Controlling Bar/Line Chart Plotted Colors
I've been using the following code (in the onRender script area of the individual chart) to control the legend and 'slice' colors for Pie charts:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawLegendItem( lerh, bounds, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
label = lerh.getLabel();
labelString = label.getCaption().getValue();
if (labelString == "Approved")
lerh.getFill().set(51, 224, 68);
else if (labelString == "Closed")
lerh.getFill().set(48, 48, 48);
else if (labelString == "Submitted")
lerh.getFill().set(0, 68, 255);
else if (labelString == "New")
lerh.getFill().set(255, 0, 0);
else if (labelString == "Review")
lerh.getFill().set(255, 144, 40);
else if (labelString == "Postponed")
lerh.getFill().set(240, 255, 76);
else
lerh.getFill().set(30,30,30);
}
function beforeDrawDataPoint( dph, fill, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
baseVal = dph.getBaseValue();
if (baseVal == "Approved")
fill.set(51, 224, 68);
else if (baseVal == "Closed")
fill.set(48, 48, 48);
else if (baseVal == "Submitted")
fill.set(0, 68, 255);
else if (baseVal == "New")
fill.set(255, 0, 0);
else if (baseVal == "Review")
fill.set(255, 144, 40);
else if (baseVal == "Postponed")
fill.set(240, 255, 76);
}
</pre>
<br />
This works perfectly with Pie charts; however, for both Bar and Line charts it only properly controls the colors of the Legend items (not the actual plotted data). This leads me to believe that I must somehow modify the beforeDrawDataPoint function. <br />
<br />
Any ideas?<br />
<br />
Thanks!