We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Update chart on data change

I have a line chart that is using a BindingList as a data source. The same BindingList is also the data source for ms-datagridview on the same form.
What so I need to do to get the chart to reflect any edits made to the data source via the datagridview.
I have tried chart1.Update(), chart1.Refresh(), chart1.Redraw.
Am I missing something obvious?

p.s.
I have verified that the BindingList's data is actually changing

5 Replies

JB Jaffersathick B Syncfusion Team April 26, 2010 05:58 PM UTC

Hi DanSChubel,

Thank you for using Syncfusion products.

I am afraid, that I was unable to reproduce this issue. Could you please have a look on the below online sample and if the issue still exists, try to reproduce in a simple sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution.

Sample link:

http://samples.syncfusion.com/ASPNET/8.2.0.18/Web/Chart.Web/samples/3.5/Data%20Binding/CustomCollections/CS/CustomCollections.aspx?args=9


Let me know if you have any concerns.

Regards,
Jaffer.B



DS Dan Schubel May 18, 2010 05:16 PM UTC

I added a button to the Windows Forms "Custom Collections" sample and I am able to update the chart when the source data changes via this code:
private void buttonAdv1_Click(object sender, EventArgs e)
{
bindList[0].Population = 500;

ChartDataBindModel dataSeriesModel = new ChartDataBindModel(bindList);
dataSeriesModel.YNames = new string[] { "Population" };
chartControl2.Series[0].SeriesModel = dataSeriesModel;
}

But this leaves me with some questions...
Why is it necessary to reassign the ChartDatabindModel?
I have other code where data is added to the bindinglist that serves as the chart's datasource via a timer, and the chart updates automatically with no additional code.
I'm curious what the Update, Refresh, and Redraw methods do. I have been searching the documentation for a description of them, but haven't found anything.


JB Jaffersathick B Syncfusion Team May 19, 2010 07:04 AM UTC

Hi DanSchubel,

Thanks for the update.

Instead of binding the data again we suggest you to update the binding list and reset the particular row of the list.

Please refer the following code snippet:

[CS]
private void button1_Click(object sender, EventArgs e)
{
bindList[0].Population = 500;
bindList.ResetItem(0);
}


Let me know if it helps.

Regards,
Jaffer.B



DS Dan Schubel May 19, 2010 01:54 PM UTC

That works, thanks!


JB Jaffersathick B Syncfusion Team May 20, 2010 12:28 PM UTC

Hi DanSchubel,

Thanks for the update.

We are glad to hear that your issue is resolved.

Please do not hesitate to get back to us for further assistance.

Regards,
Jaffer

Loader.
Live Chat Icon For mobile
Up arrow icon