Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Hide Legend Entry
Arne79
Hi,<br />
i have the following problem. i have a chart with two y-series. if the second series is showing should depend on the value of report parameter. To hide the series works fine.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc )
{
var p = icsc.getExternalContext().getScriptable().getParameterValue("withmax");
if(p == 0){
yAxis2.getSeriesDefinitions().get(0).getSeries().get(1).setVisible(false);
}
}
</pre>
<br />
The problem is that the entry in the legend for this series is still showing. How can i hide the entry in the legend? Sorry if someone also made this question but i have found nothing that works.
Find more posts tagged with
Comments
mwilliams
Hi Arne79,
You can hide the label for the legend in the chart script. You can also hide the color box and set its width to 0 so you don't see the border. It looks like you're hiding the series based on a parameter. If this is the case, you might just be able to drop the series from the chart in the beforeFactory rather than just hiding it.
Arne79
Hi,<br />
can you tell me how can i hide or drop the legend entry. i know how can i hide the label but then the seperator and the symbol for the series is still showing. i don?t know how i can access the the items of a legend.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawLegendItem( lerh, bounds, icsc )
{
var s = icsc.getExternalContext().getScriptable().getParameterValue("withmax");
if (s == 0){
if (lerh.getLabel().getCaption().getValue() == "Maximum"){
lerh.getLabel().setVisible(false);
}
}
}
</pre>
mwilliams
Arne,
Check out this post from the devShare. It should show you the way to hide the legend item.
Arne79
Hi, <br />
<br />
i have still a problem with a legend entry. In my former problem i had a chart with two series (Maximum and Average). depending on a report parameter i invisible the second series (Average) with its legend entry with the following code.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawLegendItem( lerh, bounds, icsc )
{
var s = icsc.getExternalContext().getScriptable().getParameterValue("withaverage");
if (s == 0){
if (lerh.getLabel().getCaption().getValue() == "Maximum"){
lerh.getLabel().setVisible(false);
bounds.setHeight(0);
bounds.setWidth(0);
}
}
}
</pre>
<br />
That works but the seperator was still shown so i made i invisible:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc ){
...
chart.getLegend().getSeparator().setVisible(false);
...
}
</pre>
<br />
But now i have four series and want make one invisible (first). when i want to do like above all legend entiries are dissapear and i do not know why. The next problem is that i cannot hide the seperator like above.
mwilliams
try adding an "else" to your "if":
else{
lerh.getLabel().setVisible(true);
}
See if that helps.