I have a chart with two series that share the same X axis values. I want to subtract the Y values and create a new series.
There are two ways I've tried so far:
Convert the points on the chart and put them into an array and subtract them:
double[] arrayX = new double[chart2.Series[0].Points.Count()]; double[] arrayY = new double[chart2.Series[0].Points.Count()]; double[] arrayResult = { }; for (int i = 0; i < chart2.Series[0].Points.Count(); i++) { arrayX[i] = chart2.Series[0].Points[i].XValue; arrayY[i] = chart2.Series[0].Points[i].YValues[0]; }
The issue with this is that this only gets the X Values from the first series and leaves out the second series X Values.
When I add the points to the chart I used this:
chart2.Series[SplitListBox.Items[0].ToString()].Points.AddXY(e, firstval); chart2.Series[SplitListBox.Items[1].ToString()].Points.AddXY(e, firstval);
Both of which are in separate loops. I was going to use 2 array to catch the points (e,firstval) for each loop but I don't know how to subtract the two from each other and still keep the values that exist in one series but not in the other.