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)
Persisting Parameter Value throughout report
bgbaird
<p>I have a requirement to manage the y axis scale on a bar chart dynamically based on external data.</p>
<p> </p>
<p>Currently:</p>
<p>I set the parameter value default (ie 50).</p>
<p>params["myParam"].value == 50</p>
<p>Execute a dataset using a table.</p>
<p>In that dataset, I set the parameter value based on stuff (ie 75).</p>
<p>params["myParam"].value ==75</p>
<p> </p>
<p>After this, I have a bar chart.</p>
<p> </p>
<p>In beforeDataSetFilled,</p>
<p>I set "gblscale" = icsc.getExternalContext().getScriptable().getParameterValue("myParam").</p>
<p> </p>
<p>In beforeGeneration,</p>
<p>I set yscale.setMax( NumberDataElementImpl.create(gblscale) )</p>
<p> </p>
<p>The Y Scale resolves to the default parameter value of 50. I want it to be 75.</p>
<p> I'm working in 3.2.22</p>
<p> </p>
<p>Thanks, Brian</p>
<p>
Find more posts tagged with
Comments
mwilliams
<p>Have you tried using a PersistentGlobalVariable vs using a Parameter?</p>
bgbaird
<p>That worked. I had been running into an issue with the variable type, but figured it out.T</p>
<p> </p>
<p>Thanks, Brian</p>
bgbaird
<p>On second thought, it didn't work. I'm having an issue getting a changed global variable into the chart script. It always seems to take the initial value of the variable.</p>
<p> </p>
<p>I set the value in the report initialize:</p>
<p><strong>reportContext.setPersistentGlobalVariable("maxRocCount",new Number(88));</strong></p>
<p> </p>
<p>I reset the value (I've tried multiple events before the chart execution):</p>
<p><strong>reportContext.setPersistentGlobalVariable("maxRocCount",new Number(99));</strong></p>
<p> </p>
<p>In the chart, i always get the initial value of 88:</p>
<p> </p>
<p><strong>var gblscale = new Number(22)</strong></p>
<p> </p>
<p> </p>
<p><strong>function beforeDataSetFilled( series, idsp, icsc )</strong></p>
<p><strong><strong> {</strong></strong></p>
<p><strong><strong> gblscale = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("maxRocCount");</strong></strong></p>
<p><strong><strong> }</strong></strong></p>
<p> </p>
<p><strong>function beforeGeneration( chart, context )<br>
{<br>
chart.setUnitSpacing(50);<br>
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );<br>
xAxis = chart.getBaseAxes()[0];<br>
yAxis = chart.getOrthogonalAxes( xAxis, true)[0]<br>
yscale = yAxis.getScale();<br>
yscale.setStep (10);<br>
yscale.setMin( NumberDataElementImpl.create(0) )<br>
yscale.setMax( NumberDataElementImpl.create(gblscale) )<br>
yAxis.setScale(yscale);<br>
}</strong></p>
mwilliams
<p>Here are the changes I made in your report that worked for me using PGVs.</p>
<p> </p>
<p>Computed Column:</p>
<p> </p>
<div><pre class="_prettyXprint _linenums:0">reportContext.setPersistentGlobalVariable("myParam","75");
123;</pre></div>
<p> </p>
<p>BeforeDataSetFilled:</p>
<p> </p>
<p></p><pre class="_prettyXprint _linenums:0">gblscale = parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("myParam"));</pre>
bgbaird
<p>Cool, that did it. I had issues with the string to integer issue I think.;</p>