0๐
I think you should implement ticks.callback
options in X axis.
See doc: https://www.chartjs.org/docs/latest/axes/labelling.html#creating-custom-tick-formats
In the callback you can implement the logic you need (as you described above).
Returning undefined
or empty string from callback, the label is not drawn.
- Chartjs-The options don't work when creating my chart using chartjs (4.3.0) with react-chartjs-2 (5.2.0)
- Chartjs-Chart js โ set width to a specific bar
Source:stackexchange.com