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)
Hide legend item
Souptik
<p>Hi everybody,</p>
<p> </p>
<p>I have a chart with 3 line series- ls1, ls2 and ls3. All these 3 line series should be visible, but the legend should not show the entry for ls3 (neither the text, nor the miniature icon). How can I achieve this functionality?</p>
<p>I am using BIRT for Java 2.6.1.</p>
<p> </p>
<p>Thanks,</p>
<p>Souptik</p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>You can try this code in Chart Scripting:</p>
<p> </p>
<p><span style="font-family:'courier new', courier, monospace;">function beforeDrawLegendItem( lerh, bounds, icsc )<br>
{<br>
if(lerh.getLabel().getCaption().getValue() == "ls3"){<br>
lerh.getLabel().setVisible(false);<br>
bounds.set(0,0,0,0);<br>
} else {<br>
lerh.getLabel().setVisible(true);<br>
}<br><br>
}</span><br>
</p>
<p>where "ls3" is the name of the series you want to hide in the legend.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
mogwai
<p>I have found this solution in several topics and it appears to work for everyone except me
. I did simulate this solution in a Classic Cars report and it worked there but not in my report.<br>
<br>
I have three series named Abundance, upper and lower. I only want to see the Abundance legend.<br>
I tried to hide the legend for the 'upper' series using<br>
<br>
function beforeDrawLegendItem( lerh, bounds, icsc )<br>
{<br>
if(lerh.getLabel().getCaption().getValue() == "upper"){<br>
lerh.getLabel().setVisible(false);<br>
bounds.set(0,0,0,0);<br>
} else {<br>
lerh.getLabel().setVisible(true);<br>
}<br>
<br>
}<br>
<br>
but it is still there. I did a copy and paste of the series label to make sure there wasn't a typo. I have attached my report design but without the database a preview will be difficult.<br>
<br>
Any ideas?</p>
pricher
<p>Hi,</p>
<p> </p>
<p>I couldn't find your report. Please try attaching it again as this will help investigating your issue.</p>
<p> </p>
<p>P.</p>
mogwai
<p>I can see my report as a downloadable attachment to my comment. I will attach it again here. Hopefully you can see it.</p>
pricher
<p>Based on your design, you are creating 3 Y-Series (Abundance, upper, lower) and then you also have a Y-series grouping on row["type']. When you do this, the legend will have two levels : one level for each Y-series, then sub-levels based on the Y-Series grouping. In other words, your legend should look like this:</p>
<p> </p>
<p>Abundance</p>
<p>-- Type 1</p>
<p>-- Type 2</p>
<p>upper</p>
<p>-- Type 1</p>
<p>-- Type 2</p>
<p>lower</p>
<p>-- Type 1</p>
<p>-- Type 2</p>
<p> </p>
<p>The code you are using can only hide the sublevels, in your case, the types. Unfortunately, I have not found a way to detect and hide the Y-Series labels. Maybe someone else will know.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>P.</p>
mogwai
<p>I'm a bit stuck on this. I suspect no-one else will respond.</p>
<p>First question is: with what exact code can I hide the sublevels. That isn't working for me either.</p>
<p>Second: do you have any idea how I can escalate this?</p>
<p> </p>
<p>I really appreciate your help Pierre. This certainly isn't the first time you have assisted me.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>The code that you have been using should hide the sublevel. In the attached example, the chart is defined with 2 Y-Series (Series 1 and Series 2), an X-Axis Category based on Year, and an optional Y-Series Grouping based on Product Line. The code hides the legend entries for 'Ships' and as you can see, the two entries have been removed:</p>
<p>
mogwai
<p>I see how this works. It hides the grouping level in both series, which wouldn't work for me at all. Thanks Pierre. I will create a new post and use your report as an example.</p>