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)
Chart colors override script
Uuux
Hi, I've been working lately on styling reports and i've ran in the wall with overriding original palette. Here is the deal, I want my charts to use color1 to color2 gradient. I was succesful using script I've found here for doing such thing:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
piecnt = 0;
startColor = null;
endColor = null;
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
function afterDataSetFilled(series, dataSet, icsc)
{
importPackage( Packages.java.io );
importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
if( series.getClass() == PieSeriesImpl ){
if( series.getSeriesIdentifier() == "Total distribution by customer [linemon not included]" ){
var list = dataSet.getValues();
piecnt = list.length;
}
}
startColor = ColorDefinitionImpl.WHITE();
endColor = ColorDefinitionImpl.BLUE();
//startColor = ColorDefinitionImpl.GREY();
//endColor = ColorDefinitionImpl.BLACK();
}
function buildPalette( sliceNumber )
{
var sr = startColor.getRed();
var sg = startColor.getGreen();
var sb = startColor.getBlue();
var er = endColor.getRed();
var eg = endColor.getGreen();
var eb = endColor.getBlue();
var nr = ((er-sr)/piecnt)*sliceNumber + sr;
var ng = ((eg-sg)/piecnt)*sliceNumber + sg;
var nb = ((eb-sb)/piecnt)*sliceNumber + sb;
var nc = ColorDefinitionImpl.create( nr, ng, nb );
return nc;
}
function beforeGeneration( chart, icsc )
{
sd = chart.getSeriesDefinitions( ).get( 0 );
sd.getSeriesPalette( ).getEntries( ).clear( );
for ( i = 1; i <= piecnt; i++ )
{
sd.getSeriesPalette().getEntries().add( buildPalette(i) );
}
}
</pre>
<br />
And my question is: Is it possible to do same thing for bar and stack bar charts? I am curently use BIRT4.2 on tomcat6.
Find more posts tagged with
Comments
mwilliams
Take a look at this example. I modified the script above, slightly, to work with a bar chart.