ortizh
Posts: 30
Joined: Thu Oct 22, 2020 10:35 am

Irregular space between ticks of X-Axis

Fri Sep 15, 2023 12:15 pm

Hi!
I use a stockchart to display time series with multiple Y axis (one axis by unit).
At start, ticks on X-Axis are equidistant, but if I use the left or the right handle of the navigator, space between ticks are no longer equal.
See attached images.
Is there a way to maintain equidistant space between ticks ?
Thanks!

ortizh
Posts: 30
Joined: Thu Oct 22, 2020 10:35 am

Re: Irregular space between ticks of X-Axis

Fri Sep 15, 2023 12:20 pm

the missing attached files
Attachments
okAtStart.png
okAtStart.png (100.98 KiB) Viewed 79 times
notLongerOkAfter.png
notLongerOkAfter.png (106.13 KiB) Viewed 79 times

jakub.j
Posts: 857
Joined: Tue Jan 24, 2023 11:14 am

Re: Irregular space between ticks of X-Axis

Mon Sep 18, 2023 6:56 am

We appreciate you reaching out to us!

Could you reproduce the issue in an online editor that I could work on?
It is hard to tell you what is not working and what could be done without taking a look at your code.

You can base on this demo -> https://jsfiddle.net/BlackLabel/9hn2wbkr/ or any other stock demo you can find on our demo page.

Best regards
Jakub
Jakub
Highcharts Developer

ortizh
Posts: 30
Joined: Thu Oct 22, 2020 10:35 am

Re: Irregular space between ticks of X-Axis

Mon Sep 18, 2023 8:45 am

Hi Jakub,

I managed to reproduce it with the fiddle you suggested, and without modifying it.
In the attached file you can see that the space between '18 Sep' and '21 Sep' is smaller than the one between '21 Sep' and '23 Sep' where the first one represents 3 days and the second one ony 2...
Thanks!

ortizh
Posts: 30
Joined: Thu Oct 22, 2020 10:35 am

Re: Irregular space between ticks of X-Axis

Mon Sep 18, 2023 8:48 am

Screenshot_2023-09-18_10-32-20.png
Screenshot_2023-09-18_10-32-20.png (26.54 KiB) Viewed 45 times

jakub.j
Posts: 857
Joined: Tue Jan 24, 2023 11:14 am

Re: Irregular space between ticks of X-Axis

Mon Sep 18, 2023 9:31 am

Hey!

This is exactly how xAxis.ordinal works.

By default, it is set to true and what it does, is that it makes the spaces between the points exactly the same. So If you have one points on 16th, 17th and 20th of September, the spaces on xAxis between them will be equal. That's why there are different distances between xAxis ticks.

If you turn xAxis.ordinal to false, the spaces between points will be equivalent to how much they are really apart from each other, also the spaces between xAxis ticks will be exactly the same. Check out the demo below:

Demo: https://jsfiddle.net/BlackLabel/kawz0g23/

Let me know if you have any further questions!
Best regards
Jakub
Jakub
Highcharts Developer

Return to “Highcharts Usage”