Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Scaling Multiple Bar Charts(Want bar charts in table detail row, all with same scale)
Scaling Multiple Bar Charts [message #638036] Tue, 09 November 2010 17:34 Go to next message
Greg Clemenson is currently offline Greg ClemensonFriend
Messages: 2
Registered: November 2010
Junior Member
This is probably really simple, but I don't know BIRT very well.

I put a bar chart in table detail row column. Works great, however the scales are locally fine but globally inconsistent. The thought was to have one data series be the max value (computed as a column max aggregate) and use that to force identical scaling. As far as I can tell, one cannot get data aggregate values into a series no matter what you do. I tried creating a new data binding aggregating over entire table--chart ignored aggregate and showed individual row value. Tried heavy-duty approach: scripting. The thought here was to use some OnCreate code to put the max value in a global variable using reportContext.setPersistentGlobalVariable and then set the chart scale by retrieving the global variable value. Chart scripting only seems to have OnRender functions available for scripting and I could not figure out how to access the report context to retrieve the global variable value.
Re: Scaling Multiple Bar Charts [message #638045 is a reply to message #638036] Tue, 09 November 2010 17:50 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Greg,

Not sure how you are doing the aggregate (would be great if you could
post an example using the sample db). But using the script approach
should work. To get the global variable use code like:
mar =
icsc.getExternalContext().getScriptable().getPersistentGloba lVariable( "myvar");

To scale it you could use a beforeGeneration script like:

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(1.5) )
yscale.setMax( NumberDataElementImpl.create(mar) )
yAxis.setScale(yscale);

Jason

On 11/9/2010 12:34 PM, Greg Clemenson wrote:
> This is probably really simple, but I don't know BIRT very well.
>
> I put a bar chart in table detail row column. Works great, however the
> scales are locally fine but globally inconsistent. The thought was to
> have one data series be the max value (computed as a column max
> aggregate) and use that to force identical scaling. As far as I can
> tell, one cannot get data aggregate values into a series no matter what
> you do. I tried creating a new data binding aggregating over entire
> table--chart ignored aggregate and showed individual row value. Tried
> heavy-duty approach: scripting. The thought here was to use some
> OnCreate code to put the max value in a global variable using
> reportContext.setPersistentGlobalVariable and then set the chart scale
> by retrieving the global variable value. Chart scripting only seems to
> have OnRender functions available for scripting and I could not figure
> out how to access the report context to retrieve the global variable value.
Re: Scaling Multiple Bar Charts [message #638283 is a reply to message #638045] Wed, 10 November 2010 17:05 Go to previous messageGo to next message
Greg Clemenson is currently offline Greg ClemensonFriend
Messages: 2
Registered: November 2010
Junior Member
Your solution worked quite well. I now get a table with embedded charts that have identical scales.

I did have to work a bit to get the aggregation to work properly. I ended up with an OnCreate script on the containing table with this code:

var maxTime = Total.max(row["task_total_time"]);
reportContext.setPersistentGlobalVariable("maxTime", "" + maxTime);


In the second line, "" + maxTime converts the number maxTime to a string. Otherwise Java throws an error because the needed method signature is reportContext.setPersistentGlobalVariable(String, String).

Thank you
Re: Scaling Multiple Bar Charts [message #638301 is a reply to message #638283] Wed, 10 November 2010 18:07 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Glad you got it working.

Jason

On 11/10/2010 12:05 PM, Greg Clemenson wrote:
> Your solution worked quite well. I now get a table with embedded charts
> that have identical scales.
>
> I did have to work a bit to get the aggregation to work properly. I
> ended up with an OnCreate script on the containing table with this code:
>
> var maxTime = Total.max(row["task_total_time"]);
> reportContext.setPersistentGlobalVariable("maxTime", "" + maxTime);
>
>
> In the second line, "" + maxTime converts the number maxTime to a
> string. Otherwise Java throws an error because the needed method
> signature is reportContext.setPersistentGlobalVariable(String, String).
>
> Thank you
>
Previous Topic:Dynamic report::how to display report output in a frameset
Next Topic:Conditionally showing draft figure?
Goto Forum:
  


Current Time: Thu Apr 25 08:48:40 GMT 2024

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

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

Back to the top