reset a chart

Aiken_Bob

Member
Joined
Jun 25, 2010
Messages
11
Programming Experience
Beginner
It may be obvious but I missing it.... How do I reset the chart so that I can use new data for the same control. I have tried the disposed method without luck. Any help would be appreciated.
 
I'm assuming you are talking about the System.Windows.Forms.DataVisualization.Charting.Chart control?, and that you are setting the data by using the DataSource property? If i'm not mistaken, can't you just change the datasource and then call the DataBind method to use a different set of data?

Example:
        Chart1.DataSource = myDataView
        Chart1.DataBind()



I'm not too familiar with this control, but if your trying to clear everything you can use the Clear methods of the Series and Chart Areas, and maybe also set the DataSource to nothing?

something like
        Chart1.DataSource = Nothing
        Chart1.Series.Clear()
        Chart1.ChartAreas.Clear()


Heres the documentation from msdn: Chart Class (System.Windows.Forms.DataVisualization.Charting), hope that is of some help...
 
I am using system.windows.forms.datavisualization.charting. But I'm not using data binding. I populate several series on a given chart from several sources. All I want to do is change some of the initial conditions and see what the graph will look like.

Thanks
 
I'm still looking for a better way - in the mean time I found that I can clear the the series and then rebuild the entire chart. Not pretty but it works
 
Back
Top