Force the colour of a grouping in a stacked bar chart
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 chart开发者_开发百科s using the same parameters and data source, but on different filters.
Because the repartition of the groupings is not perfect depending on the filter, I get different colors associated for the same grouping in two different charts.
e.g.:
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 have any idea how to fix this?
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!
精彩评论