Kuttan Sujith
Kuttan Sujith

Reputation: 7979

Pie chart -custom event for legendItemClick-highchart

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?

Upvotes: 0

Views: 2011

Answers (2)

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

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

Upvotes: 4

Santosh
Santosh

Reputation: 885

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

Upvotes: 0

Related Questions