31

I have a chart working fine with data in the options, when I leave the data empty for a series and try the below (so I can change the data depending on a click) it doesn't work, any ideas?

options.series[0].data = [35.00,35.91,36.82,37.73,38.64];
var chart = new Highcharts.Chart(options);
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Staple
  • 712
  • 1
  • 10
  • 20

3 Answers3

38

you can also go with series.setData(). This will allow you to change the entire data of a particular series.

Here is the API link for it.

Hope this will be of use for you.

beaver
  • 17,333
  • 2
  • 40
  • 66
Strikers
  • 4,698
  • 2
  • 28
  • 58
11

You can update the values dynamically as follows :

chart.series[0].setData([89,71,16,12,14]);

If you want to change both value and label, create an array of arrays:

chart.series[0].setData([['Apple',89], ['Orange',71], ['Banana',16], ['Grapes',12], ['Others',14]]);

JSFiddle Demo to update data on a button click.

Raging Bull
  • 18,593
  • 13
  • 50
  • 55
5

Eureka - needs nested square brackets so this below works..

options.series[0].data = [[35.00,35.91,36.82,37.73,38.64]];
Staple
  • 712
  • 1
  • 10
  • 20