Page 1 of 1

Set one Datepicker to all charts

Posted: Tue Nov 30, 2021 3:02 pm
by Daniil
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?

Re: Set one Datepicker to all charts

Posted: Wed Dec 01, 2021 1:06 pm
by michal.f
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!

Re: Set one Datepicker to all charts

Posted: Fri Dec 03, 2021 6:57 am
by Daniil
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

Re: Set one Datepicker to all charts

Posted: Fri Dec 03, 2021 7:09 am
by Daniil
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

Re: Set one Datepicker to all charts

Posted: Fri Dec 03, 2021 4:09 pm
by michal.f
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!

Re: Set one Datepicker to all charts

Posted: Tue Dec 07, 2021 2:35 pm
by Daniil
Thanks a lot michal.f ! That is exactly what I needed.

Best regards!

Re: Set one Datepicker to all charts

Posted: Tue Dec 07, 2021 4:00 pm
by michal.f
You're welcome!

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