Is there a way to disable the default legend item?

Hi Highcharts Community,

I am curious to see if there is a way to disable one default legend item. For example, if there were 3 legend objects - "Accepted" "Perfect" "Prediction", is it possible to ONLY have the "Predict" legend item turned off after loading the chart without having to first click on the legend item? (Note: I don't want to exclude the legend item altogether, I just want it to be crossed out initially and still retain the functionality to re-enable the legend item after clicking on it).

Any help would be greatly appreciated.

Thank!

+3


source to share


1 answer


Yes, you can do it. In the options series

for the item you don't want to show, set the property visible

to false.

series: [{
    data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
    visible: false
}, {
    data: [144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2]
}]

      

Updated to set visibility after loading. To handle the case you are talking about where you cannot enter the visible

series property , you can do it in chart.events.load

using series.update()

:



chart: {
    events: {
        load: function () {
            this.series[0].update({
                visible: false
            });
        }
    }
},

      

Demo .

In this example, I used index 0 for the Tokyo series. You can check other properties of the series using operators if

.

+4


source







All Articles