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)
Common scaling with rounded values for multiple y axis
Ddev
Hi,<br />
I have a stacked bar chart with line series in it. The stacked bar is plotted in one y axis and the line series are plotted against second y axis. I have to provide common scale to both y axis. The max value should be rounded too. The max value is dynamic and I calculated the max value in the java code and passed it to the report as a dataset column(for all the rows in the dataset, this column value will be same as it is the highest among all the values). However my code is not working as expected.<br />
<br />
Below is the script that I am using for fetching the highest value(that i passed from java code) from the dataset<br />
<br />
max=0;<br />
function afterDataSetFilled( series, dataSet, icsc )<br />
{<br />
importPackage( Packages.java.io );<br />
importPackage( Packages.org.eclipse.birt.chart.model.type.impl );<br />
importPackage( Packages.org.eclipse.birt.chart.util);<br />
<br />
var list = dataSet.getValues();<br />
for( i=0;i<list.length;i++){ <br />
if( list
> max ){<br />
max = list
;<br />
} <br />
} <br />
}<br />
Below is the script for setting the common max scale <br />
<br />
function beforeGeneration( chart, icsc ){<br />
<br />
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );<br />
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);<br />
<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute);<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);<br />
<br />
var roundedMax = 0;<br />
var chart = icsc.getChartInstance();<br />
xAxis = chart.getBaseAxes()[0];<br />
yAxis1 = chart.getOrthogonalAxes( xAxis, true)[0]<br />
yAxis2 = chart.getOrthogonalAxes( xAxis, true)[1]<br />
yscale1 = yAxis1.getScale();<br />
yscale2 = yAxis2.getScale();<br />
//For getting a rounded value<br />
if(max >= 0 && max <= 99) {<br />
roundedMax = BirtMath.roundUp(max/10)*10<br />
} else if(max >= 100 && max <= 999) {<br />
roundedMax = BirtMath.roundUp(max/100)*100<br />
} else if(max >= 1000 && max <= 9999) {<br />
roundedMax = BirtMath.roundUp(max/1000)*1000<br />
} else if (max >= 10000 && max <= 99999) {<br />
} else if (max >= 100000 && max <= 999999) {<br />
roundedMax = BirtMath.roundUp(max/100000)*100000; <br />
} else if(max >= 1000000 && max <= 9999999){<br />
roundedMax = BirtMath.roundUp(max/1000000)*1000000<br />
} else {<br />
roundedMax = BirtMath.roundUp(max/10000000)*10000000<br />
}<br />
yscale1.setMin( NumberDataElementImpl.create(0) );<br />
yscale1.setMax( NumberDataElementImpl.create(roundedMax) );<br />
yAxis1.setScale(yscale1); <br />
yscale2.setMin( NumberDataElementImpl.create(0) );<br />
yscale2.setMax( NumberDataElementImpl.create(roundedMax) );<br />
yAxis2.setScale(yscale2); }<br />
<br />
Say for example, if the highest value is 70123, then the scale should display max value as 80000, but it is showing only 70000. The rounding is not working as I understand. My birt version is 2.3. Can anybody help me in identifying the issue? Or is there any other better way to do this?<br />
<br />
Regards<br />
Ddev.
Find more posts tagged with
Comments
There are no comments yet