MPAndroidChart hide background grid
Solution 1
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)
Solution 2
Simply below three lines remove horizontal and vertical lines in the bar chart.
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);
Solution 3
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)
Solution 4
Hide Background grid
chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
Solution 5
Use this code to clear all lines with labels:
mChart.setTouchEnabled(true);
mChart.setClickable(false);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setDoubleTapToZoomEnabled(false);
mChart.setDrawBorders(false);
mChart.setDrawGridBackground(false);
mChart.getDescription().setEnabled(false);
mChart.getLegend().setEnabled(false);
mChart.getAxisLeft().setDrawGridLines(false);
mChart.getAxisLeft().setDrawLabels(false);
mChart.getAxisLeft().setDrawAxisLine(false);
mChart.getXAxis().setDrawGridLines(false);
mChart.getXAxis().setDrawLabels(false);
mChart.getXAxis().setDrawAxisLine(false);
mChart.getAxisRight().setDrawGridLines(false);
mChart.getAxisRight().setDrawLabels(false);
mChart.getAxisRight().setDrawAxisLine(false);
and use this to remove value of all points:
LineDataSet set1;
set1.setDrawValues(false);
Related videos on Youtube
Metehan Toksoy
Blog writer, graduated from Yildiz Technical University in Istanbul. Android and iOS developer.
Updated on July 09, 2022Comments
-
Metehan Toksoy almost 2 years
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?
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?
-
Hitesh Sahu almost 8 yearshow you have removed values from nodes ?
-
Anil P Babu over 7 years@HiteshSahu use lineData.setDrawValues(false)
-
-
NinjaCoder almost 9 years@philipp-jahoda Do you know if we can change grid color to alternate between white and grey
-
Tefa over 6 years@Philipp How to remove the horizontal axis
-
Simon over 6 yearsTurn off the horizontal grid lines by using: mChart.getAxisRight().setDrawGridLines(false);
-
Prince Dholakiya almost 6 yearshow to remove barChart of outer line ?
-
sadat over 5 yearsIs it possible to remove or keep some of the grids among all?
-
Maf almost 4 yearsWhat about the line at the top?
-
Muhammed Haris over 3 years@PrinceDholakiya use below code for remove outer line: barChart.getAxisRight().setDrawAxisLine(false); barChart.getAxisLeft().setDrawAxisLine(false); barChart.getXAxis().setDrawAxisLine(false);
-
Diego Palomar over 2 yearsI was looking for all this. Nice one! :D