Custom chart colors based on data set values
Options
This report features two pie charts. The first uses the standard colors to render the pie chart. The second chart (on the right) leverages two scripts to check the category value and set the color to a specific RGB value. Specifically we are going to override the "beforeDrawDataPoint" and the "beforeDrawLegendItem" functions (code below).<br />
<br />
The colors applied are intentionally simple, primary colors that contrast to show the differences from the standard palette. There are four conditions in the sample data set and these conditions (Critical, High, Medium and Low) are used to determine the correct color for that marker.<br />
<br />
Code:
The report design and data required to see the report in action are attached. The only modification you may need to run the report is to update the path assigned to the Flat File Data Source.<br />
<br />
Good Luck!
<br />
The colors applied are intentionally simple, primary colors that contrast to show the differences from the standard palette. There are four conditions in the sample data set and these conditions (Critical, High, Medium and Low) are used to determine the correct color for that marker.<br />
<br />
Code:
Chart Replacement Code (repeat if clause for each screened condition): 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 ... Legend Replacement Code (repeat if clause for each screened value): var Condition = lerh.getLabel().getCaption().getValue(); if(Condition.contains("Critical")) { lerh.getFill().set(255, 0, 0);} // Set to Red else if(Condition.contains("High")){ lerh.getFill().set(255, 255, 0);} // Set to Yellow ...<br />
The report design and data required to see the report in action are attached. The only modification you may need to run the report is to update the path assigned to the Flat File Data Source.<br />
<br />
Good Luck!
Warning
No formatter is installed for the format ipb
0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 122 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management