Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Changing the background color of chart using event handler
Happy_20
I have to change the 3 different background color of meter chart based on the the parameters i get in the database. I need to do this in java using event handler. Can anyone tell me how to do that
Find more posts tagged with
Comments
johnw
<pre class='_prettyXprint _lang-auto _linenums:0'>
import org.eclipse.birt.chart.model.attribute.ColorDefinition;
import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl;
import org.eclipse.birt.chart.model.layout.Block;
import org.eclipse.birt.chart.script.ChartEventHandlerAdapter;
import org.eclipse.birt.chart.script.IChartScriptContext;
import org.eclipse.birt.report.data.adapter.api.script.ReportContextObject;
public class Test extends ChartEventHandlerAdapter {
@Override
public void beforeDrawBlock(Block block, IChartScriptContext icsc) {
ReportContextObject reportContext = (ReportContextObject) icsc.getExternalContext().getObject();
reportContext.getParameterValue("backgroundColor");
int red = 0;
int blue = 0;
int green = 127;
ColorDefinition color = ColorDefinitionImpl.create(red, green, blue);
block.setBackground(color);
}
}
</pre>