How to set margin/padding for x-axis first/last point in MPAndroidChart?

Viewed 5353

I need some space before the first point and after the last point in the line chart showing below (red rectangle area). How do I achieve that in MPAndroidChart?

enter image description here

3 Answers

@hengstar. I meet the same question like you. The following codes work for me. I hope it will to help to you.

xAxis.setSpaceMax(0.5f);
xAxis.setSpaceMin(0.5f);
To start x - axis from 1st position add this code

xAxis.setAxisMinimum(mLineData.getXMin() - 0.5f);
xAxis.setAxisMaximum(mLineData.getXMax() + 0.5f);
Related