Graph contains 4 marker lines, some not needed [message #1027927] |
Wed, 27 March 2013 16:00 |
|
I'm currently using BIRT 3.7. I've got a report template that has 4 marker lines that are threshold lines. When the report is run, the query result may or may not contain all of these thresholds. Some may be null. In the case that the value is null, is there a way to not draw the line? In the template I have a working script that sets the value of each marker line under the use case where all marker lines contain valid values. importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
function beforeDrawMarkerLine( axis, markerLine, context)
{
target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("COUNTER");
if(target == 1)
{
target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MAX_THRESHOLD");
markerLine.setValue(NumberDataElementImpl.create(target));
markerLine.getLabel().getCaption().setValue("Max Red " + target);
context.getExternalContext().getScriptable().setPersistentGlobalVariable("COUNTER", "2");
}
else if(target == 2)
{
target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MIN_THRESHOLD");
markerLine.setValue(NumberDataElementImpl.create(target));
markerLine.getLabel().getCaption().setValue("Min Red " + target);
context.getExternalContext().getScriptable().setPersistentGlobalVariable("COUNTER", "3");
}
else if(target == 3)
{
/*
target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MAX_THRESHOLD_YELLOW");
markerLine.setValue(NumberDataElementImpl.create(target));
markerLine.getLabel().getCaption().setValue("Max Yellow " + target);*/
context.getExternalContext().getScriptable().setPersistentGlobalVariable("COUNTER", "4");
}
else
{
/*
target = context.getExternalContext().getScriptable().getPersistentGlobalVariable("MIN_THRESHOLD_YELLOW");
markerLine.setValue(NumberDataElementImpl.create(target));
markerLine.getLabel().getCaption().setValue("Min Yellow " + target);*/
context.getExternalContext().getScriptable().setPersistentGlobalVariable("COUNTER", "1");
}
}
Is there any way to check at this point that if the value of the threshold is null then don't draw it? I can set the global variable to a flag value and check it for the flag in another method if need be. I've been looking through some API's http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.birt.chart.doc.isv%2Fchart%2Fapi%2Forg%2Feclipse%2Fbirt%2Fchart%2Fmodel%2Fcomponent%2FMarkerLine.html but I'm still looking for a solution. Any help is appreciated.
|
|
|
Re: Graph contains 4 marker lines, some not needed [message #1028084 is a reply to message #1027927] |
Wed, 27 March 2013 20:23 |
|
why not just create the marker lines dynamically in the beforeGeneration 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 chart = icsc.getChartInstance();
var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
var base_value = icsc.getExternalContext().getScriptable().getGlobalVariable("baseline");
var target_value = icsc.getExternalContext().getScriptable().getGlobalVariable("target");
target_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(target_value));
target_ml.getLabel().getCaption().setValue("Target");
target_ml.getLineAttributes().getColor().set(32,145,245);
base_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(base_value));
base_ml.getLabel().getCaption().setValue("Baseline");
base_ml.getLineAttributes().getColor().set(0,0,0);
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04007 seconds