Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 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 Strydom
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 Strydom
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 Weathersby
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 message
Brett Strydom is currently offline Brett Strydom
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.
Previous Topic:Refresh a report
Next Topic:Data Extraction from Report Using Data Cubes
Goto Forum:
  


Current Time: Wed Sep 03 04:51:31 GMT 2014

Powered by FUDForum. Page generated in 0.01633 seconds