highcharts pie chart multiple sections selection

a 夏天 提交于 2019-12-12 12:32:01

问题


I want to select multiple sections in pie chart. And section should be unselected on clicking, if it is already selected.

I found an example here. But in this case, only one section can be selected and selected ones get deselected on clicking on any other section.

Similarly, I found another example [

$(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
        }]
    }]
}); });

]2. In this case multiple sections can be selected but they are not deselected on clicking again.

Please help !!


回答1:


Try this solution: 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());
                    }
                }  
            }                    
        }
    }



回答2:


Shift + Mouseclick or CTRL + Mouseclick lets you select/deselect 'points'. Does the job by simply setting:

allowPointSelect : true



来源:https://stackoverflow.com/questions/23613431/highcharts-pie-chart-multiple-sections-selection

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