Setting BIRT chart title dynamically

January 13th, 2010 | Tags: ,

It is possible to set the title of a chart dynamically, for example based on parameter values, using a little bit of scripting. The example below assumes that two parameters are defined (“Year” and “Month” with values such as “2010” and “Jan”).


function beforeGeneration( chart, icsc )
{
    var sYear = icsc.getExternalContext().getScriptable().getParameterValue( "Year" );
    var sMonth = icsc.getExternalContext().getScriptable().getParameterValue( "Month" );
    var sTitle = "Chart for " + sMonth + " " + sYear;
    chart.getTitle().getLabel().getCaption().setValue( sTitle );
}

The title of the chart will be set dynamically based on report parameter values.

  1. arod
    July 15th, 2010 at 18:55
    Reply | Quote | #1

    Another option for printing parameters is using a dynamic text element and insert there something like params[“my_param_name”]. Just in case someone want/need to use this approach…