【发布时间】:2014-11-19 04:21:48
【问题描述】:
我正在使用 jFreeChart 并绘制带有图例的饼图。 饼图的半径因图例而异,所以我想固定饼图的大小(绘图区域)
RingPlot plot = new RingPlot(dataset);
StringBuffer chartFileName = new StringBuffer(Integer.toString(generatedCharts)).append(Long.toString(System.currentTimeMillis())).append(".png");
JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));
TextTitle t = chart.getTitle();
t.setHorizontalAlignment(org.jfree.ui.HorizontalAlignment.LEFT);
t.setPaint(new Color(240, 240, 240));
t.setFont(new Font("Arial", Font.BOLD, 26));
plot.setBackgroundPaint(null);
plot.setOutlineVisible(false);
plot.setLabelGenerator(null);
plot.setSectionDepth(0.35);
plot.setSectionOutlinesVisible(false);
plot.setSimpleLabels(true);
plot.setShadowPaint(null);
plot.setOuterSeparatorExtension(0);
plot.setInnerSeparatorExtension(0);
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}",new DecimalFormat("#,##0"), new DecimalFormat("0.000%")));
plot.setLabelBackgroundPaint(null);
plot.setLabelOutlinePaint(null);
Font font=new Font("",0,16);
plot.setLabelFont(font);
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setPosition(RectangleEdge.BOTTOM);
chart.setBackgroundPaint(java.awt.Color.white);
chart.setPadding(new RectangleInsets(4, 8, 2, 2));
【问题讨论】:
-
开SO账户的时候,你有没有费心看一下规则。如果没有与您的问题相关的代码,那么任何人都应该如何帮助您。另外,您是否费心查看JFreeChart Forums 的答案?他们在那里也回答了很多这样的问题。
-
更好地解释您的问题。 “我想修复饼图(绘图区域)的大小”是什么意思?这到底是什么意思?
-
另外,
dataset和generatedCharts定义不正确。添加完整代码。
标签: java jfreechart