MPAndroidChart hide background grid

38,544

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. enter image description here

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

enter image description here

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);
Share:
38,544

Related videos on Youtube

Metehan Toksoy
Author by

Metehan Toksoy

Blog writer, graduated from Yildiz Technical University in Istanbul. Android and iOS developer.

Updated on July 09, 2022

Comments

  • Metehan Toksoy
    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?

    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

    • Hitesh Sahu
      Hitesh Sahu almost 8 years
      how you have removed values from nodes ?
    • Anil P Babu
      Anil P Babu over 7 years
      @HiteshSahu use lineData.setDrawValues(false)
  • NinjaCoder
    NinjaCoder almost 9 years
    @philipp-jahoda Do you know if we can change grid color to alternate between white and grey
  • Tefa
    Tefa over 6 years
    @Philipp How to remove the horizontal axis
  • Simon
    Simon over 6 years
    Turn off the horizontal grid lines by using: mChart.getAxisRight().setDrawGridLines(false);
  • Prince Dholakiya
    Prince Dholakiya almost 6 years
    how to remove barChart of outer line ?
  • sadat
    sadat over 5 years
    Is it possible to remove or keep some of the grids among all?
  • Maf
    Maf almost 4 years
    What about the line at the top?
  • Muhammed Haris
    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
    Diego Palomar over 2 years
    I was looking for all this. Nice one! :D