Aneesh
Posts: 4
Joined: Tue Jan 25, 2022 4:34 pm

How to set fixed number of xAxis labels

Hello,

I am trying to set fixed number of labels for xAxis in iOS app. Here xAxis is of type "datetime", right now label count random based on the data what we provide. Is there any we can set the date label count to 5 for example: 6/Dec, 7/Dec, 8/Dec, 8/Dec, 9/Dec,10/Dec need to be shown in in xAxis.

Thanks.
magdalena
Posts: 517
Joined: Tue Aug 24, 2021 1:32 pm

Re: How to set fixed number of xAxis labels

Hello,

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

I'm not sure if I understood correctly. Limit amount of labels by parameter is not possible, but you have a few ways:
- use tickpositions https://api.highcharts.com/highcharts/x ... kPositions
- use formatter https://api.highcharts.com/highcharts/x ... .formatter
- use positioner https://api.highcharts.com/highcharts/x ... Positioner

Or maybe the setExtremes will be helpful?

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

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

Let me know if you have any further questions,
Regards!
Magdalena Gut
Developer and Highcharts Support Engineer

Return to “Highcharts Usage”