Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Alternating Crosstab Column Colours for Dynamic Data
lotusman
<p>Hi,</p><p> </p><p>I have done some searching and found a number of responses on how to handle alternating colours for rows, but my client has requested that we alternate column colours in the crosstab dynamic data. Any ideas?</p><p> </p><p>Thanks in advance</p><p> </p>
Find more posts tagged with
Comments
kclark
<p>Take a look at <a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/forum/index.php?/topic/17993-crosstab-alternate-rows-coloring/page-2'>this
thread</a> that shows how to setup alternating row colors in a crosstab. You want to change the background color based on some data in the row, correct?</p>
lotusman
<p>Hi,</p><p> </p><p>As far as I can see, this is alternating row colours and not columns as I need.... Thanks for the link.</p><p> </p><p>Thanks</p>
lotusman
<p>Hi All,</p><p> </p><p>Wondering if anyone has any other samples I might be able to look at for doing columns instead of rows?</p><p> </p><p>Thanks</p>
kclark
<p>Sorry for the late reply. Try setting a PGV in the initialize of your report like this</p><pre class="_prettyXprint">reportContext.setPersistentGlobalVariables("background", "0");</pre><p>Then you could alternate the column colors doing something like this in the onCreate() of the crosstab</p><pre class="_prettyXprint">var color = reportContext.getPersistentGlobalVariable("background")if(color == "1") { this.getStyle().setBackgroundColor("#FF0000"); reportContext.setPersistentGlobalVariable("background", "0");}else{ reportContext.setPersistentGlobalVariable("background", "1")}</pre>
lotusman
<p>Thanks! With this and some other scripting I was able to get it to work. For other people's information - I had to come up with a way to reset the value when I started a new row - the code alone worked fine if you had an even number of columns, but gave a checkerboard pattern when you had and odd number. </p><p> </p><p>What I did was setup a highlight in the first column of the row to change and global variable each time the row changed. Then I read that in the onCreateCell field and compared it to a previous variable and when they differed, reset the color logic and started over. </p>
kclark
<p>Thanks for the update, this would make a good devshare if you've got a sample report.</p>