我需要在 Excel 中导出饼图。到目前为止,导出工作正常,但图表的某些颜色是相同的。无法弄清楚问题所在。
这是代码:
Color[] c = this.createRainbow(100);
int n = chart.getDataPointCount(0); //number of Pies
ArrayList<Integer> compare = new ArrayList<Integer>();
for (int j = 0; j < n && !ValueWatcherServer.canceled_id.contains(connectionid); j++) {
int rePos = (int)(((double)j / (double)n * (double)c.length));
ChartFormat format = chart.getDataPointFormat(0, j);
format.setSolid();
if(!compare.contains(rePos)){
compare.add(rePos);
format.setForeColor(c[rePos].getRGB());
}
else{
format.setForeColor(3);
}
chart.setDataPointFormat(0, j, format);
}
结果是这样的: