Dan A
Dan A

Reputation: 53

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

Upvotes: 1

Views: 1365

Answers (2)

Peter234
Peter234

Reputation: 1052

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 ;)

Upvotes: 0

Philipp Jahoda
Philipp Jahoda

Reputation: 51411

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.

Upvotes: 2

Related Questions