开发者

highcharts: disable only a single element in legend so it cannot be clicked

开发者 https://www.devze.com 2023-03-07 14:51 出处:网络
I was wondering is it possible to prevent only a one element in plot le开发者_运维技巧gend from disabling/enabling. Let\'s say I have three categories in my legend: \'car1\', \'car2\', \'car3\'. I wou

I was wondering is it possible to prevent only a one element in plot le开发者_运维技巧gend from disabling/enabling. Let's say I have three categories in my legend: 'car1', 'car2', 'car3'. I would like to show/hide only 'car2' and 'car3', while 'car1' is shown all the time.

Thank you!


If it's always a certain series that you want to disable show/hide, then within the legendItemClick return false for that series.

For example:


plotOptions: {
        series: {
            events: {
                legendItemClick: function(event) {
                    return !(this.name == 'car1');
                }
            }
        }
    },

0

精彩评论

暂无评论...
验证码 换一张
取 消