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)
Get Chart in rptdesign file
chris_w
Hi,<br />
<br />
I defined a chart which is saved in the rptdesign file for example with id <strong class='bbc'>1</strong>.<br />
<br />
And now, I would like to read the Chart using the BIRT API.<br />
<br />
I read the file with the <em class='bbc'>ReportDesignHandle</em> and used the <strong class='bbc'>getElementByID(1)</strong> method to retrieve the <strong class='bbc'>DesignElement </strong>. Thats working. But now, how do I get the chart object itself? Is it possible to cast something? Is that the correct approach itself?<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
...
//open a design or a template
designHandle = session.openDesign("some path");
DesignElementHandle deh = designHandle.getElementByID(1);
DesignElement de = deh.getElement();
// And now something like: Chart chart = (Chart) de.getElement() ????????
</pre>
Find more posts tagged with
Comments
chris_w
Found that way to get the chart from rptdesign file. But is that the common way to use a while loop to do that?<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
// Instantiate a slot handle and iterator for the body slot.
SlotHandle shBody = designHandle.getBody();
Iterator<SlotHandle> slotIterator = shBody.iterator();
// To retrieve top-level report items, iterate over the body.
while (slotIterator.hasNext()) {
Object shContents = slotIterator.next();
if( shContents instanceof ExtendedItemHandle){
String type = ((ExtendedItemHandle)shContents).getExtensionName();
if( type.compareToIgnoreCase("Chart") == 0){
Chart cm = (Chart) ((ExtendedItemHandle) shContents).getReportItem().getProperty( "chart.instance" );
}
}
}
</pre>
mwilliams
You might try something like:
reportContext.getDesignHandle().getElementByID(1).getProperty("chart.instance");