Majonez69
Posts: 13
Joined: Fri Mar 18, 2022 4:33 pm

Keep the size of navigator range the same while moving the 'window'

Hi!

I have a moderate set of timeseries data. I've added a personal callback that's passed to xAxis events which triggers on `afterSetExtremes`, basically something like this:

Code: Select all

      
    xAxis: {
      events: {
        afterSetExtremes(e) {
          if (e.trigger) {
            foo(parseInt(e.min), parseInt(e.max), true);
          }
        }
      }
    }
    
When the chart is loaded I'm setting the extremes to 1h window. What I expect is that when moving the navigator selection (moving - not expanding/colapsing) the range of 1h will be kept as is. What I'm observing is that's it's slightly modified sometimes. So instead of getting 3600000 (milliseconds) I'm getting 3599000 or 3633860 (so a difference of seconds). I guess it's somehow related to the series data, maybe there's some approximation or aligning happening.

My question is can I somehow disable this approximation, and force the range to be kept at all times, until I modify it by expanding or reducing the selection?

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

Re: Keep the size of navigator range the same while moving the 'window'

Hi Majonez69,

Thanks for contacting us with your question.

Please create a live demo showing described behaviour. You can start here: https://jsfiddle.net/BlackLabel/L4k8c9gr/

Regards!
Mateusz Bernacik
Highcharts Developer
Majonez69
Posts: 13
Joined: Fri Mar 18, 2022 4:33 pm

Re: Keep the size of navigator range the same while moving the 'window'

Hi Mateusz

I've used a different fiddle as an example, but I think my issue can be reproduced: http://jsfiddle.net/1pqkx7bf/6/

Please open the console while trying it out. The first printed line is the initial distance between the navigator handles. Now move the navigator selection around, multiple times, either by dragging or clicking, but don't drag it by the handles not to resize the selection.

What I'm getting while doing some repositioning of the navigator selection:
5.000000000000013
5.000000000000028
5
5.000000000000031
5
5
5.0000000000005
while I would like to get "5" at all times, until I resize the navigator through the handles.
So what I mean is that the distance/difference between the 2 handles or the 2 extremes i slightly changing, while I would like to keep it exactly the same if possible, until i resize the selection.

Hope that explains it, let me know if you have more questions.
Best regards!
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Keep the size of navigator range the same while moving the 'window'

Hi Majonez69,

Thanks for the explanation.

This most likely is caused by ordinal option, which by default is enabled for stock charts. Please try to disable that option and let me know if it helps. However, you need to do that for real data set, it won't work for the demo that you shared, because irregular values in that demo are most likely caused by small intervals that are unnatural for datetime axis.
Demo: https://jsfiddle.net/BlackLabel/m8Lqosae/
API reference: https://api.highcharts.com/highstock/xAxis.ordinal

Regards!
Mateusz Bernacik
Highcharts Developer
Majonez69
Posts: 13
Joined: Fri Mar 18, 2022 4:33 pm

Re: Keep the size of navigator range the same while moving the 'window'

That's it!
Thanks Mateusz, that did the trick for my data (datetime based). Appreciate your help!

Best regards :)
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Keep the size of navigator range the same while moving the 'window'

You're welcome! In case of any further questions, feel free to contact us again.
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”