Skip to main content



      Home
Home » Archived » BIRT » Problems setting Y-Axis min and max dynamically
Problems setting Y-Axis min and max dynamically [message #243436] Tue, 19 June 2007 23:16 Go to next message
Eclipse UserFriend
Hi,

I am using BIRT 2.1.1 and I am trying to set the min and max values for
the y-axis dynamically.

I am passing a java object to the reports which contains the min and max
values. In the scriptable dataset I use the following java script for the
"fetch" method:

importPackage(Packages.java.lang)

if (!trendNameIterator.hasNext())
{
return false;
}
else
{
trendNameNode = trendNameIterator.next();

row["TrendName"] = trendNameNode.getTrendName();
row["ResponseNode"] = trendNameNode;
row["ResponseCnt"] = trendNameNode.getResponseCnt();
row["MC"] = trendNameNode.getMultipleChoice();
row["MaxVal"] = trendNameNode.getMaxResponseValue();
row["MinVal"] = trendNameNode.getMinResponseValue();
reportContext.setPersistentGlobalVariable("maxValue", new
Float(trendNameNode.getMaxResponseValue()));
reportContext.setPersistentGlobalVariable("minValue", new
Float(trendNameNode.getMinResponseValue()));

return true;
}

I define the beforeGeneration method of the chart as:

function beforeGeneration( chart, context ){

// Axis information
xAchse = chart.getBaseAxes();
yAchse = chart.getOrthogonalAxes(xAchse[0], true);

// getScale yields all information about the scale (min, max, step ...)
s = yAchse[0].getScale();

scriptable = context.getExternalContext().getScriptable();
maxValue = scriptable.getPersistentGlobalVariable("maxValue");
minValue = scriptable.getPersistentGlobalVariable("minValue");

// create new data element
max =
Packages.org.eclipse.birt.chart.model.data.impl.NumberDataEl ementImpl.create(maxValue);
min =
Packages.org.eclipse.birt.chart.model.data.impl.NumberDataEl ementImpl.create(minValue);

// set new max and step width
s.setMax (max);
s.setMin (min);

//s.setMin (min);
//s.setStep (2); I get errors if I uncomment this line

// ... finally set the scale of the axis
//yAchse[0].setScale(s); I get errors if I uncomment this line
}

When I run the report the y-axis is showing values 1.0 - 3.0 in the
increments of 0.2. It is not showing min and max that I expect on the
y-axis. I am also printing the row["MaxVal"] and row["MinVal"]and it is
printing the expected value. Am I missing something here?

Regards,
Nisha
Re: Problems setting Y-Axis min and max dynamically [message #243848 is a reply to message #243436] Thu, 21 June 2007 08:11 Go to previous message
Eclipse UserFriend
It works for me in 2.2 RC4. Can you try with 2.1.3?

Thanks,

David

"Nisha Agarwal" <nagarwal@healthhero.com> wrote in message
news:5eae5593f06edf2f6bf2aa78d2ad0916$1@www.eclipse.org...
> Hi,
>
> I am using BIRT 2.1.1 and I am trying to set the min and max values for
> the y-axis dynamically.
>
> I am passing a java object to the reports which contains the min and max
> values. In the scriptable dataset I use the following java script for the
> "fetch" method:
>
> importPackage(Packages.java.lang)
>
> if (!trendNameIterator.hasNext())
> {
> return false;
> }
> else
> {
> trendNameNode = trendNameIterator.next();
>
> row["TrendName"] = trendNameNode.getTrendName();
> row["ResponseNode"] = trendNameNode;
> row["ResponseCnt"] = trendNameNode.getResponseCnt();
> row["MC"] = trendNameNode.getMultipleChoice();
> row["MaxVal"] = trendNameNode.getMaxResponseValue();
> row["MinVal"] = trendNameNode.getMinResponseValue();
> reportContext.setPersistentGlobalVariable("maxValue", new
> Float(trendNameNode.getMaxResponseValue()));
> reportContext.setPersistentGlobalVariable("minValue", new
> Float(trendNameNode.getMinResponseValue()));
>
> return true;
> }
>
> I define the beforeGeneration method of the chart as:
>
> function beforeGeneration( chart, context ){
>
> // Axis information
> xAchse = chart.getBaseAxes();
> yAchse = chart.getOrthogonalAxes(xAchse[0], true);
>
> // getScale yields all information about the scale (min, max, step ...)
> s = yAchse[0].getScale();
>
> scriptable = context.getExternalContext().getScriptable();
> maxValue = scriptable.getPersistentGlobalVariable("maxValue");
> minValue = scriptable.getPersistentGlobalVariable("minValue");
>
> // create new data element
> max =
> Packages.org.eclipse.birt.chart.model.data.impl.NumberDataEl ementImpl.create(maxValue);
> min =
> Packages.org.eclipse.birt.chart.model.data.impl.NumberDataEl ementImpl.create(minValue);
>
> // set new max and step width
> s.setMax (max);
> s.setMin (min);
>
> //s.setMin (min);
> //s.setStep (2); I get errors if I uncomment this line
>
> // ... finally set the scale of the axis
> //yAchse[0].setScale(s); I get errors if I uncomment this line
> }
>
> When I run the report the y-axis is showing values 1.0 - 3.0 in the
> increments of 0.2. It is not showing min and max that I expect on the
> y-axis. I am also printing the row["MaxVal"] and row["MinVal"]and it is
> printing the expected value. Am I missing something here?
>
> Regards,
> Nisha
>
Previous Topic:duplicate colors in pie charts
Next Topic:[2.2 RC2 & RC3] Dynamically change label of a chart doesn't work anymore
Goto Forum:
  


Current Time: Sat May 10 11:25:48 EDT 2025

Powered by FUDForum. Page generated in 0.03456 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top