Highcharts.js : 从数据中获取特定值到工具提示

Highcharts.js : get specific value from data to tooltip

我想根据 this one 制作一个 Highcharts 圆环图。只是我的数据看起来像这样:

data: [
                {y:40, color: colors[0], name: 'yoyo'},
                {y:0, color: colors[1],  name: 'dada'},
                {y:60, color: colors[2],  name: 'sasa'}
            ]

现在:当我将 mouseOver 函数更改为:

mouseOver: function(){
                        this.series.chart.innerText.attr({text: this.name});
                    },

然后我可以从我的数据中检索 name-key 的值。但是,当我想将它添加到tooltip时,下面的代码不起作用(代码在原代码中的tooltip:之后添加):

{
      formatter: function() {
                             return '<b>'+this.name+'</b>';
                    }
                },

当我将 this.name 更改为 this.y 时,我再次获得正确的值。谁能告诉我如何检索工具提示的 this.name?非常感谢任何帮助。

通过以下方式更改格式化程序:

formatter: function() {
    return '<b>' + this.key + '</b>';
}

当您不知道您的对象如何时,请在您的代码中使用 console.log(myObject) 并检查您的 js 控制台。