jfreechart如何设置背景色为白色

feiyu107 2011-08-11 11:44:07
请问如何设置背景色为白色啊,调用方法chart.setBackgroundPaint(Color.white); 不起作用。
还有当我设置plot.setSimpleLabels(true);的时候饼图上面的百分比会互相覆盖,请问怎么设置呢?
图片看这个地址!
http://www.iteye.com/problems/69837
...全文
466 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
softroad 2011-08-11
  • 打赏
  • 举报
回复
学习了。。。
dandan0912 2011-08-11
  • 打赏
  • 举报
回复
你用的是1.0.9吗 这个版本有bug 用1.0.1版本吧
feiyu107 2011-08-11
  • 打赏
  • 举报
回复
现在默认背景色是灰色,十分难看,下面是我的代码。

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);
dandan0912 2011-08-11
  • 打赏
  • 举报
回复
在网上搜下吧 我这现在没有那个版本的
feiyu107 2011-08-11
  • 打赏
  • 举报
回复
我用的是1.0.13官网最新的版本,你有1.0.1么,给我一份吧,qq22241294

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧