我的Highchart如下所示,是否有一种方法可以在图例悬停时显示工具提示,就像我们在切片上悬停时一样。
https://plnkr.co/edit/yzXLz7AIDoWa1Pzxxl4k?p=preview

我的工具提示代码:

tooltip: {
    positioner: function(x, y){
         var center = this.chart.series[0].center;
         console.log(this, arguments);
         return { x: center[0] - x/2, y: center[1] + y/2 };
    },
    formatter: function() {
         return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage*100)/100 + ' %';
    }
}

最佳答案

您已经在代码中添加了引导程序,因此请使用Bootstrap tooltip并在图表onload函数中添加以下代码,

var legend = chart.legend;
for (var i = 0, len = legend.allItems.length; i < len; i++) {
   (function(i) {
       var t=legend.allItems[i],
           content= '<b>'+ t.name +'</b>: '+ Math.round(t.percentage*100)/100 + ' %';
           jQuery($(t.legendItem.element)).tooltip({title:content,html:true});
   })(i);
}


Plnkr Demo

09-26 22:13
查看更多