Reputation: 13508
I am using the Dundas Chart Controls and Microsoft Chart Controls for .NET. Currently I have a method which populates the chart control with a date from a generic List.
Let's say that I populate the chart with data from one list. Then I want to populate the chart with data from another list.
I have a problem populating the chart with the data from the second list. I end up with a chart that displays the combined data from list 1 and list 2, whereas 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 have tried various method calls to clear the chart control before populating it with the data from the second list but to no avail.
Is there a way of doing this?
Upvotes: 4
Views: 13686
Reputation: 14668
A comment for others who may come across this:
To clear out the chart series, titles, and legends:
//clear chart
Chart1.Series.Clear();
Chart1.Titles.Clear();
Chart1.Legends.Clear();
//create chart
Upvotes: 3
Reputation: 74530
You should probably post some example code.
However, I would guess it is simply a matter of resetting the data source. Assuming you have a list of points (or some other structure), you should probably create a new instance of that data container (i.e. the list), populate that, and then assign it to the chart.
Instead, it seems like you are probably trying to set the elements of an existing data container and not clearing it out correctly.
Upvotes: 0