Browndog Posted January 18, 2009 Share Posted January 18, 2009 Hi,I'm trying to change the color of a crosstab cell based on the cell content i.e. if the cell content is 1 I want the cell to be red, 2 blue, 3 green etc... Anyone got any ideas on how to do this? Greg Link to comment Share on other sites More sharing options...
Browndog Posted January 21, 2009 Author Share Posted January 21, 2009 I've got an idea on how to do this but I cant make it work. I now what it so when the leaveCode = A/L the cell is green and S/L the cell is yellow In the <crosstabCell> I want the color to change I add a <rectangle> and I use the <printWhenExpression> tag and different colored. The problem I get is "Field not found : leaveCode" it seems the leaveCode field is not avaliable within the crosstab cell, is there a way around this? Code:<crosstabCell width="50" height="25"> <cellContents> <box> <pen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> </box> <rectangle> <reportElement mode="Opaque" x="0" y="0" width="50" height="25" backcolor="#FF0000"> <printWhenExpression><![CDATA[new Boolean( $F{leaveCode}.equals("A/L")]]></printWhenExpression> </reportElement> </rectangle> <rectangle> <reportElement mode="Opaque" x="0" y="0" width="50" height="25" backcolor="#00FF00"> <printWhenExpression><![CDATA[new Boolean( $F{leaveCode}.equals("S/L") )]]></printWhenExpression> </reportElement> </rectangle> <textField hyperlinkType="None"> <reportElement style="Crosstab Data Text" x="0" y="0" width="50" height="25"/> <textElement/> <textFieldExpression class="java.lang.Double"><![CDATA[$V{hoursMeasure}]]></textFieldExpression> </textField> </cellContents> </crosstabCell> Link to comment Share on other sites More sharing options...
Teodor Danciu Posted January 21, 2009 Share Posted January 21, 2009 Hi, I think you need to understand how crosstabs work. In general, crosstabs display aggregated values that we call measures. These measures are variables that aggregate data coming from individual field values.In a crosstab you can only display measure values, not field values. Inside a crosstab, field values are irrelevant.Within a crosstab cell level expression, field references are not even available because they do not make any sense.Just like in a cell crosstab you can only display measure values, you can only used measure values in the printWhenExpression.I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Browndog Posted January 30, 2009 Author Share Posted January 30, 2009 Yes thanks I understand now and I've found a way to get the desired result.Post Edited by Greg Brown at 01/30/09 04:11 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now