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)
dynamic Max Scale of a meter chart
Kchiri Yassine
<p>Hi<br>
I'm working on a meter chart that shows me the count of each string in a column of a dataset<br>
so to set dynamicaly the scale I used the beforeGeneration method of the meterchart and the onfetch method of the dataset</p>
<p><strong>onFetch script:</strong></p>
<p>reportContext.setPersistentGlobalVariable("Maxpgs", row["pgs_total"].toString() );<br><strong>BeforeGeneration script:</strong></p>
<p>function beforeGeneration( chart, icsc )<br>
{<br><br>
importPackage( Packages.org.eclipse.birt.chart.model.impl );<br>
importPackage( Packages.org.eclipse.birt.chart.model.type.impl );<br>
importPackage( Packages.org.eclipse.birt.chart.model.attribute );<br>
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );<br>
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );<br>
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);<br>
<br>
seriesDef = chart.getSeriesDefinitions().get(0);<br>
meter1 = seriesDef.getSeriesDefinitions().get(0).getRunTimeSeries().get(0);<br>
mdial = meter1.getDial( );<br>
mscale = mdial.getScale( );<br>
mscale.setStep( 50 );<br>
mscale.setMin( NumberDataElementImpl.create( 0 ) );<br>
max=icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("Maxpgs")<br>
mscale.setMax( NumberDataElementImpl.create( max ) );<br>
<br>
}</p>
<p>it work perfectly when i don't use the optional grouping, but when i use the grouping which allow me to count the number of each string of that column, it set the maximum scale only for the first instance of the chart and let the others with the default value which is 1</p>
<p>So How can i set the Max Scale for all the instances of the meterchart<br><br>
Find more posts tagged with
Comments
JFreeman
<p>When you use the optional grouping, a new series is created for each group that is created and the way your code is setup you are explicitly setting the scale for only the first series. Instead you will need to iterate through each series and apply the desired scale.</p>
<p> </p>
<p>For example:</p>
<pre class="_prettyXprint _lang-js">
function beforeGeneration( chart, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
var seriesDef = chart.getSeriesDefinitions().get(0);
var seriesIterator = seriesDef.getSeriesDefinitions().get(0).getRunTimeSeries().listIterator();
while(seriesIterator.hasNext()){
var meter = seriesIterator.next();
var meterDial = meter.getDial();
var meterScale = meterDial.getScale();
meterScale.setStep(3);
meterScale.setMin(NumberDataElementImpl.create(0));
meterScale.setMax(NumberDataElementImpl.create(15));
}
}
</pre>
<p>I have also attached a sample report with this code in place for reference.</p>
Kchiri Yassine
<p>It work perfectly now<br>
Thank you</p>
JFreeman
<p>You're welcome.</p>
<p>Let us know if you have any additional questions.</p>