aheber Posted February 29, 2008 Report Posted February 29, 2008 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!
aheber Posted February 29, 2008 Author Report Posted February 29, 2008 Updating to: chart1.Data[0, 0] = 0; chart1.Data.Clear(); still leaves the old data in the charts and stacks the new data behind it.
aheber Posted February 29, 2008 Author Report Posted February 29, 2008 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.
Frank Posted February 29, 2008 Report Posted February 29, 2008 chart1.Data.Clear(); Clears all the data in the chart. I don't knw what you mean by "This, however still results in the follow up queries being stacked into the same chart, without the old chart data clearing." Can you please elaborate.
aheber Posted February 29, 2008 Author Report Posted February 29, 2008 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.
Frank Posted February 29, 2008 Report Posted February 29, 2008 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.