Janardhan Y
Janardhan Y

Reputation: 257

Android : MPAndroidChart how to remove left side line

for Line chart i'm using mp android chart i want to remove the line which is left side of the graph not the gridlines.

code:-

    chart.setGridBackgroundColor(128);
    chart.setBorderColor(255);
    chart.getAxisRight().setEnabled(false);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setEnabled(false);
    chart.setDrawGridBackground(true);
    XAxis xAxis = chart.getXAxis();
    xAxis.setDrawGridLines(true);
    chart.getAxisRight().setDrawLabels(false);
    chart.getAxisLeft().setDrawLabels(false);
    chart.getLegend().setEnabled(false);
    chart.setPinchZoom(false);
    chart.setDescription("");
    chart.setTouchEnabled(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.getXAxis().setEnabled(true);
    chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    chart.getXAxis().setDrawGridLines(false);
    chart.invalidate();

Upvotes: 3

Views: 8258

Answers (3)

Janardhan Y
Janardhan Y

Reputation: 257

I had got by adding following line

leftAxis.setDrawAxisLine(false);

Upvotes: 9

suku
suku

Reputation: 10937

If the X Axis line is to be removed then use chart.getXAxis().setDrawAxisLine(false);

Upvotes: 1

Madhur
Madhur

Reputation: 3353

Add this following code,

 YAxis leftAxis = lineChart.getAxisLeft();
                leftAxis.setEnabled(false);

You can enable or disable gridline by,

lineChart.setDrawGridBackground(true);

XAxis xAxis = lineChart.getXAxis();
xAxis.setDrawGridLines(true);
xAxis.setDrawAxisLine(true);

UPDATE

    chart.setGridBackgroundColor(128);
    chart.setBorderColor(255);
    chart.getAxisRight().setEnabled(false);
    YAxis leftAxis = chart.getAxisLeft();
    leftAxis.setEnabled(false);
    chart.setDrawGridBackground(true);
    chart.getAxisRight().setDrawLabels(false);
    chart.getAxisLeft().setDrawLabels(false);
    chart.getLegend().setEnabled(false);
    chart.setPinchZoom(false);
    chart.setDescription("");
    chart.setTouchEnabled(false);
    chart.setDoubleTapToZoomEnabled(false);
    chart.getXAxis().setEnabled(true);
    chart.setDrawGridBackground(true);//enable this too
    chart.getXAxis().setPosition(XAxis.XAxisPosition.BOTTOM);
    chart.getXAxis().setDrawGridLines(true);//enable for grid line
    chart.getYAxis().setDrawGridLines(false);//disable vertical line
    chart.invalidate();

Upvotes: 13

Related Questions