Charts with date time axis use com.ibm.icu.util.Calendar. Date time parameters use java.util.Date. This example shows a report that has a date time parameter which is compared to the values of a date axis and used to add a marker line.
function afterDataSetFilled( series, dataSet, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
importPackage(Packages.com.ibm.icu.util);
//x-axis Series
if (series.eClass().getName().equals("Series"))
{
var list = dataSet.getValues();
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;
}
}
}
}
<br />
The afterDateSetFilled event is fired for every runtime series. This includes the category axis.<br />
So this line:<br />
series.eClass().getName().equals("Series")<br />
will be true for the category series. Use "BarSeries", "LineSeries" etc for others or use getSeriesIdentifier()<br />
This line:
icsc.getExternalContext().getScriptable().getParameterValue("myDtParm");
<br />
Gets the report parameter which is compared to each of the x-axis values using a the fieldDifference method of the Calendar class. When a match is found the intcountformaker global variable is set.<br />
We then just dynamically create the marker in the beforeGeneration event which is called after the afterDataSetFilled event.
function beforeGeneration( chart, icsc )
{
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);
var xAxis =chart.getAxes().get(0);
target_ml = MarkerLineImpl.create(xAxis, NumberDataElementImpl.create(intcountformaker));
target_ml.getLabel().getCaption().setValue("Target");
target_ml.getLineAttributes().getColor().set(32,145,245);
}