Custom colors on Pentaho Analyzer conditions

Almost everybody knows: using Pentaho Analyzer and also the old famous JPivot OLAP players, it’s possible to add conditional formatting to the measure fields.

This functionality is very useful when, for example, we have some KPIs and want to color it according to its performance, as in the following example:

Screen Shot 2013-08-16 at 1.20.09 PM

In this picture, the customer wants to color with red, the Territory that shows Sales < 1000000, and to achieve that, we can enter the following MDX Expression in the Column Formatting:

Case
    When [Measures].[Sales] < 1000000
    Then '|#,##0|style=red'
    Else '|#,##0|'
End

 

However, if our customer wanted us to color the other cells with blue or other color contained in those 50 shades of something, we’d be in trouble.

…not actually!

Analyzer does something wise, while rendering these styles we deliver to the cells.

It renders in these formatted cells, within their <td> tag, the property class="cell-style-red",when it attends to the style=red condition.

This means we can do a lot of cool stuff. Everything that CSS enables us to do. Or only adding some colors that Analyzer doesn’t give us out-of-the-box for these conditions.

But where to add these styles?

The CSS class .cell-style-red is already included in the file:
/biserver-ee/pentaho-solutions/system/analyzer/styles/themes/onyx/anaOnyx.css
The next step is to append our custom styles to this file and voilà.

This custom code:

.cell-style-blue{
    background-image:url(http://www.veryicon.com/icon/png/System/Networking/Emoticon%20inlove.png);
    background-position:left;
    background-size:contain;
    background-repeat:no-repeat;
    color:#0000cc;
}

…added to the css file, produces this result:

Screen Shot 2013-08-16 at 1.35.20 PM

…if our MDX formula is something like this:

Case
    When [Measures].[Sales] > 1000000
    Then '|#,##0|style=blue'
    Else '|#,##0|style=red'
End

Okay, you wouldn’t want to add smileys and crazy colors to your report.

Just a

.cell-style-blue{
    background-color:#0000CC;
}

 

…would fit for you. :)

Marcello Pontes
Analytics Architect & Front-ender at Oncase |