Clear ZedGraph Data
Asked Answered
A

3

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????

Ahoufe answered 14/6, 2011 at 14:19 Comment(0)
M
15
zg1.GraphPane.CurveList.Clear();
zg1.GraphPane.GraphObjList.Clear();
Mitigate answered 15/6, 2011 at 7:37 Comment(2)
To redraw the graph you may also need to call zg1.Invalidate()Mitigate
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.Thermistor
B
1

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

Byrom answered 24/2, 2013 at 3:16 Comment(1)
This does not answer the question. A comment at best, but something I think the OP is already aware of anywayUnthrone
J
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()

Justinjustina answered 20/9, 2013 at 15:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.