Reputation: 350
I am using iReport and JasperReports, both in v4.7.
I want to show the percentage of each slice in the label. Something like "Option 1 (45.67%)".
After reading many sites I came to the following snippet.
<piePlot labelFormat="{0} ({2})" legendLabelFormat="{0} ({2})">
<plot/>
<itemLabel/>
</piePlot>
According to the documentation of iReport.
However, when I run the report on iReport or JasperReports I get only the percentage in the legend area (legendLabelFormat) not in label (labelFormat) of each slice and, also, the percentage is show as an integer not as a float.
Somebody knows how to show the percentage in the label and -if possible- with decimal values?
Upvotes: 3
Views: 7108
Reputation: 61
Found the solution here. Remove your lableExpression from the pieDataset, it overwrites your piePlot lables.
<pieDataset>
<keyExpression><![CDATA[$F{GENERATION}]]></keyExpression>
<valueExpression><![CDATA[$F{SUBTOTAL}]]></valueExpression>
</pieDataset>
<piePlot isShowLabels="false" isCircular="true" labelFormat="({2})" legendLabelFormat="{0}">
<plot/>
<itemLabel/>
</piePlot>
Upvotes: 6