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

Change datasource of dynamically created chart

2 Answers 272 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Ant
Top achievements
Rank 1
Ant asked on 07 Mar 2016, 03:48 PM
Hi,
 
How can I dynamically create multiple charts and then change their datasource independently? 
 
Thanks
 
 

2 Answers, 1 is accepted

Sort by
0
Ant
Top achievements
Rank 1
answered on 07 Mar 2016, 04:10 PM

Here's a bit more information with an example of a dynamically generated chart:

 

  var div = $("<div/>");
  $(document.body).append(div);
  
  div.kendoChart({
    series: [ 
      { data: [1, 2] }
    ]
  });

Here is a live demo showing that: http://jsbin.com/ixupix/1/editBut how would i go about changing it's datasource as it has now id selector? I could use var div = $("<div id="chart />"); But when i do var c = $("#chart").data("kendoChart") i get undefined.

0
Iliana Dyankova
Telerik team
answered on 09 Mar 2016, 09:51 AM
Hi Ant,

You could use the setOptions method to change the chart series data. Take a look at this dojo which demonstrates a possible implementation.

Regards,
Iliana Nikolova
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
Ant
Top achievements
Rank 1
Answers by
Ant
Top achievements
Rank 1
Iliana Dyankova
Telerik team
Share this question
or