【发布时间】:2020-06-22 07:04:10
【问题描述】:
在MpAndroidChart中使用饼图.was成功地能够绘制饼图。当尝试将自定义标签和颜色添加到图表的图例时。标签正在更新,但所有图例的图例颜色都变为蓝色。
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);
【问题讨论】:
-
可以分享colors.xml文件吗?
标签: java android mpandroidchart