HighCharts Hide Series Name from the Legend

JavascriptHideHighchartsLegendSeries

Javascript Problem Overview


I try to solve this problem several times and give up. Now, when I have met him again, I decided to ask for some help.

I have this code for my Legend:

legend:
{
    layout: 'vertical',
    align: 'right',
    verticalAlign: 'top',
    x: -10,
    y: 100,
    borderWidth: 0,
    
    
    
    labelFormatter: function() 
    {
        if(this.name!='Series 1')
        {
            return this.name;
        }
        else
        {
            return 'Legend';
        }
    }
}

If I change the return from 'Legend' to '' the text is not shown but still there is a 'dash' on the top of the legend. If I do not use label formater function I have 'Series 1' + 'dash' like a first row in my legend. How to hide them?

Please, note my version is : Highcharts-2.0.5

This is a simple view of my legend and the dash I want to remove:

Sample Image

Javascript Solutions


Solution 1 - Javascript

If you don't want to show the series names in the legend you can disable them by setting showInLegend:false.

example:

series: [{
   showInLegend: false,				
   name: "<b><?php echo $title; ?></b>",
   data: [<?php echo $yaxis; ?>],
}]

You get other options here.

Solution 2 - Javascript

Set showInLegend to false.

series: [{
            showInLegend: false,
            name: 'Series',
            data: value                
        }]

Solution 3 - Javascript

Looks like HighChart 2.2.0 has resolved this issue. I tried it here with the same code you have, and the first series is hidden now. Could you try it with HighChart 2.2.0?

Solution 4 - Javascript

showInLegend is a series-specific option that can hide the series from the legend. If the requirement is to hide the legends completely then it is better to use enabled: false property as shown below:

legend: { enabled: false }

More information about legend is here

Solution 5 - Javascript

Replace return 'Legend' by return ''

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongotqnView Question on Stackoverflow
Solution 1 - JavascriptvkGunasekaranView Answer on Stackoverflow
Solution 2 - JavascriptMilanView Answer on Stackoverflow
Solution 3 - Javascriptzhongxiao37View Answer on Stackoverflow
Solution 4 - JavascriptZameer KhanView Answer on Stackoverflow
Solution 5 - JavascriptFouadView Answer on Stackoverflow