Hi all,
For my project, I need to add & update real-time data to my dual-y graph. The Y and Y2 values share the same X value and I created it already. Now I have a function that adds the new point pairs to the curve lists.
Here is my problem: My Y and Y2 values are always added to the curve list of the first curve. How can I get the Y2 value added to the second curve list in my graph?
Here is my function code:
private void AddDataToGraph(ZedGraphControl zg1, XDate xValue, double yValue1, double yValue2)
{
// Make sure that the curvelist has at least one curve
if (zg1.GraphPane.CurveList.Count <= 0)
return;
// Get the first CurveItem in the graph
LineItem curve = zg1.GraphPane.CurveList[0] as LineItem;
if (curve == null)
return;
// Get the PointPairList
IPointListEdit list = curve.Points as IPointListEdit;
IPointListEdit list2 = curve.Points as IPointListEdit;
// If this is null, it means the reference at curve.Points does not
// support IPointListEdit, so we won't be able to modify it
if (list == null || list2 == null)
return;
// add new data points to the graph
list.Add(xValue, yValue1);
list2.Add(xValue, yValue2);
// force redraw
zg1.Invalidate();
}
Maybe some of you did this already or can tell me how the Y2 values can be added to the 2nd curve list.
Thanks.