This is a migrated thread and some comments may be shown as answers.

[Solved] Chart Binding to shared DataSource

1 Answer 173 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Daris
Top achievements
Rank 1
Daris asked on 17 Oct 2014, 03:04 PM
I am confused about chart behavior when the chart is bound to a datasource that is shared by multiple widgets.

Specifically, I have a chart and a grid that share a datasource. When I page through the data via the grid, the datasource is firing off change events but the chart seems to remain oblivious. So I had to write an extra function:

01.var statsByUserDataChange = function(e) {
02.  var chart = $("#x-by-user").data("kendoChart");
03. 
04.  if( chart.dataSource.page() !== e.sender.page() ) {
05.    chart.dataSource.page(e.sender.page());
06.  }
07. 
08.  if( chart.dataSource.sort() !== e.sender.sort() ) {
09.    chart.dataSource.sort(e.sender.sort());
10.  }
11. 
12.  chart.refresh();
13.};

This function is used as the dataSource change event handler. If I just try chart.refresh() its as if the dataSource hasnt been changed even though it clearly has.

Questions:
Why is it that when the grid manipulates the dataSource and the refresh method on the chart is called, the chart data remains the same?
Is the above method the best way to tell the chart to change?

1 Answer, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 21 Oct 2014, 07:08 AM
Hi Daris,

The chart is bind to the dataSource's change in order to get the latest data from the dataSource. Because of that in change event we will repaint the chart with the new data.

Regards,
Hristo Germanov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Charts
Asked by
Daris
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Share this question
or