5

I am using ZedGraph on a windows form to display bar chart. Following code executes when user click on a button.

zg1.GraphPane.AddBar("Series", null, y, Color.Red);

It adds an extra bar every time user click on button. I am looking for a way to reset or clear data already in chart.

How can i do that????

Manjoor
  • 4,091
  • 10
  • 43
  • 67

3 Answers3

15
zg1.GraphPane.CurveList.Clear();
zg1.GraphPane.GraphObjList.Clear();
Patrick
  • 1,138
  • 7
  • 13
  • To redraw the graph you may also need to call `zg1.Invalidate()` – Patrick Jun 15 '11 at 07:49
  • Why are `CurveList` and `GraphObjList` both cleared? How would it work if I tried `zg1.GraphPane.Points = null;` or `zg1.GraphPane.Points = newPointPairList;` ? Understanding this would help me more than trial and error on my end. –  Jul 13 '12 at 20:46
1

don't forget to give zg1.Refresh() if never see the result if you don't refresh.

santo
  • 11
  • 1
  • 1
    This does not answer the question. A comment at best, but something I think the OP is already aware of anyway – musefan Jul 17 '13 at 11:32
0

No Need to clear anything, the think you need to put at the end of the code after generating the graph is zg1.Refresh()

Dennis Henry
  • 76
  • 10