How to modify highcharts legend item click event?

前端 未结 2 1666
我在风中等你
我在风中等你 2020-12-13 23:33

I need to modify click event on highcharts legend items. Highcharts demo http://www.highcharts.com/demo/line-basic . I want for example: first action will be some alert and

2条回答
  •  暖寄归人
    2020-12-14 00:07

    For me, the legendItemClick event had to be for the series, not the line. E.g.:

    plotOptions: {
            series: {
                events: {
                    legendItemClick: function(event) {
                        var visibility = this.visible ? 'visible' : 'hidden';
                        if (!confirm('The series is currently '+ 
                                     visibility +'. Do you want to change that?')) {
                            return false;
                        }
                    }
                }
            }
        },
    

    Example from Highcharts: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/plotoptions/series-events-legenditemclick/

提交回复
热议问题