Reputation: 1145
I know we should use setData()
to update the series of the chart,
but i don't know how to update the series when creating some column chart since it's series looks like below
series: [{
name: 'Tokyo',
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
name: 'New York',
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
}, {
name: 'London',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
}, {
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]
i have made a fiddlejs as example http://jsfiddle.net/cmeubLr2/1/
Upvotes: 0
Views: 70
Reputation: 3192
This fiddle will fix your problem. http://jsfiddle.net/cmeubLr2/5/
You just have to change each series[].
$('#changeData').on('click',function(){
var changeData = $('#container').highcharts();
//TOKYO
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]);
//New York
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]);
//London
changeData.series[2].setData([46578.9, 387657.8, 37659.3, 41.4, 47.0, 48.3, 57659.0, 59.6, 52.4, 65.2, 59.3, 51.2]);
//Berlin
changeData.series[3].setData([427657.4, 33.2, 34.5, 397657.7, 576572.6, 75765.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]);
Upvotes: 2