在使用饼图的MpAndroidChart中,可以成功绘制饼图。尝试向图表的图例添加自定义标签和颜色时,标签会更新,但所有图例的颜色都为蓝色。

   ArrayList<String> PieEntryLabels = new ArrayList<>();
    PieEntryLabels.add("January");
    PieEntryLabels.add("February");
    PieEntryLabels.add("March");
    PieEntryLabels.add("April");

    List<LegendEntry> legendEntries = new ArrayList<>();

    int[] colorList = new int[] { R.color.graphcolor1, R.color.graphcolor2,R.color.graphcolor3,R.color.graphcolor4};
    pieDataSet.setColors(colorList, context);
    for (int i = 0; i < PieEntryLabels.size(); i++) {
        LegendEntry entry = new LegendEntry();
        entry.formColor =colorList[i];
        entry.label = PieEntryLabels.get(i);
        legendEntries.add(entry);
    }

    pieChart.getLegend().setCustom(legendEntries);


java - 饼图图例颜色未更新mpandroidchart-LMLPHP

最佳答案

尝试在colors.xml中将颜色强调或原色的十六进制代码更改为所需的颜色。

关于java - 饼图图例颜色未更新mpandroidchart,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60616675/

10-12 02:41