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)
Determining the name of a chart in script
RichT
Hi,
How can I determine the name of the chart I'm in within the beforeGeneration function of the chart?
Background: I'm creating copies of a chart in the beforeFactory event of the report. During this activity I am setting the name of the reports ("chart-1", "chart-2", "chart-3").
I seem to be able to find every other attribute related to the chart except for the name.
Any thoughts or ideas are appreciated.
Find more posts tagged with
Comments
mwilliams
What's your BIRT version? I'll take a look.
RichT
Version 2.6<br />
<br />
As a work around I was able to set the series identifier for each chart while looping thru my chart copying activities in the beforeFactory event and then grab series in the beforeGeneration function in the chart. This works this time around because I only have one series in the charts.<br />
<br />
I am taking the example provided by johnw <a class='bbc_url' href='
http://digiassn.blogspot.com/2009/06/birt-highlight-chart-series-on.html'>Highlight
Chart Series on MouseOver Event</a> and revising it to work on a line chart. Below is my basic setup in beforeFactory-<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage(Packages.org.eclipse.emf.ecore.util);
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);
var reportDesignHandle = reportContext.getReportRunnable().getDesignHandle();
cht = reportDesignHandle.findElement("trendLineChart");
trendLineChart = cht.getReportItem().getProperty("chart.instance");
for (var x = 1; x <=5; x++){
var chartCopy = EcoreUtil.copy(trendLineChart);
var xAxis = chartCopy.getBaseAxes()[0];
var yAxis = chartCopy.getOrthogonalAxes( xAxis, true )[0];
var seriesDef = yAxis.getSeriesDefinitions().get(0);
var series = seriesDef.getSeries().get(0);
//set the series name to identify it in the chart script
series.setSeriesIdentifier("Series-" + x);
var eih = reportDesignHandle.getElementFactory().newExtendedItem("Chart-" + x, "Chart");
eih.getReportItem().setProperty("chart.instance", chartCopy);
eih.setBookmark("\"Chart-" + x + "\"");
cht.getContainerSlotHandle().add(eih);
}</pre>
<br />
Thanks again for taking a look at it.<br />
-Rich
mwilliams
Great! Glad you found a solution!