Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Conditional Labels for Value (Y) series
Conditional Labels for Value (Y) series [message #635100] Mon, 25 October 2010 15:57 Go to next message
Garey Smiley is currently offline Garey SmileyFriend
Messages: 13
Registered: July 2009
Junior Member
I'm trying to figure out how to have conditional labels for "Value (Y) series" in a Percent Stacked bar chart. I have lots of values in the bar and only want to label those items that are more than X percent.
Re: Conditional Labels for Value (Y) series [message #635123 is a reply to message #635100] Mon, 25 October 2010 16:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Add a beforeDrawDataPoint script like:

function beforeDrawDataPointLabel( dph, label, icsc )
{

if( dph.getPercentileOrthogonalValue() < 0.25 ){
label.setVisible(false);
}else{
label.setVisible(true);
}
}

0.25 is 25% on the label.

Jason

On 10/25/2010 11:57 AM, Garey Smiley wrote:
> I'm trying to figure out how to have conditional labels for "Value (Y)
> series" in a Percent Stacked bar chart. I have lots of values in the bar
> and only want to label those items that are more than X percent.
Re: Conditional Labels for Value (Y) series [message #635143 is a reply to message #635123] Mon, 25 October 2010 18:21 Go to previous messageGo to next message
Garey Smiley is currently offline Garey SmileyFriend
Messages: 13
Registered: July 2009
Junior Member
Thanks! That worked perfectly.
Re: Conditional Labels for Value (Y) series [message #946577 is a reply to message #635100] Tue, 16 October 2012 10:00 Go to previous messageGo to next message
Saurabh Puri is currently offline Saurabh PuriFriend
Messages: 10
Registered: February 2012
Junior Member
Hi Jason,

I am trying to display values on the stacked bar chart using "value (Y) series" - show label option.
As some of the stacks are smaller in height which makes the values overlap. Is there any way out??

Please help.
Thanks

[Updated on: Tue, 16 October 2012 10:01]

Report message to a moderator

Re: Conditional Labels for Value (Y) series [message #947390 is a reply to message #946577] Wed, 17 October 2012 03:40 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You could always bump the labels to the left or right. You could even alternate the bump.

crcnt=0;
function beforeDrawDataPointLabel( dph, label, icsc )
{
if( crcnt == 0 ){
currl = label.getInsets().getLeft();
label.getInsets().setLeft(currl-8);
}
if( crcnt == 1 ){
currl = label.getInsets().getLeft();
label.getInsets().setLeft(currl+8);
}
crcnt++;
if(crcnt > 1 )crcnt=0;


}

Jason
Re: Conditional Labels for Value (Y) series [message #955146 is a reply to message #947390] Tue, 23 October 2012 14:54 Go to previous messageGo to next message
Saurabh Puri is currently offline Saurabh PuriFriend
Messages: 10
Registered: February 2012
Junior Member
Thanks a lot for the solution.

But i have another problem which was not solved even if i move the label out.
Somehow the values of two or more stacks overlap. Please refer the attached image.

Is there any way out?

Also is there any way where i can put a condition of height

if (height_of_piece_of_stack >= smvalue)
{display label}
else
{not}


Thanks again

Saurabh
  • Attachment: overlap.jpg
    (Size: 33.93KB, Downloaded 327 times)
Re: Conditional Labels for Value (Y) series [message #955665 is a reply to message #955146] Wed, 24 October 2012 00:19 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Did you try using the above code? Or if that inset was not enough, increasing the variance by a few. Like, use 12 instead of 8. In the image, it doesn't appear that you're using this code at all. If you want to hide the label if it's below a certain value, you can do this:

function beforeDrawDataPointLabel( dph, label, icsc )
{
if(dph.getOrthogonalValue() < minValueYouWantToShow){
label.setVisible(false);
}
}

Hope this helps.


Michael

Developer Evangelist, Silanis
Re: Conditional Labels for Value (Y) series [message #956180 is a reply to message #955665] Wed, 24 October 2012 09:53 Go to previous messageGo to next message
Saurabh Puri is currently offline Saurabh PuriFriend
Messages: 10
Registered: February 2012
Junior Member
Hi,

I tried using the code but the problem is not solved even if i increase the variance.
Variance will make the values to shift more towards left but the overlap of labels for one stack still happens. Can i alternate the label bumps of the same stack??

Also, because my data values varies, can one compare some way the relative value (like percentages) to disable/enable label display.

function beforeDrawDataPointLabel( dph, label, icsc )
{
if(value<some_percent){
label.setVisible(false);
}
}

Thanks in Advance
Saurabh

[Updated on: Wed, 24 October 2012 09:59]

Report message to a moderator

Re: Conditional Labels for Value (Y) series [message #958123 is a reply to message #956180] Thu, 25 October 2012 19:32 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

The inset code is made to alternate which direction the label goes. The crcnt should alternate between 0 and 1, as you encounter each label. This is why one of the statements is currl - 8 and one is currl + 8.

As for the hiding a section of a bar based on its percentage of the stacked bar, you'd probably be dealing with a little bit more complicated script. The percentage value you can get from dph would be the percentage of a bar section across the optional grouping, which is spread across the different bars. It doesn't tell you the percentage of the current section of the stack it's in. That may just be my chart sample I'm working with though. The way I see it, you'd have to use the afterDataSetFilled script to figure out the total for each bar, then in the dataPointLabel script, you'd figure the percentage based on the bar's value. I could be wrong though. Hope this helps. Smile


Michael

Developer Evangelist, Silanis
Re: Conditional Labels for Value (Y) series [message #1821898 is a reply to message #947390] Fri, 21 February 2020 21:13 Go to previous message
Thrivikram Chamala is currently offline Thrivikram ChamalaFriend
Messages: 1
Registered: February 2020
Junior Member
Hi,

Thank you for the code and it helped my issue to some extent.
I have to hide categories or labels with zero slice values.
I'm able to hide the value in the chart but under category labels I can hide label name but not square or radial button.


Please refer to the attachments for your reference.
Before and After images.
In the after image, I have to hide the square button in the chart.

-Vikram
  • Attachment: After.png
    (Size: 36.69KB, Downloaded 63 times)
  • Attachment: Before.png
    (Size: 37.56KB, Downloaded 65 times)
Previous Topic:bar chart not showing chart if data is missing values
Next Topic:Hyperlink not working as intended
Goto Forum:
  


Current Time: Tue Apr 16 14:06:13 GMT 2024

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

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

Back to the top