I have created a pie chart in JFreeChart. However, numerical values are not appearing on the “slices”. How do I make it appear there?
I have created a pie chart in JFreeChart. However, numerical values are not appearing
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
On a
PiePlotthis is possible using a settersetSimpleLabels.Assuming you have your created chart:
If you need an even more plain look you can use a transparent color for the label shadow, outline and background paint:
Edit: To display values instead of legends in the slices:
The
StandardPieSectionLabelGeneratoralso has a number formatter if you need one of these.That should do it for a pie chart.
As for a bar chart you can set the label positions on the
BarRendererusing thesetPositiveItemLabelPositionFallback(ItemLabelPosition position)method. For inside labels you could use:Be sure the font size can fit inside the bar when you try this.