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)
Another chart color question
hpbrantley
<p>After lots of searching I've come up empty handed. I need to force the colors on an area chart. The code I use on a pie chart doesn't work, except on the legend. No matter what I change, the area will not change colors. What am I missing?</p>
<p> </p>
<p>Thanks for looking.</p>
<p>Hue</p>
<p> </p>
<div>function beforeDrawLegendItem( lerh, bounds, icsc ) {</div>
<div> var seriesValue = lerh.getLabel().getCaption().getValue();</div>
<div> var fill = lerh.getFill();</div>
<div> if( seriesValue == "BUILDING" )</div>
<div> fill.set(75,75,75);</div>
<div> if( seriesValue == "GARAGE" )</div>
<div> fill.set(204,204,0);</div>
<div>}</div>
<div> </div>
<div>function beforeDrawDataPoint( dph, fill, icsc ) { </div>
<div> if( dph.getBaseDisplayValue() == "BUILDING" )</div>
<div> fill.set(75,75,75);</div>
<div> if( dph.getBaseDisplayValue() == "GARAGE" )</div>
<div> fill.set(204,204,0);</div>
<div>}</div>
Find more posts tagged with
Comments
Clement Wong
<p>For Open Source BIRT charts, to modify the area chart you can change in the <em>beforeGeneration </em>event. This example below is hard coded to get the first series color, clear the color value, and change it to yellow.</p>
<pre class="_prettyXprint _lang-">
function beforeGeneration( chart, icsc )
{
var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
//var xSerieDef = xAxis.getSeriesDefinitions().get(0);
var ySerieDef = yAxis.getSeriesDefinitions().get(0);
ySerieDef.getSeriesPalette().getEntries().clear();
ySerieDef.getSeriesPalette().getEntries().add( ColorDefinitionImpl.YELLOW() );
}
</pre>
hpbrantley
<p>Thank you for the reply. Just what I needed. One thing for anyone else reading, this function also needed importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );</p>