Using report parameter values in a chart title

CodeRookie
edited February 11, 2022 in Analytics #1

Good morning, All!
As the title says, I'm trying to pull in report parameter values and use them in a chart title. After searching for a while (and finding some answers on the opentext boards), I was able to piece together the following:

beforeGeneration: function(chart, icsc)
{
var month = icsc.getExternalContext().getScriptable().getParameterValue('month1');
var year = icsc.getExternalContext().getScriptable().getParameterValue('year1');
var customer = icsc.getExternalContext().getScriptable().getParameterValue('customer');
var grade = icsc.getExternalContext().getScriptable().getParameterValue('grade');
chart.getTitle().getLabel().getCaption().setValue(month + ' / ' + year + ' ' +
'Customer: ' + customer + ' ' + 'Grade: ' + grade);
}

Now, this doesn't break the report as earlier attempts did, but it doesn't modify the chart title either..... What piece am I missing?

Thanks in advance for the help!

Scott

Best Answer

  • I am using the following in my beforeFactory
    myTitle = " AS2-"+ grp + " " + params["eDate"] + " " + params["etonum"];
    reportContext.setPersistentGlobalVariable("title", myTitle);

    and this in the onRender
    function beforeGeneration( chart, icsc )
    {
    var myTitle = chart.getTitle().getLabel().getCaption().getValue();
    var title = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("title")
    chart.getTitle().getLabel().getCaption().setValue(BirtDateTime.year(BirtDateTime.addYear(BirtDateTime.today(),-1)) + " " + title +" " + myTitle)
    }

    HTH

Answers

  • I am using the following in my beforeFactory
    myTitle = " AS2-"+ grp + " " + params["eDate"] + " " + params["etonum"];
    reportContext.setPersistentGlobalVariable("title", myTitle);

    and this in the onRender
    function beforeGeneration( chart, icsc )
    {
    var myTitle = chart.getTitle().getLabel().getCaption().getValue();
    var title = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("title")
    chart.getTitle().getLabel().getCaption().setValue(BirtDateTime.year(BirtDateTime.addYear(BirtDateTime.today(),-1)) + " " + title +" " + myTitle)
    }

    HTH

  • Thanks for the info! I'll try it in a bit, and get back to you with the results.

  • Worked like a charm! Thanks again for the help!