Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart hide background grid

I'm using MPAndroidChart - LineChart in my android application. I want to remove gridlines from the background . How can I remove gridlines from the background?

MPAndroidChart Line Chart Example

Library: MPAndroidChart on GitHub

EDIT: I created my own custom LineChart using this library. I want to remove bottom line. how can I do that too? Custom LineChart

like image 496
Metehan Toksoy Avatar asked Jul 07 '15 08:07

Metehan Toksoy


4 Answers

Use this:

mChart.getAxisLeft().setDrawGridLines(false);
mChart.getXAxis().setDrawGridLines(false);

Please note you may need right axis or both of them. It depends on axis you are actually using.

UPDATE: Is it axis line? If it is, then simply chart.getXAxis().setEnabled(false)

Also possible: chart.getAxisLeft().setDrawAxisLine(false)

like image 81
MightySeal Avatar answered Oct 31 '22 19:10

MightySeal


Simply below three lines remove horizontal and vertical lines in the bar chart. enter image description here

barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);

enter image description here

like image 23
badarshahzad Avatar answered Oct 31 '22 20:10

badarshahzad


Non of the above helped me to hide all axis lines. I just needed clean sheet with bars. Code below did the work:

    barChart.xAxis.isEnabled = false
    barChart.axisLeft.isEnabled = false
    barChart.axisRight.isEnabled = false

provided in kotlin, in java methods will look like that: setEnabled(false)

like image 11
Zhangali Bidaibekov Avatar answered Oct 31 '22 19:10

Zhangali Bidaibekov


Hide Background grid

    chart.getXAxis().setDrawGridLines(false);
    chart.getAxisLeft().setDrawGridLines(false);
    chart.getAxisRight().setDrawGridLines(false);
like image 9
Shaon Avatar answered Oct 31 '22 19:10

Shaon