Highcharts donut legend toggle

余生颓废 提交于 2019-12-24 01:29:13

问题


Im using a highchart pie chart to make Donut chart. The problem is when I click on legend to toggle series it only affects the clicked serie. I want to also toggle related sub series. I have tried LegenditemClick event and legendIndex , but no success so far. Here example for chart: http://jsfiddle.net/safarov/PgpRv/ When you click "facebook legend" for example, only inner pie hide.

Any help will be appreciated


回答1:


You need to set ids for inner and outer rings. Then common it by legendItemClick and search correct point by id.

legendItemClick: function () {
                    var id = this.id,
                        data = this.series.chart.series[0].data;
                    $.each(data, function (i, point) {

                        if (point.parentId == id) {
                            if(point.visible)
                                point.setVisible(false);
                            else
                                point.setVisible(true);
                        }

                    });
                }

http://jsfiddle.net/sbochan/PgpRv/4/



来源:https://stackoverflow.com/questions/17642139/highcharts-donut-legend-toggle

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