Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Legend label for series when grouped by key
Legend label for series when grouped by key [message #731005] Thu, 29 September 2011 17:01 Go to next message
Prashant Jha is currently offline Prashant JhaFriend
Messages: 18
Registered: September 2011
Junior Member
I am having this datetime chart in which I have grouped the y axis data by ID column. Thus the chart automatically creates all the requisite series. Now ID column in the legend list doesn't go for great viewing. So I want to replace the ID with its corresponding name. But there seems no way to do it Sad

I even tried a data cube. In it one can specify a display field for key field. So for ID key field, I had display field of associated text and all was good until I realized that chart is not picking up date time group as date time but as text!! And I cannot change the text to datetime. So though the legend shows fine, since the x axis is now text in chart, it is not scaled properly for one.

I will appreciate your help.
Re: Legend label for series when grouped by key [message #731019 is a reply to message #731005] Thu, 29 September 2011 17:37 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is there anyway you can share a sample report with the issue that we can
run? For example create a scripted data source and hard code some
values and add your chart. If you can post the report.

Jason

On 9/29/2011 1:01 PM, pkj5ue wrote:
> I am having this datetime chart in which I have grouped the y axis data
> by ID column. Thus the chart automatically creates all the requisite
> series. Now ID column in the legend list doesn't go for great viewing.
> So I want to replace the ID with its corresponding name. But there seems
> no way to do it :(
> I even tried a data cube. In it one can specify a display field for key
> field. So for ID key field, I had display field of associated text and
> all was good until I realized that chart is not picking up date time
> group as date time but as text!! And I cannot change the text to
> datetime. So though the legend shows fine, since the x axis is now text
> in chart, it is not scaled properly for one.
>
> I will appreciate your help.
Re: Legend label for series when grouped by key [message #731042 is a reply to message #731019] Thu, 29 September 2011 18:42 Go to previous messageGo to next message
Prashant Jha is currently offline Prashant JhaFriend
Messages: 18
Registered: September 2011
Junior Member
Yeah, I will do that. But meanwhile, I was thinking if

function beforeDrawLegendItem( lerh, bounds, icsc )
{
lerh.getLabel().setCaption(dataSetRow["TAG"]);
}
would work by looking up in dataset. But apparently dataset is not valid in the context of function.
Re: Legend label for series when grouped by key [message #731055 is a reply to message #731042] Thu, 29 September 2011 18:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

No it is not, but if Tag is already part of the chart data I can show
you how to get it. If it is not you can always put it in a global
variable and get it from script. Tell me which is your scenario and I
will explain how to do it.

Jason

On 9/29/2011 2:42 PM, pkj5ue wrote:
> Yeah, I will do that. But meanwhile, I was thinking if
> function beforeDrawLegendItem( lerh, bounds, icsc )
> {
> lerh.getLabel().setCaption(dataSetRow["TAG"]);
> }
> would work by looking up in dataset. But apparently dataset is not valid
> in the context of function.
Re: Legend label for series when grouped by key [message #731169 is a reply to message #731055] Fri, 30 September 2011 07:37 Go to previous messageGo to next message
Prashant Jha is currently offline Prashant JhaFriend
Messages: 18
Registered: September 2011
Junior Member
I have attached the report with a scripted data source. Report has two chart instances, one using a data set and the other data cube made from data set.
In first example, I was unable to change the series label from id to a name from that dataSetRow.
In the second chart example, though series label can be changed by having a different display text for id column, the x series is taken as text. I cannot change it to time Sad
Re: Legend label for series when grouped by key [message #731306 is a reply to message #731169] Fri, 30 September 2011 15:10 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can always uses a hidden table to load up a hashmap with key value
pairs and then use this map in the beforeDrawLegendItem to lookup the
new value. Have a look at the attached example. Notice the table is
hidden and I use an oncreate script on the table detail row to load up
the hm and then uses a beforeDrawLegendItem script to read it.

Jason

On 9/30/2011 3:37 AM, pkj5ue wrote:
> I have attached the report with a scripted data source. Report has two chart instances, one using a data set and the other data cube made from data set.
> In first example, I was unable to change the series label from id to a name from that dataSetRow.
> In the second chart example, though series label can be changed by having a different display text for id column, the x series is taken as text. I cannot change it to time :(
Re: Legend label for series when grouped by key [message #731372 is a reply to message #731306] Fri, 30 September 2011 18:45 Go to previous messageGo to next message
Prashant Jha is currently offline Prashant JhaFriend
Messages: 18
Registered: September 2011
Junior Member
Thanks Jason.
I worked on Sql Server Reporting Services a couple of years back. From what I see in birt it feels like a different world with enormous possibilities. Of course I can't overstate the nightmare SSRS had become for anything custom:)
I wish to gain more insight of scripting and function and variable scope and age. If you could suggest some sources.
Thanks again.
Re: Legend label for series when grouped by key [message #731395 is a reply to message #731372] Fri, 30 September 2011 20:01 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Check

http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php

There are a lot of materials on birt-exchange.org.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/339-birt-advanced-report-and-chart-scripting-examples/

You also can check birtworld.blogspot.com. We have a lot scripting
articles posted there.
http://birtworld.blogspot.com/2010/02/birt-crosstab-scripting.html
http://birtworld.blogspot.com/2010/08/birt-charting-scripting-overview.html

We also have several chapters on scripting in the Integrating and
Extending BIRT 3rd edition:
http://www.amazon.com/Integrating-Extending-BIRT-Eclipse-ebook/dp/B005GVFKKS/ref=tmm_kin_title_0?ie=UTF8&m=AG56TWVU5XWC2&qid=1317323690&sr=8-2

Jason

On 9/30/2011 2:45 PM, pkj5ue wrote:
> Thanks Jason. I worked on Sql Server Reporting Services a couple of
> years back. From what I see in birt it feels like a different world with
> enormous possibilities. Of course I can't overstate the nightmare SSRS
> had become for anything custom:)
> I wish to gain more insight of scripting and function and variable scope
> and age. If you could suggest some sources.
> Thanks again.
Re: Legend label for series when grouped by key [message #798165 is a reply to message #731005] Tue, 14 February 2012 10:34 Go to previous message
Nikola Baranov is currently offline Nikola BaranovFriend
Messages: 6
Registered: February 2012
Junior Member
I did in my report next.

The put into Y series Grouping the expression: row["TB_GROUP_ID"]+"|"+row["GROUP_NAME"]

And I added the script for the chart:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
S = lerh.getLabel().getCaption().getValue();
S = S.substr(S.indexOf("|")+1);
lerh.getLabel().getCaption().setValue(S);
}


All works wonderful.
Previous Topic:Report Legend
Next Topic:Change Chart Grouping unit and interval
Goto Forum:
  


Current Time: Fri Dec 19 22:52:09 GMT 2014

Powered by FUDForum. Page generated in 0.02378 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software