Pie chart -custom event for legendItemClick-highchart

我是研究僧i 提交于 2019-12-12 03:04:54

问题


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?


回答1:


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);
        });
    });



回答2:


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



来源:https://stackoverflow.com/questions/16092030/pie-chart-custom-event-for-legenditemclick-highchart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!