Multiple pie-charts in the same chart with HighCharts

前端 未结 1 1706
臣服心动
臣服心动 2020-12-20 09:55

I\'m trying to draw multiple pie-charts in the same chart with HighCharts.

JSFIDDLE DEMO

I have enabled the legend for each pi

相关标签:
1条回答
  • 2020-12-20 10:28

    I have added the below code to detect the legend item clicked.

    function(chart) {
            $(chart.series[0].data).each(function(i, e) {
                e.legendItem.on('click', function(event) {
                    var legendItem=e.name;
    
                    event.stopPropagation();
    
                    $(chart.series).each(function(j,f){
                           $(this.data).each(function(k,z){
                               if(z.name==legendItem)
                               {
                                   if(z.visible)
                                   {
                                       z.setVisible(false);
                                   }
                                   else
                                   {
                                       z.setVisible(true);
                                   }
                               }
                           });
                    });
    
                });
            });
        }
    

    Here is the jsfiddle

    0 讨论(0)
提交回复
热议问题