饼图显示百分比

10 篇文章 0 订阅
6 篇文章 0 订阅

环境:JDK1.4.2

JFreeChart: jfreechart-1.0.6

看见有的人Blog里面要"饼图显示百分比"是用这个类

原来在1.0.0-rc1版中显示百分比已经调整到StandardPieItemLabelGenerator构造函数中了,StandardPieItemLabelGenerator有三个构造函数。StandardPieItemLabelGenerator()不显示各项所占比例。另外两个可以显示比例。代码如下:

plot.setLabelGenerator( new StandardPieItemLabelGenerator(StandardPieItemLabelGenerator.DEFAULT_TOOLTIP_FORMAT));
// 或者采用下面自定义样式显示,{0}表示选项,{1}表示数值,{2}表示所占比例
plot.setLegendLabelGenerator( new StandardPieItemLabelGenerator( " {0}: ({1}M, {2}) " ));

但是我用的是jfreechart-1.0.6这个版本,以上的StandardPieItemLabelGenerator,StandardPieItemLabelGenerator这2个类已经取消了换成了

 

StandardPieItemLabelGenerator ------->>>> StandardPieSectionLabelGenerator    ( 1.0 .6版本)

StandardPieItemLabelGenerator
------->>>> StandardPieToolTipGenerator     ( 1.0 .6版本)

我实现 “百分比”的方法如下:

 

// 设置百分比
plot.setLabelGenerator( new  StandardPieSectionLabelGenerator(StandardPieToolTipGenerator.DEFAULT_TOOLTIP_FORMAT));
plot.setLegendLabelGenerator(
new  StandardPieSectionLabelGenerator( " {0}=({1}M, {2}) " ));

具体的代码  请看我下面的文章 

JFreeChart+sql 生成饼图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值