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 to pull paramer for chart legend from the data source?
Allaj
Is it possible to make titles for legend dynamic? I need to pull them from the data source or pass some kind of parameter.
One of the option that I thought it could be done by utilizing the Externalized text dialog. But the externalized text check box is disabled ( see the attached). What should I do to activate it?
Also, I was trying to find and example of how the externalized value
should look like in that window, but could not find it.
I would appreciate if you can give an example how to do it.
Or point out if there are other ways how to populate the value for the legend title
thanks a lot
P.S. I am using Version: 3.4.1 Eclipse J2EE with BIRT OS: either Vista or Windows XP
Find more posts tagged with
Comments
mwilliams
Hi Alla,
Are you talking about the "legend title" or the "series titles" in the legend? Or both?
Allaj
I would appreciate if you give the answer for both
Last time I didn't include the attachment, so I will try to do it this time
thanks
mwilliams
Alla,
I'll look into how to change both dynamically and let you know what I find.
mwilliams
Alla,
For the series title, if you leave the standard title names i.e. Series 1, Series 2, etc. You can use the following code in the chart script to check the value and change it.
function beforeDrawLegendItem( lerh, bounds, icsc )
{
if (lerh.getLabel().getCaption().getValue() == "Series 1"){
lerh.getLabel().getCaption().setValue("S1");
}
}
mwilliams
Alla,
And you can use this to set the legend title dynamically. You can probably put this in a different function in the chart script too, but I know it works in the beforeDrawBlock function.
function beforeDrawBlock( block, icsc )
{
icsc.getChartInstance().getLegend().getTitle().getCaption().setValue("Legend Title");
}
Hope this helps.
mwilliams
Oh, forgot to say how you can access external data from the chart for that. If you set persistentGlobalVariables with the values you'd like to use as your titles, you can access them with the following:
icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("pGV_name");
I'm pretty sure that's the correct call. Let me know if it doesn't work.
Allaj
Thanks a lot your response. I had tried to override the Series name, an it works. The only thing that I still do not know is how to associate the external variable with my dataset? Is it possible at all?
mwilliams
Alla,<br />
<br />
Can you explain more about what you're trying to do? i.e. How your report is set up, what your data looks like, why you need to use dynamic values from your dataSet, etc. This will help me understand more what you're doing so I can provide better answers.<br />
<br />
You can set a persistentGlobalVariable's value almost anywhere in your report design's script with reportContext.setPersistentGlobalVariable("varname", "varvalue"), including the dataSet script. So, you can set you pGV's to any value from your dataSet.<br />
<br />
Also, here is some info I found on externalized content for charts.<br />
<br />
<a class='bbc_url' href='
http://wiki.eclipse.org/BIRT/FAQ/Charts2.2#How_do_I_externalize_text_that_needs_to_retrieve_a_runtime_value_from_a_locale_specific_message_file.3F'>BIRT/FAQ/Charts2.2
- Eclipsepedia</a>
Allaj
Mike, just so you know, I do appreciate very much your help. Currently I am struggling with the following task: I have 2 series in my chart. One of the series is always the same (( the selection criteria in SQL), but the other is created based upon of the past parameter ( so basically the selected info in series 2 is compared to an average values in series 1), and since the second series selection criteria is unknown , the name of the series has to be populated dynamically. I was trying to put the name for the series in the data set, but I do not know how to get to it because I do not know how to refer to the data set?s row column in the script ( I have multiple rows that have the same value for the column that I want to use for the series number).
There is also, a second way ( better way) of doing this by assigning the parameter value to the series name, but I do not know how to do that in the script.
The ability to access the dataset row column or the report parameter in the scrip provides a great flexibility for the report design, but I just do not know how to do it.
Any examples how to do that would be greatly appreciated
thanks
Allaj
I had managed to populate the the series name dynamically from the parameted using the following code:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
if (lerh.getLabel().getCaption().getValue() == "Series 2"){
lerh.getLabel().getCaption().setValue(
icsc.getExternalContext().getScriptable().getParameterValue("RP_Group_name"));
}
}
But I had to query the database extra time to get the value for the parameter first, even though my data set for the chart contain this value, but I do not know how to get to it.
mwilliams
Alla,
Why did you need to use another query to get the value for the parameter? What all are you doing to get the value currently?