Hi I used MpAndroidChart library. I mentioned label at bottom of the chart but it takes extra space to assign for label ie below 0 value. How to reduce or remove space at bottom of zero?
You can see screenshot below where there is a huge space between 0 and the label. How to remove that spacing?
barChart = (BarChart) findViewById(R.id.chart);
XAxis xAxis = barChart.getXAxis();
xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
YAxis leftAxis = barChart.getAxisLeft();
leftAxis.setDrawAxisLine(true);
leftAxis.setDrawGridLines(true);
YAxis rightAxis = barChart.getAxisRight();
rightAxis.setDrawAxisLine(true);
rightAxis.setDrawGridLines(true);
Try to add:
leftAxis.setAxisMinValue(0f);
rightAxis.setAxisMinValue(0f);
Hope, this answer will solve your problem.
Edit 1:
For newer version, method has been changed to:
leftAxis.setAxisMinimum(0f);
rightAxis.setAxisMinimum(0f);
In version 3.0.2 method setAxisMinValue
marked as @deprecated.
New method is xAxis.setAxisMinimum(0f);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With