I have a Title band with a Text Field containing a calculated Variable $V{avg_perc}
. The Text Field has the evaluationTime set to Report, same for the Variables resetType.
Now I'm trying to set the background color of this field with a Conditional Style but I keep getting an error message saying something like:
Invalid expression: !Double.isNaN($V{avg_perc}) && $V{avg_perc} >= 0.8
I'm doing exactly the same thing with the same Conditional Style in the Column Footer and it works without any problems, even if I set the evaluationTime for this field to Report too.
After removing !Double.isNaN($V{avg_perc})
I don't get an error anymore but the expression still doesn't work. My field stays red which is the basic color when none of the conditions is valid, no matter which value $V{avg_perc}
has. It still works in the Column Footer, though. This is my style:
<style name="avg_color" mode="Opaque" backcolor="#FF0000" pdfFontName="Helvetica-Bold">
<conditionalStyle>
<conditionExpression><![CDATA[$V{avg_perc} >= 0.8]]></conditionExpression>
<style backcolor="#008000"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$V{avg_perc} >= 0.6 && $V{avg_perc} < 0.8]]></conditionExpression>
<style backcolor="#FFCC00"/>
</conditionalStyle>
</style>
Used Fields and Variables for this:
<field name="perc" class="java.lang.Double"/>
<variable name="avg_perc" class="java.lang.Double" calculation="Average">
<variableExpression><![CDATA[$F{perc}]]></variableExpression>
</variable>
Any idea how to get this thing to work? I'm using JasperReports and iReport in version 3.7.4.