# Dynamic Y-axis scale

Hello BIRT Experts,

I am trying to adjust the y-axis of a report based on a report parameter. If the report parameter is greater than the default y-axis maximum, the y-axis maximum should be set to the parameter. Otherwise, the y-axis scale should keep its default formatting.

I've made some progress with the following script (note that the y and x axes are inverted in this report):

The problem I'm having is that yScale1.getMax() is returning nothing (I'm assuming it gets set later on in the chart rendering) and the y-scale ends up always being set to the report parameter. Which event function sets the y-axis min and max, and what would be the best way to work out this problem?

Thanks for your help

David

I am trying to adjust the y-axis of a report based on a report parameter. If the report parameter is greater than the default y-axis maximum, the y-axis maximum should be set to the parameter. Otherwise, the y-axis scale should keep its default formatting.

I've made some progress with the following script (note that the y and x axes are inverted in this report):

function beforeGeneration( chart, icsc )

{

// Force the y-axis scale to increase if load mark is greater than its default

yAxis1 = chart.primaryBaseAxes[0];

yScale1 = yAxis1.getScale();

if(icsc.externalContext.scriptable.getParameterValue("LoadMark") > yScale1.getMax())

{

yScale1.setMax(NumberDataElementImpl.create(icsc.externalContext.scriptable.getParameterValue("LoadMark")));

yAxis1.setScale(yScale1);

}

}

The problem I'm having is that yScale1.getMax() is returning nothing (I'm assuming it gets set later on in the chart rendering) and the y-scale ends up always being set to the report parameter. Which event function sets the y-axis min and max, and what would be the best way to work out this problem?

Thanks for your help

David

0

## Comments

Regards,

Michael Williams

eSignLive Evangelism & Community Manager | eSignLive by VASCO

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

eSignLive Evangelism & Community Manager | eSignLive by VASCO

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

eSignLive Evangelism & Community Manager | eSignLive by VASCO

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Is there a way to run getMaximum() on a single axis/component of a dataSet?

if (series.eClass().getName().equals("Series 1")){

dsp = ps.getDataSetProcessor(series.getClass());

if (dsp.getMaximum(dataSet) > maxValue)

{

maxValue = dsp.getMaximum(dataSet);

}

}

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Is there a way to only check the one axis' value? Thanks for all the help on this one

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

I am trying to get the dynamic scale and the marker line based on the data set. X-axis seems to be working based on the series values but Y-axis does not. In the attached report, first chart has the code applied to X-axis scale and the second chart has the OnRender script applied to both X-axis and Y-axis.

Any idea why the dynamic scale logic is not working for the Y-axis?

Thanks

UY

Thanks,

UY

Edit: Is it the scale you're wanting to be fixed?

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

The Y-axis scale should look into the min and max values of the "Series 1" and get the Y scale. That does not seem to happen with the code below.

Not sure why the code is not reading the mimimum and maximum values of "Series 1".

Thanks

UY

Thanks,

UY

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

I could resolve this with disabling the grouping on the X-axis series.

Thanks for all your support.

Regards

UY

Thanks,

UY

Regards,

Michael Williams

Find me on:Twitter

Facebook

Blog

LinkedIn

eSignLive Developer Community

Email me:Google: [email protected]

Hello,

I am trying to dynamically change the multiplier and suffix on the y-axis at run time.

For example in a bar chart if the min value of the chart is in excess of Â£1m, to have the scale shown as Â£1m, Â£2m,.... but if the min and max values are between Â£1k and Â£1m to have the scale shown as Â£1k, Â£2k, .....

How might I be able to code that in the beforeGeneration() function ?

Many thanks

What version of BIRT are you using? Is this commercial BIRT, or open source BIRT?

Clement WongPrincipal Analytics ArchitectOpenText Corporation

http://www.actuate.com | http://www.opentext.com

We are using Actuate Birt Designer Professional Version 4.2.3.

Have managed to find a working solution with the following :

yAxis,formatSpecifier.multiplier

yAxis.formatSpecifier.suffix

You can also do this in the

beforeRenderingevent:Attached is a sample.

In the future, please specify what version of BIRT you are using so that we can assist you more efficiently.

Clement WongPrincipal Analytics ArchitectOpenText Corporation

http://www.actuate.com | http://www.opentext.com

Clement Wong,

Qucik question:

what happens when you have secondary Y-axis. getYAxis just updates on primary -Yaxis. Any help would be appreciated.

Thanks

Suresh

chart.getYAxisMax() only works for the first Y axis.

However, if you want to check on the max of the secondary axis, you can get its value via:

Clement WongPrincipal Analytics ArchitectOpenText Corporation

http://www.actuate.com | http://www.opentext.com