Android : MPAndroid图表如何删除左侧线
Android : MPAndroidChart how to remove left side line
对于折线图,我使用的是 mp android 图表,我想删除图表左侧的线,而不是网格线。
代码:-
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();
添加以下代码,
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.setEnabled(false);
您可以通过
启用或禁用网格线
lineChart.setDrawGridBackground(true);
XAxis xAxis = lineChart.getXAxis();
xAxis.setDrawGridLines(true);
xAxis.setDrawAxisLine(true);
更新
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();
我通过添加以下行得到了
leftAxis.setDrawAxisLine(false);
如果要删除 X 轴线,则使用
chart.getXAxis().setDrawAxisLine(false);
对于折线图,我使用的是 mp android 图表,我想删除图表左侧的线,而不是网格线。
代码:-
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();
添加以下代码,
YAxis leftAxis = lineChart.getAxisLeft();
leftAxis.setEnabled(false);
您可以通过
启用或禁用网格线lineChart.setDrawGridBackground(true);
XAxis xAxis = lineChart.getXAxis();
xAxis.setDrawGridLines(true);
xAxis.setDrawAxisLine(true);
更新
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();
我通过添加以下行得到了
leftAxis.setDrawAxisLine(false);
如果要删除 X 轴线,则使用
chart.getXAxis().setDrawAxisLine(false);