MPAndroidChart hide background grid

自古美人都是妖i 提交于 2019-12-06 16:35:07

问题


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?

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?


回答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)




回答2:


Simply below three lines remove horizontal and vertical lines in the bar chart.

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




回答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)




回答4:


Hide Background grid

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


来源:https://stackoverflow.com/questions/31263097/mpandroidchart-hide-background-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!