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

Set one Datepicker to all charts

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?
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

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
https://blacklabel.pl/highcharts/
Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Re: Set one Datepicker to all charts

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

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
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

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
https://blacklabel.pl/highcharts/
Daniil
Posts: 4
Joined: Tue Nov 30, 2021 2:43 pm

Re: Set one Datepicker to all charts

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

Best regards!
michal.f
Posts: 1114
Joined: Thu Aug 12, 2021 12:04 pm

Re: Set one Datepicker to all charts

You're welcome!

If you have any more questions associated with Highcharts, feel free to ask.
Best regards!
Michał Filipiec
Highcharts Developer
https://blacklabel.pl/highcharts/

Return to “Highcharts Stock”