MPAndroidChart how to make y-axis to start at non-zero value?

Viewed 9552

I am using MPAndroidChart library and have a set of data entries where the Y values are between 20 - 30 and I'm currently displaying it in a Line chart. However, I notice that there is a big gap because the Y-axis starts at 0 instead of 20.

Screenshot

How can I make Y-axis to start at the 20 instead of 0? Or even better the minimum of all y-values?

Thank you for your time!

3 Answers

The last version includes a left and right axis. You can set to zero like this (Kotlin):

chart.axisLeft.axisMinimum = 0f
chart.axisRight.axisMinimum = 0f

You can set zero in Bar Graph like this in Java

 barChart.getAxisLeft().setAxisMinValue(0f);
 barChart.getAxisRight().setAxisMinValue(0f);
Related