TGH
TGH

Reputation: 39278

Optimize chart rendering when adding series dynamically

Is there an optimized way to add multiple series dynamically to an already rendered line chart with existing series?

So far I can think of two options:

1)Calling Chart.addSeries(graphSeries) n times.

I am currently using this approach, but it's slow for multiple series

2)Reinitialize the chart from the JSON object after adding the new series to the JSON object

Chart = new Highcharts.Chart(graphData);

This however means that the entire chart has to be regenerated every time.

Is there another way to bulk add new series to a chart?

Upvotes: 0

Views: 163

Answers (1)

colestrode
colestrode

Reputation: 10668

I would use chart.addSeries with the redraw parameter set to false. Once you are done adding series, you can call chart.redraw to display the series. This will only cost you one redraw for any number of series and won't be as expensive as recreating the chart from the config.

chart.addSeries(series1, false);
chart.addSeries(series2, false);
...
chart.addSeries(seriesN, false);

chart.redraw();

http://api.highcharts.com/highcharts#Chart.addSeries()

Upvotes: 1

Related Questions