Microsoft Chart Controls / Dundas Charts Clear Content?

I use Dundas chart controls and Microsoft chart controls for .NET. I currently have a method that populates a chart control with a date from a general list.

Let's say that I fill the chart with data from one list. Then I want to populate the chart with data from another list.

I have a problem filling the chart with data from the second list. I get a chart that displays the combined data from list 1 and list 2, while I want it to display only the data from the first list, and then clear the chart before displaying the data from the second list.

I tried various method calls to clear the chart control before filling it with data from the second list, but to no avail.

Is there any way to do this?

+3
source share
3 answers

I found him! Do it:

chart1.Series[0].Points.Clear();
+5
source

Comment for others who may run into this:

To clear a series of diagrams, headings and legends:

//clear chart
Chart1.Series.Clear();
Chart1.Titles.Clear();
Chart1.Legends.Clear();           
//create chart
+3
source

, .

However, I would suggest that this is just a matter of resetting the data source. Assuming you have a list of points (or some other structure), you probably should create a new instance of this data container (i.e. List), fill it in and then assign it to the chart.

Instead, it seems like you're probably trying to set the elements of an existing data container and not clear it properly.

0
source

Source: https://habr.com/ru/post/1712104/


All Articles