首先,先按常规把pieChart显示出来
pieChart.setBackgroundColor(Color.WHITE);
pieChart.setExtraOffsets(0,20,0,20);
//创建数据
List<PieEntry> entryList = new ArrayList<>();
entryList.add(new PieEntry(300,"教育"));
entryList.add(new PieEntry(900,"饮食"));
entryList.add(new PieEntry(700,"日常"));
entryList.add(new PieEntry(500,"还款"));
entryList.add(new PieEntry(400,"衣物"));
entryList.add(new PieEntry(1000,"数码"));
PieDataSet pieDataSet = new PieDataSet(entryList,"上月各类支出占比");
//设置颜色
List<Integer> colors = new ArrayList<>();
int[] MATERIAL_COLORS = {
Color.rgb(200, 172, 255)
};
for (int c : MATERIAL_COLORS) {
colors.add(c);
}
for (int c : ColorTemplate.VORDIPLOM_COLORS) {
colors.add(c);
}
pieDataSet.setColors(colors);
//展示
PieData pieData = new PieData(pieDataSet);
pieChart.setData(pieData);