Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove extra space in bottom of x axis label ie below zero mpandroidchart

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?

enter image description here

  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);
like image 870
Shadow Avatar asked May 24 '16 18:05

Shadow


Video Answer


2 Answers

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);
like image 120
Dhruv Avatar answered Oct 08 '22 22:10

Dhruv


In version 3.0.2 method setAxisMinValue marked as @deprecated. New method is xAxis.setAxisMinimum(0f);

like image 38
northerngirl Avatar answered Oct 08 '22 22:10

northerngirl