Jump to content
Software FX Community

Clearing charts question


aheber

Recommended Posts

Using a chart that the user can manually refresh (pulling new SQL data), I'd like to chart to be cleared (reset) before the updated chart data is displayed.  I've tried including as the first item after the 'refresh' button is pushed:

chart1.Data.Clear();

This, however still results in the follow up queries being stacked into the same chart, without the old chart data clearing.

Thanks for any help!

Link to comment
Share on other sites

I found that if I call,

chart1.Reset();

this has the desired result of clearing the data from the chart, and redrawing with only the new data, however, this results in loosing all of my custom chart properties which were set on the form properties and is not desired.

Link to comment
Share on other sites

After the initial query, the chart looks good with two data lines shown.

After the second query, which should clear the data from the initial chart with, 'chart1.Data.Clear();' a second set of lines are drawn (in 3-D) behind the first set, and two additional entries are added to the legend box. 

post-4661-13922403165189_thumb.jpg

Link to comment
Share on other sites

chart1.Data.Clear();

Clears the data completely, I think what you may be experiencing is that the second time you are binding the data to the chart not clearing the Fields collection and therefore ending up with duplicate fields. It is only at the time of binding to the new data that the duplicate series are created, not that they remained there from before.

Make sure that if you are adding fields to the Fields collection (chart.DataSourceSettings.Fields) you are clearing it first, otherwise, like any other collection it will ad to the existing items.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...