简体   繁体   中英

How to draw all x-axis labels in a BarChart

I'm using the great mpandroidchart libs for drawing various graph in our apps and first of all I'm deeply sorry if this question will be redundat or stupid. Anyway, I have this BarChart which is drawing great except to the fact that i can't find a way to force the drawing of ALL XLabels. It just draw some of them and obviously if I pinch the view they are coming up but i would like to show them always, without the needs of zooming. Hope is much clear. Thanks

Unfortunately there is no way to force draw all x-axis-labels . The chart will prevent overlapping labels from being drawn.

What you can do is reduce the space between the labels to the absolute minimum by calling:

XAxis xa = chart.getXAxis();
xa.setSpaceBetweenLabels(0); // space in characters

This will make sure the space between the labels is kept to a minimum. Default space between labels is 4 characters.

I know the question is a bit older... But the posted solution didn't work for me. I used:

XAxis xa = chart.getXAxis();
xa.setLabelsToSkip(0);

And this worked perfectly! Hope it helps somebody ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM