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 set the scale of the Y-axis dynamically in Bar chart?
Aarti
Hi,
How can I set the scale of the Y-axis dynamically in bar chart.
The max and min values for the scale will be coming from my dataset.
The step size for the scale will remain fixed as defined.
Will I have to write a script? If yes, can anyone guide me how to write a script for the same.
Thanks and Regards,
Aarti
Find more posts tagged with
Comments
mwilliams
This devShare doesn't do exactly what you're wanting, but the beforeGeneration script used is still the same as what you'd use, except you'd pass your values in from your dataSet and use them rather than what this script uses. Let me know your version if you need an example.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/655-reverse-bar-chart-scale/
Aarti
Thank you for replying..
Yes an example will be of great help. Currently I am using BIRT v2.5.
Aarti
I presume following code snippet, from your previous example, can be used for setting the chart axes dynamically:
function beforeGeneration(chart, icsc)
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
xAxis = chart.getBaseAxes()[0];
yAxis = chart.getOrthogonalAxes( xAxis, true)[0]
yscale = yAxis.getScale();
yscale.setStep (10);
yscale.setMin( NumberDataElementImpl.create(0) )
yscale.setMax( NumberDataElementImpl.create(gblscale) )
yAxis.setScale(yscale);
}
Only in above code the min and max values for Y scale should be coming from dataSet.
In this case, how can I access the dataSet values in the above code?
mwilliams
In the onFetch of the dataSet where you have the min and max fields, you can store the values into persistent global variables. Then, in the chart, retrieve those PGVs and set your scale.