views:

77

answers:

1

Hello, I'm currently stuck with BIRT as you might expect.

As indicated in the title, I'm looking for a way to force BIRT to associate a specific colour to a grouping in a stacked bar chart.

I need this behaviour because I'm generating several charts using the same parameters and data source, but on different filters.

Because the repartition of the groupings is not perfect depending filter, I get different colors associated for the same grouping in two different charts.

eg:

In chart 1, I get [A,B,C] groupings with blue for A, red for B and orange for C. Because in chart 2 I get only [A, C] groupings, I have blue for A, and red for C.

This behaviour breaks the coherence if both charts are in the same page...

Does anyone has an idea on how to fix this?

Thanks,

Vincent

A: 

I have a post on the DevShare over at BIRT Exchange that does just this:

http://www.birt-exchange.org/org/devshare/designing-birt-reports/1231-custom-chart-colors-based-on-data-set-values/

The chart scripting uses values in the Data Set to dynamically set the color on the chart. Here is the key bit from the "beforeDrawDataPoint" event on the chart:

var Condition = dph.getBaseDisplayValue();
if(Condition.contains("Critical")) { fill.set(255, 0, 0);} // Set to RED
else if(Condition.contains("High")){ fill.set(255, 255, 0); } // Set to Yellow
...

Good Luck!

MystikSpiral
Well, thanks for your answer but it only refers on the pile itself. Actually your code only works for the entire stack. My problem here is on the coloration of the groupings contained by the stack.
Vincent
You can get to whatever filter criteria you need through the dph value, including your groupings. Using the strategy in the referenced sample I have done exactly what you describe in your question. Did you give the sample a try?
MystikSpiral
Actually I got myself the answer, thanks to you :) The trick lies in : var Condition = dph.getSeriesDisplayValue(); and everything works. Thanks!
Vincent
Actually you must also set the Y-value as well as the Y-grouping with the same column in order to get this result.
Vincent