Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to use a dataRow value in a Chart Title?
DierckxK
I've created a report, that has a list using a group on a specific column. <br />
In the group header I've added the data field used in the group, and also a chart. This is working very nicely.<br />
<br />
But now my end user would like to have that data field, IN the title of the chart. (so they can reuse the chart image, without loosing the 'group' this chart is about.<br />
<br />
As far as I could understand, this is not directly possible using the birt designer, as I can only specify a static text value for the title.<br />
So I assume I've got to learn some birt scripting.<br />
<br />
I've managed to script changing the chart title, using a static value:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc )
{
chart.getTitle().getLabel().getCaption().setValue("A title that is set from script ");
</pre>
<br />
But I can't seem to figure out how to get the data for the current group...<br />
<br />
Does anyone have some pointers how to accomplish this?<br />
(Ideally some example code, as I'm new to birt scripting)<br />
<br />
UPDATE:<br />
(typically, when you post the question, 10 minutes later you find the solution...)<br />
<br />
In the list, on 'List Group' add following code:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("charttitle", row["PERSON"]);</pre>
<br />
On the chart (that is used on the group header)<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc )
{
var myTitle = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("charttitle");
chart.getTitle().getLabel().getCaption().setValue(myTitle);
}
</pre>
Find more posts tagged with
Comments
mwilliams
Hi DierckxK,
You did it exactly how I would have replied. Glad you figured it out! Let us know whenever you have questions!
DierckxK
LOL
a typical case of 'great minds think alike'
No seriously, it's good to know there is an active community, in case I run into problems later on.
thnx for your reply