Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Dynamic dial chart scale
Dynamic dial chart scale [message #948956] Thu, 18 October 2012 14:48 Go to next message
Tobbi Filteau is currently offline Tobbi FilteauFriend
Messages: 10
Registered: September 2011
Junior Member
I'm currently doing a sparkline chart in BIRT that resembles the one presented here (just so you have a general idea of what sort of context I'm working with):

This part went swimmingly, but now, I'd like a dial chart at the end of the line that shows where the average payment is located in relation with the maximum payment and the minimum payment.

So essentially, I want the minimum payment as the minimum value on the dial's scale and the maximum payment as the maximum value on the dial's scale. So, I created three aggregations in my table to extract this data (one for the average, one for the max and one for the min).

However, while I can set these aggregations as dials for the chart, I can't set any of them as the max and min for the scale. In my case, hardcoded values are impossible to set since, from one product to another, my values change greatly (for example, one can be between 100 and 200 while the next goes from 5000 to 10000... try hardcoding that!!!). And there's also WAY too many product to do each one of them by hand.

Obviously, the chart has access to the aggregations since I can choose them for dials... so why only dials and not the min and max of the scale too? I saw this post:

which sets the min and max via a script... but again the values are hardcoded, which sucks because it's otherwise exactly what I need to do.

Any suggestion would be greatly appreciated.

Re: Dynamic dial chart scale [message #949392 is a reply to message #948956] Fri, 19 October 2012 00:22 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is the dial going to be in the row? Meaning will you have multiple dials? If you only have one and it is in the table, put an oncreate script on the row containing it and enter a script like:

var myMin = this.getRowData().getColumnValue("nameofyourmincolbinding");
var myMax = this.getRowData().getColumnValue("nameofyourmaxcolbinding");
reportContext.setPersistentGlobablVariable("myMin", myMin);
reportContext.setPersistentGlobablVariable("myMax", myMax);

Then in the chart script

mscale.setMin( NumberDataElementImpl.create(parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("mymin")) );

mscale.setMax( NumberDataElementImpl.create( parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("mymax")) );

Re: Dynamic dial chart scale [message #949908 is a reply to message #949392] Fri, 19 October 2012 12:34 Go to previous message
Tobbi Filteau is currently offline Tobbi FilteauFriend
Messages: 10
Registered: September 2011
Junior Member
Hot damn! It's working Very Happy. Though there were some typos in your code, Globabl and a few missing parenthesis). Here's the corrected version:

So, on the onCreate script of the row:

var myMin = this.getRowData().getColumnValue("MyBinding1");
var myMax = this.getRowData().getColumnValue("MyBinding2");
reportContext.setPersistentGlobalVariable("myMin", myMin);
reportContext.setPersistentGlobalVariable("myMax", myMax);

and in the beforeGeneration:

function beforeGeneration( chart, icsc )
	//Not sure if all these imports are necessary, but at this point
	//I don't really care.

	importPackage( );
	importPackage( );
	importPackage( );
	importPackage( );
	importPackage( );

	seriesDef = chart.getSeriesDefinitions().get(0);
	meter1 = seriesDef.getSeriesDefinitions().get(0).getRunTimeSeries().get(0);
	mdial = meter1.getDial( );
	mscale = mdial.getScale( );

	mscale.setMin( NumberDataElementImpl.create( parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("myMin")) ));
	mscale.setMax( NumberDataElementImpl.create( parseInt(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("myMax")) ));

Thanks a LOT for this information, I was really starting to lose some hair on this one.

Previous Topic:Border for Table Detail columns
Next Topic:font in dynamic content of text
Goto Forum:

Current Time: Mon Jan 30 01:52:08 GMT 2023

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

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

Back to the top