Skip to main content



      Home
Home » Archived » BIRT » Conditional Labels for Value (Y) series
Conditional Labels for Value (Y) series [message #635100] Mon, 25 October 2010 11:57 Go to next message
Eclipse UserFriend
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 12:55 Go to previous messageGo to next message
Eclipse UserFriend
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 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Thanks! That worked perfectly.
Re: Conditional Labels for Value (Y) series [message #946577 is a reply to message #635100] Tue, 16 October 2012 06:00 Go to previous messageGo to next message
Eclipse UserFriend
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 06:01] by Moderator

Re: Conditional Labels for Value (Y) series [message #947390 is a reply to message #946577] Tue, 16 October 2012 23:40 Go to previous messageGo to next message
Eclipse UserFriend
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 10:54 Go to previous messageGo to next message
Eclipse UserFriend
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 363 times)
Re: Conditional Labels for Value (Y) series [message #955665 is a reply to message #955146] Tue, 23 October 2012 20:19 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Conditional Labels for Value (Y) series [message #956180 is a reply to message #955665] Wed, 24 October 2012 05:53 Go to previous messageGo to next message
Eclipse UserFriend
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 05:59] by Moderator

Re: Conditional Labels for Value (Y) series [message #958123 is a reply to message #956180] Thu, 25 October 2012 15:32 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Conditional Labels for Value (Y) series [message #1821898 is a reply to message #947390] Fri, 21 February 2020 16:13 Go to previous message
Eclipse UserFriend
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 98 times)
  • Attachment: Before.png
    (Size: 37.56KB, Downloaded 100 times)
Previous Topic:bar chart not showing chart if data is missing values
Next Topic:Hyperlink not working as intended
Goto Forum:
  


Current Time: Thu Jul 03 07:01:46 EDT 2025

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

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

Back to the top