81,092
社区成员
发帖
与我相关
我的任务
分享
JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, false, false);
chart.setBackgroundPaint(Color.WHITE);
chart.setTitle(new TextTitle(title,new Font("宋体", Font.BOLD, 14)));
LegendTitle legend = chart.getLegend(0);
legend.setItemFont(new Font("宋体",Font.BOLD,10));//修改图例的字体
legend.setPosition(RectangleEdge.TOP);//设置图例的位置
// legend.setLegendItemGraphicPadding(RectangleInsets.ZERO_INSETS);
PiePlot plot = (PiePlot)chart.getPlot();
plot.setLabelFont(new Font("宋体",Font.BOLD,10));//设置饼图各部分标签字体
plot.setNoDataMessage("没有数据");
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1},{2}"));
plot.setToolTipGenerator(new StandardPieToolTipGenerator());
plot.setLabelBackgroundPaint(new Color(220, 220, 220));
plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}"));
plot.setSimpleLabels(true);
plot.setInteriorGap(0.0D);
plot.setBackgroundAlpha(0.9f);
name = ServletUtilities.saveChartAsPNG(chart,280, 280,null, null);