我试图用jasper报告制作饼图...我已经为图表编写了自定义程序类......任何人都可以给我一些关于如何使项目标签颜色与系列颜色相同的建议?
PiePlot piePlot = (PiePlot)chart.getPlot();
PieDataset pieDataset = piePlot.getDataset();
piePlot.setOutlineVisible(false);
chart.setBackgroundPaint(Color.white);
piePlot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 7)); piePlot.setShadowPaint(null);
piePlot.setLabelOutlinePaint(null);
piePlot.setLabelShadowPaint(null);
piePlot.setLabelBackgroundPaint(null);
piePlot.setSectionOutlinesVisible(false);
我添加图片...在图片中," 0.07%,6.18%,93.74%"有黑色......我们可以用系列颜色改变颜色吗?所以" 93.74%"有棕色," 6.18%"有洋红色...
由于
答案 0 :(得分:1)
最后我找到了基于@PetterFriberg建议的解决方案......
在PiePlot
方法drawLeftLabels
和drawRigtLabels
更改
TextBlock block = TextUtilities.createTextBlock(label,
this.labelFont, this.labelPaint, maxLabelWidth,
new G2TextMeasurer(g2));
到
TextBlock block = TextUtilities.createTextBlock(label,
this.labelFont, lookupSectionPaint(leftKeys.getKey(i)), maxLabelWidth,
new G2TextMeasurer(g2));
<强>结果强>