MPAndroidChart PieChart为什么只有在点击了饼图之后才会显示颜色?

设置数据的代码如下。如果一个数据占了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 colors

        ArrayList<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 highlights
        mChart.highlightValues(null);

        mChart.invalidate();
    }
阅读 4.6k
2 个回答

好像这是PieChartBug。详情请看这里 点我

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题