This simple example will change the bar color to green if positive (or 0) value and red if negative. It uses a simple scripted data set so you should be able to run it as is.<br />
<br />
The design is using BIRT 4.2 but will work in almost any version.<br />
<br />
The code for the scripted data source is just used to populate dummy data and looks like this:
counter++;
if (counter == 1) {
row["Category"] = "Category A";
row["Value"] = 3;
return true;
}
else if (counter == 2) {
row["Category"] = "Category B";
row["Value"] = -1;
return true;
}
else if (counter == 3) {
row["Category"] = "Category C";
row["Value"] = 2;
return true;
}
else if (counter == 4) {
row["Category"] = "Category D";
row["Value"] = -2;
return true;
}
else {
return false;
}
<br />
The code on the chart is on the onRender event and looks like this:
function beforeDrawDataPoint( dph, fill, icsc )
{
var seriesName = dph.getSeriesDisplayValue();
if (seriesName == "Series 1") {
var val = dph.getOrthogonalValue();
var lab = dph.getBaseDisplayValue();
if (val < 0) {
// Set to Red
fill.set(255, 0, 0);
}
else {
// Set to Green
fill.set(0, 255, 0);
}
}
}
<br />
Note you can also get the label value.