bharat.nagdev
Posts: 24
Joined: Mon Aug 10, 2020 1:45 pm

Range selector changes x axis min randomly

Hello there,
I am using high stock with a boost module.
I have custom range selector options such as 1d,1m,3m,6m,1y.

When I change the range selector option from 1m to 1d it gives x-axis min-max with a difference of 24 hours exactly.
When I change the range selector option from 6m to 1d it gives x-axis min-max with a difference of more than 24 hours.

Following is the fiddle which has all the chart options I use: https://jsfiddle.net/rmwc6x3j/

Can anyone help me provide details on how the x-axis min-max is calculated and why it changes in certain cases?

I was unable to reproduce the issue on highcharts cloud or codepen or in the fiddle shared but this occurs in my environment.

Any details related to the x-axis calculation will be helpful.

Thanks in advance. :)
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Range selector changes x axis min randomly

Hi bharat.nagdev,

Thanks for contacting us with your question.

There are many things that are taken into consideration when it comes to calculating x axis range. First of all there are X axis options like minRange or tickInvertal that will have an impact on calculated range. Then comes your data granuality which may vary and depending on that Highcharts try to find the most optimal date range. Other things that may also have an impact are data grouping and ordinal options. In general these calculations are quite complex and may vary depending on chart config. Feel free to refer directly to the code and look how extremes are applied to the axis. In general, every time you select one of the available ranges on your range selector, the setExtremes method is being called under the hood and this is how specific range is applied to the axis. I can't really tell what can be done without taking a look at the recreated issue, but if you want to make you chart behaviour more consistent, they you could try to overwrite default range buttons and apply your own calculated extremes.
API reference: https://api.highcharts.com/class-refere ... etExtremes

Let me know if you have any further questions!
Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”