Reputation: 1145
For example i have a chart like below
$("#tester").highcharts({
chart: {
type: 'column',
height:320
},
series: [{name: 'Postive',data: sPositiveTotal},
{name: 'Neutral',data: sNeutralTotal},
{name: 'Negative',data: sNegativeTotal}]
});
And i tried to update the data with a button, i do
var SentimentChart = $("#tester").highcharts();
SentimentChart.series[0].setData([{name: 'Postive',data: sPositiveTotal}, {name: 'Neutral',data: sNeutralTotal}, {name: 'Negative',data: sNegativeTotal}]);
But it doesn't as i except, how may i update it correctly?
fiddle example : http://jsfiddle.net/cmeubLr2/1/
Upvotes: 0
Views: 41
Reputation: 20536
The setData
method is called on a specific series, so you have to do the update for each individual series. It also expects just data, not series options.
So for example (JSFiddle):
changeData.series[0].setData([124, 5435, 16434, 129.2, 144.0, 176576.0, 176535.6, 148.5, 216.4, 194.1, 95.6, 54.4]);
changeData.series[1].setData([8753.6, 66.8, 98.5, 93.4, 175606.0, 84.5, 107655.0, 104.3, 91.2, 83.5, 106.6, 92.3]);
// ...
If you want to update the options as well you can use update
instead (JSFiddle):
changeData.series[0].update({
name: 'Beijing',
data: [124, 200, 200, 129.2, 144.0, 200.0, 200.6, 148.5, 216.4, 194.1, 95.6, 54.4]
});
Upvotes: 2