我需要在Excel中导出PieChart。到目前为止,出口工作正常,但图表的某些颜色是相同的。 无法弄清楚问题。
以下是代码:
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);
}
结果如下: