Changing background color of birt report according to groups

birtscripting

enter image description here

I am generating a BIRT report as shown by image embedded, I am grouping by custmeer such as ACM , AFL etc …

As you can see I use background alternative color as blue and white, to achieve this I simply use the highlight tab of detail row as(row["__rownum"] % 2 Equal to 0).

now , if I move into more complexity such as different color combination for different groups e.g for group(customer in this case) yellow-white, for group2 red-white etc….

I am using this.getStyle().backgroundColor ='color', but the problem lies into selecting the individual groups, may be some sort of in condition would do the trick, but I am lost

Best Answer

The simplest way to set a row's background colour in BIRT is by adding conditions to the list in the Highlight tab within the Property Editor for the row. It looks as though you have already done this to set alternative lines to blue - by adding extra conditions with additional colours, you can set the background accordingly. This method is most useful where only a small number of colours are required, since you have to set up a different condition for each colour.

Where a larger selection of colours is likely to be required, it would make more sense to do conditional formatting within an event script - you can find an example here.

EDIT: Adding a running group count in BIRT:

  • Add an aggregation item to your table - you can do this by dragging an aggregation item from the Quick Tools section of the Palette, for example.
  • In the Aggregation Builder dialog, set the Function to be COUNT, the expression to be 1 and the Aggregate On to be the group you want to count (eg. Customer)
  • Insert a second aggregation item with the Function set to be RUNNINGCOUNT, the expression to be 1/row[first aggregation name] and the Aggregate On to be Table.

The second aggregation item will be a running count of the groups in the report.

Related Topic