stekeel
Posts: 2
Joined: Thu Apr 01, 2021 8:13 am

Same x Axis data for multiple series

Hi there

First of all, highcharts is fantastic.

So my question: I use highstock for displaying multiple series in the same chart (to compare for instance) like this:

series: [
{
name: 'series 0',
data: [[1530835200000,1000.3462134169145],[1530921600000,1001.7449198288277], ...
},
{
name: 'series 1',
data: [[1530835200000,999.2103631641498],[1530921600000,998.8665083467671], ...
},
{
name: 'series 2',
data: [[1530835200000,999.7318896222658],[1530921600000,999.2428880011332], ...
}
]

now the thing is that for every point for every series I need to define the x data (time in millis). When having many time series the data part becomes very big and the information for every point is the same (given the series have all the same length). is there a way to define the x-data only once only put only the y-data in the series data?

thanks and best

stephen
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Same x Axis data for multiple series

Hello stekeel!

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

I'm afraid there's no API option to do that, but you can define xData in an array and then refer to it inside series code.

I guess that you can also try to update each point x coordinate in an event function. It will require less code, but calling updating function for each point is not the best solution regarding performance.

Demo: https://jsfiddle.net/BlackLabel/suwcehf4/

Best regards!
Dominik Chudy
Highcharts Developer
stekeel
Posts: 2
Joined: Thu Apr 01, 2021 8:13 am

Re: Same x Axis data for multiple series

thanks a lot for your help, i will do as you suggested!
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Same x Axis data for multiple series

You're welcome!

In case of any further questions, feel free to contact us again.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Stock”