Search code examples
mpandroidchart

Is it possible to draw gridlines ABOVE a filled linechart?


In all the examples I have found when a linechart is filled (gradient or solid color) , this filling covers the gridlines and they dissapear. Is it possible to draw the gridlines over them?

I have tried to include .setDrawGridLines(true);, but nothing changesenter image description here


Solution

  • You can call setDrawGridLinesBehindData(false) on the relevant chart axis to have it draw the grid lines in front of the data. For example:

    YAxis yAx = chart.getAxis(YAxis.AxisDependency.LEFT);
    yAx.setDrawGridLines(true);
    yAx.setDrawGridLinesBehindData(false);
    
    XAxis xAx = chart.getXAxis();
    xAx.setDrawGridLines(true);
    xAx.setDrawGridLinesBehindData(false);