Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display values within pie chart sector

I am using JFreeChart to create pie charts. Values are displayed outside pie chart sectors as labels. I want to display the values within the pie sectors. How can I achieve this. Please can any one help me?

like image 816
Vijayalakshmi Avatar asked Sep 05 '11 04:09

Vijayalakshmi


People also ask

How do you show a value in a pie chart?

To display percentage values as labels on a pie chart On the design surface, right-click on the pie and select Show Data Labels. The data labels should appear within each slice on the pie chart.

How do you organize data for a pie chart?

Select specific cells, columns, or rows for your data. For example, if your data has multiple columns but you want a pie chart, select the column containing your labels, and just one column of data. Switch the rows and columns in the chart after you create it.


2 Answers

Use setSimpleLabels(), as shown below; org.jfree.chart.demo.PieChartDemo1 is a good starting point.

PiePlot plot = (PiePlot) chart.getPlot();
plot.setSimpleLabels(true);
like image 188
trashgod Avatar answered Sep 18 '22 02:09

trashgod


If you are using createPieChart3D to create Pie chart, following URL will be helpful to you.
http://www.java2s.com/Code/Java/Chart/JFreeChartPieChart3DDemo1.htm
What I know is, showing values inside is default feature of the chart. If you're unable to do so it seems that you have changed the default way.

like image 24
Naved Avatar answered Sep 22 '22 02:09

Naved