Pie chart -custom event for legendItemClick-highch

2019-08-23 02:46发布

Please have a look at the jsfiddle here to understand what I am upto. To get the legendItemClick working I need to click on the colored buttons in the legend.

But in this sample even clicking on the texts(right to the colored buttons) fires legendItemClick click event.

what should I do to get the event fired even when I click on the text?

2条回答
Luminary・发光体
2楼-- · 2019-08-23 03:02

According to documentation legendItemClick is not supported in pie chart http://api.highcharts.com/highcharts#plotOptions.pie.events.legendItemClick but you can use workaround: http://jsfiddle.net/JkDrM/13/

    $(chart.series[0].data).each(function(i, e) {
        e.legendItem.on('click', function() {
            if (!e.sliced) {
                alert('hide slice');
            } else {
                alert('show slice');
            }
            e.slice(!e.sliced);
        });
    });
查看更多
在下西门庆
3楼-- · 2019-08-23 03:17

I guess you have not framed your question correctly! "// some code here to achieve my goal" what goal?

查看更多
登录 后发表回答