Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set margin/padding for x-axis values in MPAndroidChart?

I built a graph using MPAndroidChart, but there is a problem - values on x-axis overlap. enter image description here

Is there a way to fix it? Something like a margin between x-axis values?

like image 689
Orest Avatar asked Jul 13 '16 19:07

Orest


1 Answers

It's been a while since you've posted your question and probably by now you found your way around this problem, however, I'm posting this answer for anyone else who has faced this issue.

Setting

chart.getXAxis().setSpaceMin(0.5f);

would add space between the X-axis line and the chart itself. you can also use

chart.getXAxis().setSpaceMax(0.5f);

for adding space between the last value and the right X-axis of the chart.

Here is an example of a normal chart and this one is a chart with min and max space of 1.5.

By the way, I'm using MPAndroidChart V3.0.2.

like image 144
Arwen Avatar answered Sep 21 '22 02:09

Arwen