tomheaps
Posts: 11
Joined: Tue Mar 06, 2018 6:37 am

Hide datetime X axis labels for points with no data

I have an area chart with a datetime X axis and minimum tick interval of 1 day. There are no values in my data series for weekends (Mon-Fri only).

Although ordinal: true ensures the same interval for Friday-Monday as between the other days, labels for Saturdays and Sundays are still present on the X axis. Because of the reduced space available between Friday-Monday, the label for Saturday/Sunday sometimes appears at the expense of Friday/Monday labels respectively.

Is there any way to suppress (not show) labels on the X axis on days where there is no data (i.e. Saturdays and Sundays) without manually inserting null values for these days?

Thanks.
ppotaczek
Posts: 751
Joined: Mon Oct 02, 2017 3:12 pm

Re: Hide datetime X axis labels for points with no data

Hi tomheaps,

You can try to use formatter function and insert programatically null values for Saturdays and Sundays. If this solution does not suit you, please illustrate the problem with an live example.

API Reference: https://api.highcharts.com/highcharts/x ... .formatter

Best regards!
Paweł Potaczek,
Highcharts Developer
ebrahimBookwala
Posts: 1
Joined: Sat Mar 05, 2022 8:08 am

Re: Hide datetime X axis labels for points with no data

Hi team,

I have a similar problem and in my case, i don't want to use the formatter function too since that ovverides the natural behaviour of the chart labels.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Hide datetime X axis labels for points with no data

Hi ebrahimBookwala,

Welcome to our forum and thanks for contacting us with your question.

Ticks and labels are calculated automatically in case of datetime axes, regardless if there is a data or not. Currently, the formatter function solution, suggested by my colleague in the previous answer is what should be used to remove labels with no data. Alternatively you could use tickPositioner callback to remove ticks completely and thus labels too.
API reference: https://api.highcharts.com/highcharts/x ... Positioner
https://api.highcharts.com/highcharts/x ... .formatter

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

Return to “Highcharts Stock”