在我的JfreeChart
中,标签格式为{0}, {1}, {2}
。
在这里,{0}
表示饼图分区键,{1}
表示分区值,{2}
表示百分比。
我通过使用以下代码在饼图中设置标签
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));
让我们假设图表有2个部分。第一部分的
value({1})
是200,第二部分是150。我的要求是这样的:plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}" * 3));
谁能告诉我如何修改此值?
最佳答案
而不是将工具提示中的值修改为三倍大。更新实际图表中的值,并在生成器中单独使用{1}。
如果您真的只想更新标签,则必须创建自己的PieSectionLabelGenerator
,以完全根据需要设置结果的格式。
如果需要新格式,请查看API,因为StandardPieSectionLabelGenerator
具有采用多种格式的构造函数。 (http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/StandardPieSectionLabelGenerator.html)