I would like to draw dynamic vertical marker line in my chart. Position of marker is available in dataset named ml_data in column ml_position. This is a dataset with one row and one column only. Is there a way how I can get value of ml_position in javascript? Currently I have the following working example:

function beforeDrawMarkerLine(axis, markerLine, icsc)
{
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
    importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
    var ml_value = 20;
    markerLine.setValue(NumberDataElementImpl.create(ml_value)) ;
}

The value is currently fixed (20). I would like to assign value of ml_position to ml_value.

有帮助吗?

解决方案

My working solution:

Create global variable "mpos" and put your chart into simple table with one row a one column. Assign dataset with ml_position to table. This is important for executing dataset onFetch script before rendering chart. Finally set following scripts:

Dataset onFetch script:

reportContext.setPersistentGlobalVariable("mpos",row["ml_position"].toString());

Chart onRender script:

function beforeDrawMarkerLine(axis, markerLine, icsc)
{
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
    importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
    var ci = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("mpos");
    markerLine.setValue(NumberDataElementImpl.create(ci)) ;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top