... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2007-09-24

Dynamic Chart Labelling in BIRT

Here is an example script that can be attached to a BIRT chart object in order to change the labels on the chart dynamically:

importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.com.mm.managev1.report);

function beforeDrawAxisTitle(axis, label, icsc)
{
    var title = label.caption.value;
    if ("" == title) {
        if (axis.orientation === Orientation.get(Orientation.HORIZONTAL)) {
            label.caption.value = ReportUtilities.formatLongDate(getParameterValue("fromDate"))
                + " to " + ReportUtilities.formatLongDate(getParameterValue("toDate"));
        } else {
            label.caption.value = getParameterValue("currencyDesc");
        }
    }
}

function beforeRendering(gcs, icsc)
{
    var chart = gcs.chartModel;
    chart.title.label.caption.value = getParameterValue("reportingPeriodDesc") + " Capital Spending";
}

Blog Archive