在我的C#应用程序中,使用工作正常的点图表.但是,如果我试图清除所有绘图点,它就不会清除.这该怎么做?
请参考下面的代码,
series1.Points.AddXY(1, 10);//Plotting the points in chart
series2.Points.AddXY(2, 20);
chart1.Series.Clear(); //I tried to clear using this code
Run Code Online (Sandbox Code Playgroud)
如果我尝试上面的代码清除,它将删除整个图表,但我想只清除绘制的点.
要清除系列中的所有要点:
chart1.Series[0].Points.Clear();
Run Code Online (Sandbox Code Playgroud)
要删除系列中的第一个点:
chart1.Series[0].Points.RemoveAt(0);
Run Code Online (Sandbox Code Playgroud)
清除所有系列中的所有要点:
foreach(var series in chart1.Series)
{
series.Points.Clear();
}
Run Code Online (Sandbox Code Playgroud)