Hi all,
I have a customization to be done in the legends being generated (below the chart) for the Pie charts. I want only the name of the category to be displayed and not the name = value pattern as it currently exists.
If I try new StandardPieSectionLabelGenerator("{1}), it only changes for the labels being displayed next to the pie sections.
Please help me.
Thanks in advance.
Regards,
Piyush
Pie chart Legend format change
Hi All,
I found out how to do that. It can be done using.
Now I'm facing another problem. If the legend name of any section is too long, then I want to crop it off after some size. Say if my legend name is No of Users in Category X, then I would like to display only the first 10 characters of the above label, followed by trailing spaces. How do I go about it.
Any suggestion / help is highly appreciated.
Thanks in advance,
Regards,
Piyush
I found out how to do that. It can be done using
Code: Select all
pieplot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
Now I'm facing another problem. If the legend name of any section is too long, then I want to crop it off after some size. Say if my legend name is No of Users in Category X, then I would like to display only the first 10 characters of the above label, followed by trailing spaces. How do I go about it.
Any suggestion / help is highly appreciated.
Thanks in advance,
Regards,
Piyush
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
For that, you'll need to create your own PieSectionLabelGenerator class (you could start with StandardPieSectionLabelGenerator and modify it as necessary).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
I guess the fixedLegendItems attribute could be moved up into the Plot class...anyone else have any thoughts about that?
What do you display in the legend for the PiePlot? Generally, I hide the legend in this case, because you can easily label the pie sections right on the plot and so the legend is redundant.
What do you display in the legend for the PiePlot? Generally, I hide the legend in this case, because you can easily label the pie sections right on the plot and so the legend is redundant.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

