rdp1414
Posts: 41
Joined: Wed Oct 27, 2021 2:06 pm

Uneven spacing when xAxis oridinal is enabled

Hello,

1. We are giving input about stock prices coming from server and plotting it on highstock chart .
2. So, the input data doesn't contain data for weekends i.e. data comes for 7 Jul, 8 Jul, 11 Jul, ...because 9 and 10 Jul is weekend.
3. That is why we decided to enable [xAxis.ordinal](https://api.highcharts.com/highstock/xAxis.ordinal) which is already enabled by default.
4. But we see uneven spacing b/w xAxis ticks - See [fiddle](https://jsfiddle.net/snpyqLmd/1/). If you expand the o/p to 1200px, then look at Gap b/w (5, 9) > Gap b/w (9, 13). Similarly gap b/w (19, 23) > Gap b/w (23, 27).

Is there a way to have even xAxis tick gapping?
Or can you please give some advice / opinion on what we should do?

Thank You,
Rajdeep
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Uneven spacing when xAxis oridinal is enabled

Hi there,

Thank you for contacting us with your question.

The xAxis ordinal works perfectly fine in your case. The main use case for this one is to equally space the points, no matter what timestamp differences they have.
The xAxis ticks problem is a different one to the ordinal property, and can be adjusted with the tickInterval, tickPixelInterval or tickPositions. Take a look at the topic regarding the same issue here: viewtopic.php?t=19378

Example usage of tickPositions: https://jsfiddle.net/BlackLabel/re42kt68/
(for this dataset it will work just fine, but be careful with the larger datasets as it might be performance heavy)

Let me know once you need anything else!
Best regards
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Stock”