Dynamic Marker Line based on Data

micajblock
edited February 11, 2022 in Analytics #1
I built this example based on requirement from a forum post.<br />
    <br />
  1. I am using the Drop-Detail on the cell with the chart (that is why it looks like the chart and details are together).<br />
  2. I created a marker<br />
  3. I created a page variable to store data.<br />
  4. I dynamically adjusted the marker based on the data.<br />
<br />
The code is in 2 places. The onPageBreak event of the Country report item (I am setting the page variable):
if (this.getRowData().getColumnValue("COUNTRY")  == "UK") {
	vars&#91;"currentMarker"] = 5;
}
else {
	vars&#91;"currentMarker"] = 7;
}
<br />
and then I am using the page variable in the onRender event of the chart
function beforeDrawMarkerLine( axis, markerLine, 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);
	importPackage(Packages.org.eclipse.birt.chart.util);

	var ci =icsc.getExternalContext().getScriptable().getPageVariable("currentMarker");
	markerLine.setValue(NumberDataElementImpl.create(ci));
}