javascript - highcharts pie chart multiple sections selection - Stack Overflow

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

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 !!

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 !!

Share Improve this question asked May 12, 2014 at 15:47 user1744413user1744413 1151 silver badge10 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Try this solution: http://jsfiddle/3zy8p/13/

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

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

allowPointSelect : true

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745184030a4615550.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信