Amcharts how to push new chart data into chart without reloading of whole chart?

redrom picture redrom · Sep 17, 2014 · Viewed 18.8k times · Source

I would like to replace new data in JSON to chart and display them in the chart without reload of whole canvas. Is it possible in AmCharts library and if yes, how can i do it?

Thanks for any advice.

Answer

Simon picture Simon · Sep 17, 2014

Here is an example for you... http://jsfiddle.net/Se2UE/4/

I had a similar issue previously. You just need to add the data to a new array and update the graph. The key elements are:

//New data array
var NewChartData = [];

//Adding new data to array
NewChartData.push(JSON.parse(D));

//Setting the new data to the graph
chart.dataProvider = NewChartData;

//Updating the graph to show the new data
chart.validateData();

For this example I just used data from a DIV element on the page but you can use the same method to get the data from another source.