我想根据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
键的值。但是,当我想将其添加到工具提示中时,以下代码不起作用(代码添加在原始代码中的 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 控制台。
关于javascript - Highcharts.js : get specific value from data to tooltip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41022531/