Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Meter Chart - Set regions at runtime from Series data(I need to figure out how to set the regions for the meter chart at runtime based on the series data.)
Meter Chart - Set regions at runtime from Series data [message #987838] Wed, 28 November 2012 10:58 Go to next message
Brett Strydom is currently offline Brett StrydomFriend
Messages: 3
Registered: November 2012
Location: Cape Town
Junior Member
Hi All,

I am new to Birt and I am having a lot of fun Smile

I am just stuck on one thing though. I have created a meter chart and managed to get it working perfectly but I have had to hard code the regions for the data sets I want to display.

So what I am trying to do now is I want to set the regions based on the datasource data so that in the event the that the data changes, it will still work according to the logic in the script basd from the dataset.

Is this possible? I am using this script to set the regions:
function beforeGeneration( chart, icsc ) {

importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

var firstAxis = chart.getSeriesDefinitions().get(0).getSeriesDefinitions().get(0).getRunTimeSeries().get(0).getDial();

var seriesdata = series.getDataSet().getValues();

var firstRange = DialRegionImpl.create();
firstRange.setFill(ColorDefinitionImpl.RED());
firstRange.setStartValue( NumberDataElementImpl.create( 0 ) );
firstRange.setEndValue( NumberDataElementImpl.create( 2 ) );
firstAxis.getDialRegions().add(firstRange);

var secondRange = DialRegionImpl.create();
secondRange.setFill(ColorDefinitionImpl.YELLOW());
secondRange.setStartValue( NumberDataElementImpl.create( 2 ) );
secondRange.setEndValue( NumberDataElementImpl.create( 5 ) );
firstAxis.getDialRegions().add(secondRange);

var thirdRange = DialRegionImpl.create();
thirdRange.setFill(ColorDefinitionImpl.GREEN());
thirdRange.setStartValue( NumberDataElementImpl.create( 5 ) );
thirdRange.setEndValue( NumberDataElementImpl.create( 12 ) );
firstAxis.getDialRegions().add(thirdRange);

}
Re: Meter Chart - Set regions at runtime from Series data [message #988262 is a reply to message #987838] Thu, 29 November 2012 08:09 Go to previous messageGo to next message
Brett Strydom is currently offline Brett StrydomFriend
Messages: 3
Registered: November 2012
Location: Cape Town
Junior Member
Hi,

i would really appreciate some help on this one Smile

Thanks
Brett
Re: Meter Chart - Set regions at runtime from Series data [message #988442 is a reply to message #988262] Thu, 29 November 2012 22:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Brett

Are you wanting the start and end numbers to come from a dataset? If so just add a table that contains the values above the chart and using the visibility property hide the table. In the table detail row's oncreate script put in something like:
var var1 = this.getRowData().getColumnValue("yourcolumnnamethathasstartnumber");
reportContext.setPersistentGlobalVariable("mystart", var1);


Then in the chart script enter something like:


var start = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("mystart");
firstRange.setStartValue( NumberDataElementImpl.create( start ) );

Do the same for end of the region as well.

Jason
Re: Meter Chart - Set regions at runtime from Series data [message #988553 is a reply to message #988442] Fri, 30 November 2012 13:36 Go to previous messageGo to next message
Brett Strydom is currently offline Brett StrydomFriend
Messages: 3
Registered: November 2012
Location: Cape Town
Junior Member
hmmm Smile Thats a clever idea! Thanks Jason. I will try that and revert back soonest.
Re: Meter Chart - Set regions at runtime from Series data [message #1763744 is a reply to message #988442] Fri, 19 May 2017 09:24 Go to previous message
Amruta Raut is currently offline Amruta RautFriend
Messages: 7
Registered: May 2017
Junior Member
Hi,
I got a error on firstRange(firstRange is undefined)
Previous Topic:genReport create pdf even when exception
Next Topic:Linking Table Sections in BIRT-Report Designer
Goto Forum:
  


Current Time: Wed Sep 25 21:38:45 GMT 2024

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

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

Back to the top