Highcharts-如何单击仅显示两个系列

Highcharts-如何单击仅显示两个系列,highcharts,Highcharts,我发现这个例子,一半做我需要的。我需要它来展示两个系列,而不仅仅是一个 events: { show: function () { var chart = this.chart, series = chart.series, i = series.length, otherSerie

我发现这个例子,一半做我需要的。我需要它来展示两个系列,而不仅仅是一个

events: {
                show: function () {
                    var chart = this.chart,
                        series = chart.series,
                        i = series.length,
                        otherSeries;
                    while (i--) {
                        otherSeries = series[i];
                        if (otherSeries != this && otherSeries.visible) {
                            otherSeries.hide();
                        }
                    }
                },
                legendItemClick: function() {
                    if(this.visible){
                         return false;   
                    }
                }
            }
例如:我单击系列1,看到系列1和系列2。我单击系列3,看到系列3和系列4。 系列2和4将隐藏在图例中。
可能吗?

您可以链接具有相同可见性的系列,并在legendItemClick事件中隐藏其他系列:

现场演示:


API参考:

你是我的英雄!非常感谢。
    plotOptions: {
        series: {
            events: {
                legendItemClick: function() {
                    if (this.visible) {
                        return false;
                    }

                    this.chart.series.forEach(function(s) {
                        if (s !== this && s !== this.linkedSeries[0]) {
                            s.hide();
                        }
                    }, this);
                }
            }
        }
    },
    series: [{
        data: [...],
        id: 'first'
    }, {
        data: [...],
        linkedTo: 'first'
    }, {
        data: [...],
        visible: false,
        id: 'third'
    }, {
        data: [...],
        linkedTo: 'third'
    }]