问题描述
设置数据的代码如下。如果一个数据占了100时,饼图就会不显示颜色。只有点击一下饼图才会显示颜色,请问这是怎么回事儿呢?
private void setData(int count, float range) {float mult = range;ArrayList<PieEntry> entries = new ArrayList<PieEntry>();// NOTE: The order of the entries when being added to the entries array determines their position around the center of// the chart.entries.add(new PieEntry(1, '本关未掌握'));entries.add(new PieEntry(0, '本关已掌握'));PieDataSet dataSet = new PieDataSet(entries, '');dataSet.setSliceSpace(3f);dataSet.setSelectionShift(5f);// add a lot of colorsArrayList<Integer> colors = new ArrayList<Integer>();colors.add(Color.rgb(0x00,0x96,0x88));colors.add(Color.rgb(0xE8,0xEA,0xF6));dataSet.setColors(colors);PieData data = new PieData(dataSet);data.setValueFormatter(new PercentFormatter());data.setValueTextSize(13f);data.setValueTextColor(Color.WHITE);mChart.setData(data);// undo all highlightsmChart.highlightValues(null);mChart.invalidate(); }
问题解答
回答1:好像这是PieChart的Bug。详情请看这里 点我
回答2:可以参考博客 http://blog.csdn.net/github_3... 里面的MPchart详解