【发布时间】:2015-08-06 22:41:30
【问题描述】:
我创建了一个带有图表的 BIRT 报告,该图表从 oracle 数据库中获取数据。 我把图表做好了。现在我需要在图表中添加 4-5 个标记。 可以更改的标记值也存储在数据库中。
我尝试了本文中提到的脚本,并进行了一些修改http://blogs.actuate.com/birt-chart-scripting-dynamic-markers/
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.getBaseAxes()[0];
var min_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("min_val");
var ok_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("ok_val");
var great_value = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("great_val");
min_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(min_value));
min_ml.getLabel().getCaption().setValue("Minimum");
min_ml.getLineAttributes().getColor().set(255,0,0);
}
它会生成一个标记,但位置错误。 似乎没有根据 x 轴值正确标记。
这个脚本可能有什么问题?
【问题讨论】: