2016-01-28 36 views
2

折線圖我正在使用mp android圖表我想刪除左側的圖線而不是網格線。Android:MPAndroidChart如何刪除左側線

代碼: -

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(); 

回答

10

添加這下面的代碼,

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

您可以啓用或禁用通過網格線,

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(); 
+0

這個網格將不可見 –

+0

退房答案 – Madhur

+0

仍然沒有工作。我更新了我的代碼。 –

6

我曾通過加入這一行

leftAxis.setDrawAxisLine(假)得到;

+0

謝謝。它爲我工作。 – susemi99

1

如果X軸線路被刪除,然後使用 chart.getXAxis().setDrawAxisLine(false);

相關問題