Setting xaxis ticks and labels in a datetime chart to a minimum time resolution #2904
Unanswered
alon-loris
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
-
Combination of setting same formatter for hour and day and settgin showDuplicates to false helped in my case |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My data contains values per days, not per hours. For example:
series: [['2021-05-02', 0], ['2021-05-03', 100], ['2021-05-04', 0]]
For some reason (the calculation of the number of ticks and their labels in a datetime chart is not fully documented), for the above example I get a chart with hour-based ticks:

I want the x-axis to show labels of days if the range is up to X months, of months if there are more than X months etc.
In other words, I do want the labels to be dynamic based on the scale, but I want to be able to set the minimum resolution to be days and not hours, and also, as a bonus, to control the thresholds for when the labels change resolution.
Is this possible in any way?

The only solution I found for getting rid of the hour labels is setting the
xaxis.labels.formatter
property but then I get:I have no idea what's the calculation that determines the number of ticks here and why is it different just because I changed the formatting function, and I don't know why there are duplicate labels. Setting
xaxis.labels.showDuplicates: false
didn't help.What fixed this was setting xaxis.tickAmount to

series.length - 1
:But this is not a good solution because:
How can this be achieved?
As a side note, the example in the docs for xaxis.labels.formatter doesn't work!
It throws an error:
Cannot read properties of undefined (reading 'replace')
Beta Was this translation helpful? Give feedback.
All reactions