Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
how can I change the series title dynamically?
mby
hi,
I want to set the series title in a chart from a parameter, do someone know the script I have to write in order to set the series title from a report parameter?
i write the following code and got an error:
function afterDataSetFilled( series, dataSet, icsc )
{
series.setSeriesIdentifier( params["NetworkPRM"].value);
}
Find more posts tagged with
Comments
mwilliams
Hi mby,
If you're just interested in changing the title of a series in the legend, you can use the following script:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
if (lerh.getLabel().getCaption().getValue() == "Series_Name"){
lerh.getLabel().getCaption().setValue("New_Title");
}
}
mby
thanks, it helps to me,
but I need also to know how can I take the title from another element in the report,e.g. from another label in the report. can I do it?
mwilliams
mby,
Where is the label you'll be pulling from? Can you set up a report with the sample database similar to what you're trying to do and attach it so I can see more of what you're trying to do? Thanks.
mby
Hello Michael!
thank you so much, I find the way to do what I want to do,
I mean to write a script that automatic take a text of a label in the report, e.g in the header of a table in the report and put the same text in the series legend.
do I write in the onPrepare of the label:
reportContext.setPersistentGlobalVariable("series1Title", this.text);
(put the text of the label as a global variable)
and then in the onRener of the chart write the following script:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.type.impl); lerh.getLabel().getCaption().setValue(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable('series1Title'));
}
this script works if you have one legend, if you have more, and you want to change the first you have to add:
if(lerh.getLabel().getCaption().getValue() == "series 1")
thanks
mby.