Reputation: 1935
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?
Upvotes: 55
Views: 43554
Reputation: 380
code for removing outer line:
barChart.getAxisRight().setDrawAxisLine(false);
barChart.getAxisLeft().setDrawAxisLine(false);
barChart.getXAxis().setDrawAxisLine(false);
code for removing gridline
barChart.getAxisRight().setDrawGridLines(false);
barChart.getAxisLeft().setDrawGridLines(false);
barChart.getXAxis().setDrawGridLines(false);
Upvotes: 0
Reputation:
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);
Upvotes: 13
Reputation: 47
to remove borders from chart you can use setDrawBorder(boolean) property.
chart.setDrawBorders(false);
Upvotes: 0
Reputation: 2724
Hide Background grid
chart.getXAxis().setDrawGridLines(false);
chart.getAxisLeft().setDrawGridLines(false);
chart.getAxisRight().setDrawGridLines(false);
Upvotes: 9
Reputation: 701
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)
Upvotes: 11
Reputation: 1297
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);
Upvotes: 14
Reputation: 2315
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)
Upvotes: 135