Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Set one Datepicker to all charts

Tue Nov 30, 2021 3:02 pm

I have a Stockchart and a few Highcharts. The stock chart has its own default date picker. When I update date range in the Stock chart, another Highchart should be updated with it.

How can I apply selected date range in the Stockchart to another highchart?

User avatar
michal.f
Posts: 262
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

Wed Dec 01, 2021 1:06 pm

Hello Danill,

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

You can use Highcharts.xAxis.events.afterSetExtremes callback function to fire code when changing range in chart and set extremes in another chart to achieve what you want.

Demo: https://jsfiddle.net/BlackLabel/sa67typu/
API: https://api.highcharts.com/highstock/xA ... etExtremes

Let me know if you have any further questions!
Best regards!
Michał Filipiec
Highcharts Developer

Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Re: Set one Datepicker to all charts

Fri Dec 03, 2021 6:57 am

Hello Michal,

Thanks, that helped indeed. but there is an issue.
Is there a way to update multiple charts? I cannot call multiple setExtremes inside one afterSetExtremes to update multiple charts.

Best regards,
Daniil

Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Re: Set one Datepicker to all charts

Fri Dec 03, 2021 7:09 am

I need to have the main graph containing 3 data lines and Then three separate graphs one line in each of them.
So, the main graph with A, B, C lines together. And A line graph, B line graph, C line graph - one line per graph.

Best regards,
Daniil

User avatar
michal.f
Posts: 262
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

Fri Dec 03, 2021 4:09 pm

Hi Danill,

You can use a loop to execute setExtreme for all charts without assigning them to variables, in the demo I also showed how you can do it so that you can update others from each chart without generating an infinite loop.

Demo: https://jsfiddle.net/BlackLabel/0jm7bhp8/

Feel free to ask any further questions!
Best regards!
Michał Filipiec
Highcharts Developer

Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Re: Set one Datepicker to all charts

Tue Dec 07, 2021 2:35 pm

Thanks a lot michal.f ! That is exactly what I needed.

Best regards!

User avatar
michal.f
Posts: 262
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

Tue Dec 07, 2021 4:00 pm

You're welcome!

If you have any more questions associated with Highcharts, feel free to ask.
Best regards!
Michał Filipiec
Highcharts Developer

Return to “Highcharts Stock”