highcharts饼图多个部分的选择

use*_*413 3 javascript highcharts

我想在饼图中选择多个部分。如果已选择,则应在单击时取消选择该部分。

我在这里找到了一个例子。但是在这种情况下,只能选择一个部分,而单击任何其他部分,则将选定的部分取消选择。

同样,我找到了另一个示例[

$(function(){var chart = new Highcharts.Chart({chart:{renderTo:'container',type:'pie'

    },
    plotOptions: {
        series: {
            states: {
                hover: {
                    enabled: false
                }
            },
            point: {
                events: {
                    click: function () {
                        this.graphic.attr({
                            fill: 'yellow'
                        });
                    }
                }
            }
        }
    },
    tooltip: {
        enabled: false
    },
    series: [{
        data: [{
            name: 'test',
            y: 29.9,
            color: "#CCCCCC",
            active: false
        }, {
            name: 'test2',
            y: 71.5,
            color: "#CCCCCC",
            active: false
        }, {
            name: 'test3',
            y: 106.4,
            color: "#CCCCCC",
            active: false
        }]
    }]
}); });
Run Code Online (Sandbox Code Playgroud)

] 2。在这种情况下,可以选择多个部分,但是在再次单击时不会取消选择它们。

请帮忙 !!

Paw*_*Fus 5

尝试以下解决方案:http : //jsfiddle.net/3zy8p/13/

    plotOptions: {
        series: {
            point: {
                events: {
                    click: function(event){
                        this.slice(null);
                        this.select(null, true);
                        console.log(this.series.chart.getSelectedPoints());
                    }
                }  
            }                    
        }
    }
Run Code Online (Sandbox Code Playgroud)