Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Set colors for barchart globally
Set colors for barchart globally [message #1705855] Wed, 19 August 2015 13:33 Go to next message
Joseph Lantis is currently offline Joseph LantisFriend
Messages: 1
Registered: August 2015
Junior Member
Hello,

I have been using an onRender function to set the colors for the bars and legend in a chart. I have some reports that contain a large number of charts. I want to know if there is a way to set the colors in one location and reference that in each chart or if I need to continue to update the script in each chart's onRender script in the report individually.

Thanks,

Example function:
function beforeDrawDataPoint( dph, fill, icsc ) {

var ConditionX = dph.getSeriesDisplayValue();

if(ConditionX.contains("Expo Invitation")) { fill.set(255, 255, 0); }
elseif(ConditionX.contains("Other")) { fill.set(211, 211, 211); }
else if(ConditionX.equals("Survey")) { fill.set(50, 205, 50); }
else if(ConditionX.contains("No Survey")) { fill.set(255, 165, 0); }

}

function beforeDrawLegendItem( lerh, bounds, icsc ){

var Condition = lerh.getLabel().getCaption().getValue();

if(Condition.contains("Expo Invitation")) {lerh.getFill().set(255, 255, 0); }
else if(Condition.contains("Other")) {lerh.getFill().set(211, 211, 211); }
else if(Condition.equals("Survey")) {lerh.getFill().set(50, 205, 50); }
else if(Condition.contains("No Survey")) {lerh.getFill().set(255, 165, 0); }

}
Re: Set colors for barchart globally [message #1706026 is a reply to message #1705855] Fri, 21 August 2015 08:12 Go to previous message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Hi,

I think this would be a typical case requiring a java event handler. It's a little bit trickier to setup than javascript handlers, but very helpful if you have many charts sharing the same rules.

Alternatively you could create a java helper class implementing conditional rules, and then invoke this class from javascript handlers. Thus colors and conditions would not be hard-coded in each chart, and you could still use javascript to add some other specific rules in charts. For example:

ImportPackage(Packages.test.mycustombirtchartpackage);
function beforeDrawDataPoint( dph, fill, icsc ) {
  MyChartHelperClass.doConditionalFormat(fill, dph.getSeriesDisplayValue());
}

function beforeDrawLegendItem( lerh, bounds, icsc ){
  MyChartHelperClass.doConditionalFormat(lerh.getFill(), lerh.getLabel().getCaption().getValue());
}


Previous Topic:how to read value of a column into another dataset's script
Next Topic:Interfacing BIRT Report Viewer with ASP.NET
Goto Forum:
  


Current Time: Fri Apr 26 02:44:28 GMT 2024

Powered by FUDForum. Page generated in 0.02916 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top