Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » chart: hide legend entry
chart: hide legend entry [message #1061427] Fri, 31 May 2013 14:48 Go to next message
hage Mising name is currently offline hage Mising nameFriend
Messages: 67
Registered: September 2011
Member
Hi there,

is there a possibility to hide one of several legend entries of a chart? My chart contains 3 series, one is only to visualize a threshold, there is no need to show its legend entry.

I already tried
function beforeGeneration( chart, icsc )
{	
   chart.getLegend().getChildren()...

but that always returns null (obv. because it's before the chart generation), but
function afterGeneration( gcs, icsc )
{
   gcs.getChartModel().get .getLegend().getChildren().getLegend()
}


does not help me either. Any hints appreciated.
Thx in advance,
hage
Re: chart: hide legend entry [message #1061429 is a reply to message #1061427] Fri, 31 May 2013 14:55 Go to previous messageGo to next message
hage Mising name is currently offline hage Mising nameFriend
Messages: 67
Registered: September 2011
Member
just found a hint, that beforeDrawBlock could be the solution, will try that on monday

(setting visible to false in beforedrawlegenditem does not work for me)
Re: chart: hide legend entry [message #1061528 is a reply to message #1061429] Sun, 02 June 2013 03:22 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Try this:

function beforeDrawLegendItem( lerh, bounds, icsc )
{
	if(lerh.getLabel().getCaption().getValue() == "yourSeries"){
		lerh.getLabel().setVisible(false);
		bounds.set(0,0,0,0);
	}
}


Michael

Developer Evangelist, Silanis
Re: chart: hide legend entry [message #1061697 is a reply to message #1061528] Mon, 03 June 2013 14:16 Go to previous messageGo to next message
hage Mising name is currently offline hage Mising nameFriend
Messages: 67
Registered: September 2011
Member
excellent, that does the trick. thank you very much. One addition, once the
lerh.getLabel().setVisible(false);

is called, every "following" entry label is invisible also, so i had to add an else clause like
} else {
	lerh.getLabel().setVisible(true);

which makes all but the one visible again.
Re: chart: hide legend entry [message #1062491 is a reply to message #1061697] Sat, 08 June 2013 05:26 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Great to hear! You're welcome!

Michael

Developer Evangelist, Silanis
Re: chart: hide legend entry [message #1733881 is a reply to message #1062491] Wed, 01 June 2016 19:03 Go to previous messageGo to next message
Miguel Orlans is currently offline Miguel OrlansFriend
Messages: 4
Registered: April 2016
Junior Member
This code works fine when not using Y-series grouping. Once Y-series grouping is enabled, the sub-entries for each series can be hidden with this code, but not all the legend entries for a specific series.
Does anyone have a solution to hide the entries for one or more series with Y-series grouping?
Re: chart: hide legend entry [message #1734227 is a reply to message #1733881] Mon, 06 June 2016 12:18 Go to previous message
Jörg Steffen is currently offline Jörg SteffenFriend
Messages: 3
Registered: June 2016
Junior Member
Hi Miguel,

when you are using Y-series grouping, imho you only can use a workaround. I had the same issue some time ago, and I received the following code:

function beforeDrawLegendItem( lerh, bounds, icsc )
{
	var gradient=lerh.getFill().getClass().isAssignableFrom(GradientImpl);
	if (gradient)
		{
			lerh.getLabel().setVisible(false);
			bounds.set(0,0,0,0);
		}
	else
		{
			lerh.getLabel().setVisible(true);
		}
}


You have to insert this into the onRender part of the script for your chart. After that, you have to use gradient coloring in your color palette for the serie you want to hide from legend. You can select the same color for both "ends" of the gradient but you have to use it.

In the example file I added you can see the grey trend line in the chart but hidden in the legend.

I hope this helps.

BR, Jörg
  • Attachment: example.JPG
    (Size: 66.46KB, Downloaded 510 times)
Previous Topic:Report on word changes the font
Next Topic:Possible Bug
Goto Forum:
  


Current Time: Fri Apr 26 23:19:53 GMT 2024

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

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

Back to the top