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)
modifing barchart in script
cheq326
I have a report with Barcharts. A series that shows Q1 data, now I need to update the chart to include Q2 data as well. I was able to add a series using following codes, but its color is grey(I want it to be red), and label shows counts(I want it to be in percentile format). Also need to update the text/color of Legends. I hope I explain it clearly. Please help, thanks!
in beforefactory:
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
//Chart must be named
cht = reportContext.getDesignHandle().findElement("chart1");
mychart = cht.getReportItem().getProperty( "chart.instance" );
//Get the x axis
xAxis =mychart.getAxes().get(0);
//Get the first y axis
yAxis1 = xAxis.getAssociatedAxes().get(0);
{
//create a new series definition for each new series
var sdNew = SeriesDefinitionImpl.create();
//create a new series for each parameter selection
var ls = BarSeriesImpl.create();
ls.getLabel().setVisible(true);
//set bar color
//ls.setRiserOutline(ColorDefinitionImpl.RED());
//Create the query. The row value must correlate with the data set row value
var qry = QueryImpl.create("row[\"NewCol\"]" );
ls.getDataDefinition().add(qry)
sdNew.getSeries().add( ls );
//Add the new series definition to the first y axis
yAxis1.getSeriesDefinitions().add( sdNew );
}
Find more posts tagged with
Comments
mwilliams
This should set the color:
function beforeDrawDataPoint( dph, fill, icsc )
{
if (dph.getSeriesDisplayValue() == "blah"){
fill.set(255,0,0);
}
}
I believe the legend color can be set in the beforeDrawLegendItem function of the chart.
cheq326
Thanks for your reply! I have a report with lots of tables(>50). I have to go to each table to add this function? Is there an easier way to do this(like setting up color while creating it in beforeFactory)?<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="72065" data-time="1294698975" data-date="10 January 2011 - 03:36 PM"><p>
This should set the color:<br />
<br />
function beforeDrawDataPoint( dph, fill, icsc )<br />
{<br />
if (dph.getSeriesDisplayValue() == "blah"){<br />
fill.set(255,0,0);<br />
}<br />
}<br />
<br />
I believe the legend color can be set in the beforeDrawLegendItem function of the chart.<br /></p></blockquote>
mwilliams
As far as I know, the series palette is different for each chart, so you'd have to set the colors for each chart probably. I'll ask a colleague and let you know if I find out differently.