Change Bar Color based on Value
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:
The code on the chart is on the onRender event and looks like this:
Note you can also get the label value.
<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.
0
Categories
- All Categories
- 107 Developer Announcements
- 53 Articles
- 104 General Questions
- 141 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 76 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 118 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management