tooltip: {
formatter: function () {
console.log(this); // see what each slice's properties are
if (this.point.node.level == 4) {
return 'Population of <b>' + this.point.options.name +
'</b> is <b>' + this.point.options.value + '</b>';
} else {
return 'Level <b>' + this.point.node.level + '</b> has no tooltip';
}
}
}
2 回答
你可以根据切片的
level
属性得到这个 . 你可以这样做:示例jsFiddle
坦克你的答案wergled . 事实上,帮助我的是
console.log(this)
!我不知道为什么,但this
直接指代我的代码中的点 . 因为我在python中编码,我必须将js函数格式化为python字符串,这非常困难 . 所以我结束了类似的事情:它混合了python和js,很难读,但在我的情况下需要 .