Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 632
Hengstar Avatar asked Nov 28 '17 19:11

Hengstar


2 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);
like image 68
yinliang xue Avatar answered Nov 02 '22 01:11

yinliang xue


To start x - axis from 1st position add this code

xAxis.setAxisMinimum(mLineData.getXMin() - 0.5f);
xAxis.setAxisMaximum(mLineData.getXMax() + 0.5f);
like image 35
Krishna Avatar answered Nov 02 '22 01:11

Krishna