我想在 dataLabels.formatter 函数中使用另一个条件来确定是否显示标签,而这个另一个条件需要访问一个新列表(由下面的“this.something”表示),该列表将具有完全相同的数字作为“数据”列表的元素。
series: [
{
name: 'Value',
data: [92.0, 92.0, 84.0],
dataLabels: {
enabled: true,
formatter: function() {
if (this.y > 90 && this.something == 1) { return this.y }
}
}
}
],
我该怎么做?我尝试了类似以下的方法,但没有成功:
series: [
{
name: 'Value',
data: [{
y:92.0,
something:0
}, {
y:92.0,
something:1
}, {
y:84.0,
something:0
}],
dataLabels: {
enabled: true,
formatter: function() {
if (this.y > 90 && this.something == 1) { return this.y }
}
}
}
],
最佳答案
我了解到我可以使用 this.point.something 来引用我添加的新字段。
series: [
{
name: 'Value',
data: [{
y:92.0,
something:0
}, {
y:92.0,
something:1
}, {
y:84.0,
something:0
}],
dataLabels: {
enabled: true,
formatter: function() {
if (this.y > 90 && this.point.something == 1) { return this.y }
}
}
}
],
关于javascript - 访问 Highcharts 中 dataLabels.formatter 函数中的另一个列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58550136/