问题
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