MPAndroidChart - How to change the color of PieChart center Background?

三世轮回 提交于 2021-01-27 07:09:47

问题


Im trying to use the MPAndroidChart library to develop a circular chart. But only Pie chart is available. So i tried giving two xvalue coordinates, with one color similar to background. So i got something similar to circular chart. But i'm not able to change the background color and font color of center text inside the pie chart?

Thanks!


回答1:


There are two possible solutions:

Retrieve the Paint object used by the chart to draw the "center-hole" and modify it the way you want

Paint p1 = mChart.getPaint(Chart.PAINT_HOLE);
p1.setColor(...);

Paint p2 = mChart.getPaint(Chart.PAINT_CENTER_TEXT);
p2.setColor(...);

Or use this, if you only display one value anyway: CircleDisplay




回答2:


To set center color:

mChart.setDrawHoleEnabled(true);
mChart.setHoleColor(...);

To set center text

mChart.setDrawCenterText(true);
mChart.setCenterText(...);


来源:https://stackoverflow.com/questions/25927977/mpandroidchart-how-to-change-the-color-of-piechart-center-background

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