views:

516

answers:

1

Hi all,

I'm new to Jasper Reports. I'm designing report using iReports. My requirement is I have two values(Fields) x,y to compare. if x < y then the data color for y should be changed to 'black' & if greater then data color of y should be changed to 'red'.

please advice me as to how to proceed on this & where to validate.This requriement is for a swing window application.

Thanks in advance

Regards, Chandu

A: 

There's a discussion at the JasperForge forums on the topic, this is probably the most relevant part:

First drag and drop the field that you want to have dyanamic color twice. Change background color for first field to Yellow and the second field to Red. Now right click Yellow field, click Properties, select Common tab and write this code in the 'Print when expression' box: (make sure to replace myconditionalfield with your actual field name) $F{MyConditinalField}.intValue()>= 5 && $F{MyConditinalField}.intValue()<10?Boolean.TRUE:Boolean.FALSE //if >=5 and <10 then show Yellow field //Code for Red field at the same place just like above $F{MyConditinalField}.intValue()>= 10?Boolean.TRUE:Boolean.FALSE Hope this helps.

It's not exactly what you need, but might likely be close enough to push you in the right direction.

Tomislav Nakic-Alfirevic
Thanks Tomislav, Your explanation helped me a lot to achieve my requirement.Regards,chandu
Chandu