manasa7386
Posts: 1
Joined: Sun Oct 24, 2021 8:03 am

Using different Series data with same chart options

Hai

I have created required chart options.

Now, I want to produce 6 charts. The only thing that changes in these charts is series data.
But writing the same chart options for all these graphs is not effective.

Is there a way I can render different series data charts with same chart options?
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Using different Series data with same chart options

Hello manasa7386,

Welcome to our forum and thanks for contacting us with your question!

You could create a single config for all charts and store it for example in a variable. Then you can pass that variable to each chart constructor in like that:

Code: Select all

const chartOptions = {...}

Highcharts.chart('DOMelement', chartOptions)
Once chart is created you can update each chart with data, for example using chart.addSeries method.
Demo:https://jsfiddle.net/BlackLabel/zgd1nL97/
API reference: https://api.highcharts.com/class-refere ... #addSeries

Let me know if that was what you were looking for!
Best regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”