Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Axis Markers AddLine and AddRange should support the X Axis Datatype
icon1.gif   Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1080866] Tue, 06 August 2013 13:19 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello,

I've reported a enhancement bug, see:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=414489

What is your experience with axis markers? Do you also script markers? Do you know a scriptable way to scale your axis to values not included within the data set?
I find the scripting approach is unnecessarily difficult and therefore filed the bug.

Just wanted to let you know.


Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1086305 is a reply to message #1080866] Wed, 14 August 2013 04:16 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

You can create markers in the designer or through script. You can also set the scale of your axis fairly easily through script to whatever values you'd like, you can also do this from the UI. Let me know if you need help with any of these.

Michael

Developer Evangelist, Silanis
Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1086579 is a reply to message #1086305] Wed, 14 August 2013 11:36 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
HI Michael,
So far I only found out how to add DateTime markers by script or fixed number markers through the designer.
How can I add a marker on a DateTime X-Axis using a value out of a data set or parameter? And how can I influence the axis scale with it?
I would definitely appreciate your help here!
Thank your!
Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1087319 is a reply to message #1086579] Thu, 15 August 2013 13:12 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Take a look at this example in the BIRT Exchange devShare:

BIRT Exchange DevShare - Setting Marker Line Based on Date Parameter

And this one should help with the min/max on the axis:

BIRT Exchange DevShare - Setting the Min and Max Value of the X-Axis with Scripting

Hope this helps.


Michael

Developer Evangelist, Silanis

[Updated on: Thu, 15 August 2013 13:14]

Report message to a moderator

Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1090692 is a reply to message #1087319] Tue, 20 August 2013 14:05 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Michael,

thank you again!
the scaling works fine but with the markers I experience problems with the for construct:
     for ( i=0; i     {
      var cdt = icsc.getExternalContext().getScriptable().getParameterValue("myDtParm");
      
      var yr = list[i].fieldDifference( cdt, Calendar.YEAR );
      var mn = list[i].fieldDifference( cdt, Calendar.MONTH );
      var dy = list[i].fieldDifference( cdt, Calendar.DATE );
      if( yr == 0 && mn == 0 && dy == 0){
       intcountformaker = i;
      }
     }


The report designers error message is: "missing ; after for-loop condition"
For me the for loop construction looks unfamiliar, but I'm not so close with Java Script...

Any idea?
Jan

[Updated on: Tue, 20 August 2013 14:05]

Report message to a moderator

Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1090780 is a reply to message #1090692] Tue, 20 August 2013 16:29 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Ok, I found a solution that works fine for me. It's a mashup of tutorials Smile
The marker values are stored as persistent variables in a data sets onFetch event.
reportContext.setPersistentGlobalVariable("DOvar", row["DO"]);
reportContext.setPersistentGlobalVariable("DIvar", row["DI"]);
reportContext.setPersistentGlobalVariable("cptvar", row["cpt"]);


in the charts onRender event I do the following:
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);

function beforeGeneration( chart, icsc )
{
	/* This script will change the Min and Max value of the X axis based on the value
	   for the Start and End date parameters. 
	   NB: In order to work, make sure to turn OFF the "Is Category Axis" attribute
	   in the X-Axis properties screen
	   Further the DI, cpt and DO markers gets insertet into the chart with values talen from 
	   persistent variables that are set in the Release afterFetchData event.
	*/
	
	/* Get the start and end dates from the parameters */
	var startDate_p = getPersistentGlobalVariable("DIvar");
	var cpt_value = getPersistentGlobalVariable("cptvar");   
	var endDate_p = getPersistentGlobalVariable("DOvar");
	
	/* Convert the dates from YYYY-MM-DD to DD/MM/YYYY */
	startDate = new Date((startDate_p.getMonth() + 1) + "/" + startDate_p.getDate() + "/" + (startDate_p.getYear() + 1900));
	cptDate = new Date((cpt_value.getMonth() + 1) + "/" + cpt_value.getDate() + "/" + (cpt_value.getYear() + 1900));
	endDate = new Date((endDate_p.getMonth() + 1) + "/" + endDate_p.getDate() + "/" + (endDate_p.getYear() + 1900));
	
	/* Get the X-Axis object */
	xAxisArray = chart.getBaseAxes();
	
	/* Set the Min and Max values */
	xAxisArray[0].getScale().setMin(DateTimeDataElementImpl.create(startDate));
	xAxisArray[0].getScale().setMax(DateTimeDataElementImpl.create(endDate));
	
	var chart = icsc.getChartInstance(); 
	
	di_ml = MarkerLineImpl.create(xAxisArray[0], DateTimeDataElementImpl.create(startDate));
	di_ml.getLabel().getCaption().setValue("DI");
	di_ml.getLineAttributes().getColor().set(255,102,0);
	
	cpt_ml = MarkerLineImpl.create(xAxisArray[0], DateTimeDataElementImpl.create(cptDate));
	cpt_ml.getLabel().getCaption().setValue("cpt");
	cpt_ml.getLineAttributes().getColor().set(89,89,89);
	
	do_ml = MarkerLineImpl.create(xAxisArray[0], DateTimeDataElementImpl.create(endDate));
	do_ml.getLabel().getCaption().setValue("DO");
	do_ml.getLineAttributes().getColor().set(255,204,0);    
}


The trick is to use DateTimeDataElementImpl to isnert the date values Smile

Thank you!
Re: Axis Markers AddLine and AddRange should support the X Axis Datatype [message #1091895 is a reply to message #1090780] Thu, 22 August 2013 04:49 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Sorry for the delay in response! Glad you found a solution! Smile

Michael

Developer Evangelist, Silanis
Previous Topic:Birt report displaying XML file when run
Next Topic:Hide and Show Chart
Goto Forum:
  


Current Time: Mon Dec 09 11:16:01 GMT 2019

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

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

Back to the top