Clear then restore List in zedGraph

470 views Asked by At

I designed a real time graph application using zedGraph class RollingPointPairList(). User should be able to hide specific curve when checkBox is checked and show it when unchecked. The problem is that it never shows a curve again once it had been hidden. Actually, it should show curve with all points which were hide, but it draws straight line & drops specific points from list. How to do it correctly?

This is a sample code I'm using:

if (chkXScale.Checked == true) {
    zedGraphControl1.GraphPane.CurveList[0].Clear();
        zedGraphControl1.Refresh();
}
1

There are 1 answers

0
chouaib On

i Guess by calling zedGraphControl1.GraphPane.CurveList[0].Clear(); the data is removed so once you try to bring it back by checking the checkBox it finds no data to Draw !

i suggest that by the time you acquire data do 2 things:

  1. Draw it in your zeGraph control list.Add(x,y);
  2. Save the data for later use (in case you uncheck/check).

To save the data for late use you can choose any simple way you master, i just suggest using Queue As follows, so the whole operation becomes:

//declaration:
Queue<double> Xholder = new Queue<double>();
Queue<double> Yholder = new Queue<double>();
//when new data comes:
list.Add(x,y);
Xholder.Enqueue(x);
Yholder.Enqueue(y);

//when you uncheck then check the checkBox
for (int i=0; i<Xholder.Count; i++)
{
  list.Add(Xholder.Dequeue(), Yholder.Dequeue());
}

I hope that's all what you need, give me feedback when you try it