Davis
Davis

Reputation: 1

How to set the custom tooltip label in Jfree PieChart?

In my JfreeChart, the label formats are {0}, {1}, {2}.

Here {0} represents the pie section key, {1} represents the section value and {2} represents the percentage.

I am setting the label in piechart by using the following code

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

Lets assume chart has 2 sections. the value({1}) of the 1st section is 200 and second section is 150. My requirement is like this one:

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

Can any one please tell how to modify this value?

Upvotes: 0

Views: 1579

Answers (1)

jzd
jzd

Reputation: 23629

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.

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.

If you need a new format look at the API as StandardPieSectionLabelGenerator has constructors that take in multiple formats. (http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/StandardPieSectionLabelGenerator.html)

Upvotes: 1

Related Questions