Search code examples
c#zedgraph

Clear or remove all chart on zedgraph


How can I clear the chart of zedGraph?
z1.GraphPane.CurveList.Clear(); command only clear the curve alone. I want to clear entire graph and replace with new chart line.


Solution

  • You might have gotten the answer by now, but for others who are interested in this topic, here is what I do in my own code, I have a clear method that has the following calls that clear my chart,

      z1.GraphPane.CurveList.Clear();
      z1.GraphPane.GraphObjList.Clear();
      z1.GraphPane.Title.Text = "";
      z1.GraphPane.XAxis.Title = "";
      z1.GraphPane.YAxis.Title = "";
      z1.GraphPane.Y2Axis.Title = "";
      z1.GraphPane.XAxis.Type = AxisType.Linear;
      z1.GraphPane.XAxis.Scale.TextLabels = null;
      z1.RestoreScale(z1.GraphPane);
      z1.AxisChange();
      z1.Invalidate();