简体   繁体   English

如何在Jfree PieChart中设置自定义工具提示标签?

[英]How to set the custom tooltip label in Jfree PieChart?

In my JfreeChart , the label formats are {0}, {1}, {2} . 在我的JfreeChart ,标签格式为{0}, {1}, {2}

Here {0} represents the pie section key, {1} represents the section value and {2} represents the percentage. 这里的{0}代表饼图分区关键字, {1}代表分区值, {2}代表百分比。

I am setting the label in piechart by using the following code 我通过使用以下代码在饼图中设置标签

plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));

Lets assume chart has 2 sections. 让我们假设图表有2个部分。 the value({1}) of the 1st section is 200 and second section is 150. My requirement is like this one: 第一部分的value({1})是200,第二部分的值是150。我的要求是这样的:

plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}" * 3));

Can any one please tell how to modify this value? 谁能告诉我如何修改此值?

Instead of modifying the value in the tooltip to be three times larger. 而不是将工具提示中的值修改为三倍大。 Update the value in the actual chart and use {1} by itself in the generator. 更新实际图表中的值,并在生成器中单独使用{1}。

If you really want to just update the label you will have to create your own PieSectionLabelGenerator that formats the results exactly as you need them. 如果您真的只想更新标签,则必须创建自己的PieSectionLabelGenerator ,以完全根据需要设置结果的格式。

If you need a new format look at the API as StandardPieSectionLabelGenerator has constructors that take in multiple formats. 如果您需要新格式,请查看API,因为StandardPieSectionLabelGenerator具有采用多种格式的构造函数。 ( http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/StandardPieSectionLabelGenerator.html ) http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/StandardPieSectionLabelGenerator.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM