Highcharts: Updating a Pie Chart with setData()
highcharts, json
Solution
Edited: When you set a new data you have to set as array of arrays for all pie parts in this case. In my Example I have six categories, so I've to set data for all of them.
So, in this case you have to do something like:
var seriesData = [];
$.each(browser_chart.series, function(i, item) {
if(item.name == 'Browser share'){
seriesData.push(["serie"+i, someNumber]);
}
});
chart.series[0].setData(seriesData, true);
Problem
I am trying to work out how to update a Highcharts pie chart but for the life of me cannot seem to get it working right. I have looked over the documentation and have been able to get a bar and line and spline graph to update fine but when using this function for pie charts it just does not work. I am currently feeding in: ``` item.setData([["none", 100]], true); ``` Where item equals the series like so: ``` $.each(browser_chart.series, function(i, item){ if(item.name == 'Browser share'){ console.log(data.browsers); item.setData([["none", 100]], true); } }); ``` Which as shown in the demos is how the data for a pie chart is formatted. Problem is it cannot seem to read the series correctly. I try: ``` item.setData([\"none\", 100], true); ``` And it seems to do something but cannot read the x and y values right (which of course means it's wrong). Can anyone here point me in the direction to get this working? Thanks,