aheber Posted February 29, 2008 Report Share 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! Quote Link to comment Share on other sites More sharing options...
aheber Posted February 29, 2008 Author Report Share 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. Quote Link to comment Share on other sites More sharing options...
aheber Posted February 29, 2008 Author Report Share 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. Quote Link to comment Share on other sites More sharing options...
Frank Posted February 29, 2008 Report Share 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. Quote Link to comment Share on other sites More sharing options...
aheber Posted February 29, 2008 Author Report Share 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. Quote Link to comment Share on other sites More sharing options...
Frank Posted February 29, 2008 Report Share 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.