gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:01:44 34 4
gpt4 key购买 nike

在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);

enter image description here

最佳答案

尝试将颜色重音或主色的十六进制代码更改为 color.xml 中所需的颜色。

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

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com