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)
Chart - how to get column value from Container and pass it to title
hedgehog
<p>Hello,</p>
<p> </p>
<p>I have data grouped by STATION. For each group a chart is created with data "Inherit data from container".</p>
<p> </p>
<p>I need to change the title for the chart and show the STATION. I know how to change the title</p>
<p> <span style="font-family:'courier new', courier, monospace;">function beforeGeneration(chart, icsc) {<br>
chart.getTitle().getLabel().getCaption().setValue("....");<br>
}</span></p>
<p>but I don't know how to pass value from column STATION.</p>
<p> </p>
<p>Thank you very much in advance,</p>
<p>Lucy</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
Clement Wong
<p>We can get the value category and the values of the series in the afterDataSetFilled event. So then we save it, and use that variable in the beforeGeneration event to set the title.</p>
<p> </p>
<p>Example:</p>
<pre class="_prettyXprint _lang-">
function afterDataSetFilled( series, dataSet, icsc )
{
if (series.getSeriesIdentifier() == ""){ // Category (not a series like 'Series 1'
myTitle = dataSet.getValues()[0];
}
}
function beforeGeneration(chart, icsc) {
chart.getTitle().getLabel().getCaption().setValue(myTitle);
}
</pre>
hedgehog
<p>Hi,</p>
<p> </p>
<p>thanks for the reply. With <span style="font-family:'courier new', courier, monospace;"><span>series</span><span>.</span><span>getSeriesIdentifier</span><span>()</span><span> </span><span>==</span><span> </span><span>"" </span></span></p>
<p><span style="font-family:'courier new', courier, monospace;"><span><span style="font-family:arial, helvetica, sans-serif;">I got the values from x-axis (Category). But what I need is the following: The chart is binded to data model, which contains column STATION, STAMP and INDICATOR. In the graph I display the STAMP (x-axis) and INDICATOR (y-axis). And in the title I need to have STATION.</span></span></span></p>
<p>Is it possible?</p>
<p> </p>
<p>Thanks,</p>
<p>Lucy</p>
Clement Wong
<p>In the future, please include an example of what you've tried and what you are trying to achieve. Data model? BTW, are you using commercial BIRT?</p>
<p> </p>
<p>If the data is not in defined for the chart, you'll need to store it and retrieve it. I'm sure there are other ways, but here's one:</p>
<p> </p>
<p>1. In the beforeFactory event of the report, create a Java hashmap, and store it in a BIRT persistent global variable:</p>
<pre class="_prettyXprint _lang-">
importPackage(Packages.java.util);
reportContext.setPersistentGlobalVariable("pgvDataHashMap", new HashMap());
</pre>
<p>2. In the Chart's Category Definition under Edit Chart > Select Data, modify the expression to save the other values. For example, if your original category was <strong>row["Status Group"]</strong>, then change it to:</p>
<pre class="_prettyXprint _lang-">
var myDataHashMap = reportContext.getPersistentGlobalVariable("pgvDataHashMap");
myDataHashMap.put (row["Status Group"], row["STATION"]);
reportContext.setPersistentGlobalVariable("pgvDataHashMap", myDataHashMap);
row["Status Group"];
</pre>
<p>3. In the afterDataSetFilled event, change my previous example of setting the myTitle variable to:</p>
<pre class="_prettyXprint">
myTitle = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("pgvDataHashMap").get (dataSet.getValues()[0]);</pre>
<p>This method works in my environment. <strong> Sorry, I will be out of the office and will not be able to reply until after Monday, July 10th.</strong></p>