Highcharts:在饼图的数据标签上添加click事件

时间:2013-05-16 11:19:27

标签: highcharts

通过单击饼图切片打开弹出窗口,但在单击数据标签时不打开。 如何将click事件添加到饼图的数据标签?

2 个答案:

答案 0 :(得分:1)

更新到最后一个版本的Highcharts,使用点选择事件为标签和饼图切片同时触发。

plotOptions: {
    series: {
        allowPointSelect: true,
            point: {
                events: {
                    select: function() {
                        self.yourFunction(this.id);
                    }
                }
            }
    }
}

答案 1 :(得分:0)

您可以在label.formatter中使用html标签和类,然后使用jQuery添加事件。

dataLabels: {
    useHTML: true,
    formatter: function() {
        return '<div class="my-click">' + this.point.name + '</div>';
    }
}

然后:

$(".my-click").on('click', function(){ /* do somthing */ });