Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing data dynamically for a series in Highcharts

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); 
like image 280
Staple Avatar asked Jan 16 '14 03:01

Staple


People also ask

What is plotOptions in Highcharts?

The plotOptions is a wrapper object for config objects for each series type. The config objects for each series can also be overridden for each series item as given in the series array. Configuration options for the series are given in three levels. Options for all series in a chart are given in the plotOptions.

What is Highchart series?

A series is a set of data, for example a line graph or one set of columns. All data plotted on a chart comes from the series object.

How many data points can Highcharts handle?

Re: High Charts Data LimitBy default it is set to 1000, you should increase this value in your chart. If you are having problems with your chart it is good habit to open the console (Developer Tools) and look for errors.

Is Highcharts an API?

If you are a developer who would like to create hosted charts programmatically, then the Highcharts Cloud API might be for you.


2 Answers

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.

like image 74
Strikers Avatar answered Sep 21 '22 02:09

Strikers


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.

like image 31
Raging Bull Avatar answered Sep 18 '22 02:09

Raging Bull