I am using Jaspersoft Studio and JasperReports Server, both in v.5.6.0.
I want to create a Pie Chart that shows the percentage of Errors colored in red.
Example:
$V{til_1} = total
$V{state_1} = errors
total:2 - errors:1 => should result in a Pie Chart with 2 Slices -> 50% Red and 50% Green.
I used 2 Series, one Serie (Keyexpression) "green" (value 100.0), one Serie (Keyexpression) "red" (value: $V{state_1}>1?0:new Float(($V{state_1}*100)/$V{til_1}) ).
<pieChart>
<chart isShowLegend="false">
<reportElement x="293" y="0" width="30" height="30" uuid="8369e35a-d6d6-4e0d-aa6e-fef7a118ecce"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<pieSeries>
<keyExpression><![CDATA["green"]]></keyExpression>
<valueExpression><![CDATA[100.0]]></valueExpression>
<labelExpression><![CDATA[null]]></labelExpression>
</pieSeries>
<pieSeries>
<keyExpression><![CDATA["red"]]></keyExpression>
<valueExpression><![CDATA[$V{state_1}>1?0:new Float(($V{state_1}*100)/$V{til_1})]]></valueExpression>
<labelExpression><![CDATA[null]]></labelExpression>
</pieSeries>
</pieDataset>
<piePlot isShowLabels="false">
<plot>
<seriesColor seriesOrder="0" color="#99FF99"/>
<seriesColor seriesOrder="1" color="#CC0000"/>
</plot>
<itemLabel/>
</piePlot>
</pieChart>
Actual result (including the Problem):
However, when I run the report the calculation for "red" seams to be correct, the Chart output-image does not - link to image attached below.
(50%red instead of 100% and 33,3%red instead of 50%)
Image:
Somebody knows where my mistake/how to get the right percentage in Pie Chart and -if possible- a short explanation why does jasper draw wrong chart-slices? Because of the two Series?