饼图碧玉中项目标签的不同颜色
Different color for item label in pie chart jasper
我尝试用 jasper 报告制作饼图...我已经为图表编写了定制程序 class...任何人都可以给我建议如何使项目标签颜色与系列颜色相同?
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%”是洋红色...
谢谢
最后我根据@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));
结果
我尝试用 jasper 报告制作饼图...我已经为图表编写了定制程序 class...任何人都可以给我建议如何使项目标签颜色与系列颜色相同?
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%”是洋红色...
谢谢
最后我根据@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));
结果