我正在使用highcharts网络图,我想访问数据中存在的value字段以将其悬停在节点上时显示它。我无法使用this.point.value来访问它。有人可以帮助我解决此问题吗?
这是我的代码:
tooltip: {
formatter: function () {
return '<b>' + 'Tree' + '</b><br>' +
'Name: ' + this.point.name + '<br>' +
'Description: ' + this.point.value;
}
},
series: [{
dataLabels: {
enabled: true
},
data: [
{
from: 'location',
to: 'addr',
value: 'This is sample data'
}
]
}]
答案 0 :(得分:0)
您可以使用this.point.linksFrom[0].value
访问它。检查下面发布的代码和演示。
代码:
Highcharts.chart('container', {
chart: {
type: 'networkgraph'
},
tooltip: {
formatter: function() {
var text = '<b>' + 'Tree' + '</b><br>' +
'Name: ' + this.point.name + '<br>';
if (this.point.linksFrom[0]) {
text += 'Description: ' + this.point.linksFrom[0].value;
}
return text;
}
},
series: [{
dataLabels: {
enabled: true
},
data: [{
from: 'location',
to: 'addr',
value: 'This is sample data'
}, {
from: 'point2',
to: 'addr',
value: 'Another data'
}]
}]
});