highcharts - Highcharts Sankey Charts中链接和节点的不同工具提示文本
问题描述
我有一个 Highcharts sankey 图,并且希望将鼠标悬停在节点上时的工具提示文本与链接文本不同。当我只对工具提示使用 formatter() 方法时,我得到了我想查看的链接文本,而不是节点。除了 formatter() 方法之外,我还尝试使用 nodeFormatter() 方法来代替它,但这完全覆盖了我试图对链接执行的操作。
var chart = Highcharts.chart('chart_container', {
title: {
text: null
},
plotOptions: {
sankey: {
nodeWidth:100
}
},
tooltip:{
enabled: true,
formatter: function() {
//Return stuff here
}
},
series: [
{
type: 'sankey',
name: null,
data: migrationData.seriesData,
nodes: migrationData.nodes,
dataLabels: {
enabled: true,
},
},
],
allowPointSelect: true,
enableMouseTracking: false,
tooltip: {
nodeFormatter: function() {
//Just overwrites tooltip text for non-nodes as well
}
}
});
知道如何让节点说出“类别:数字”之类的内容以及在工具提示中包含更复杂细节的链接吗?
解决方案
您可以使用pointFormatter
和nodeFormatter
功能:
series: [{
...,
tooltip: {
nodeFormatter: function() {
return 'some text for node'
},
pointFormatter: function() {
return 'some text for link'
}
}
}]
现场演示: https ://jsfiddle.net/BlackLabel/romtnqx5/
API参考:
https://api.highcharts.com/highcharts/series.sankey.tooltip.pointFormatter
https://api.highcharts.com/highcharts/series.sankey.tooltip.nodeFormatter
推荐阅读
- javascript - 如何通过不同的标准访问、合并和收集嵌套数据结构中的数组值?
- python - Heroku PermissionError:[Errno 13] 权限被拒绝
- reactjs - 重新加载时的空白页面(意外的令牌'<'”:Firebase 托管
- excel - 将特定单元格从范围复制到新的工作表范围
- amazon-web-services - 如何定义 EMR 客户端运行作业流所需的角色?
- javascript - 有没有办法将数组中的项目用作布尔值?节点.js
- visual-studio - Visual Studio 2022 更改了我的系统字体
- google-chrome - Chrome 浏览器:用浮动窗口覆盖网页广告的扩展程序?
- r - 如何查看 igraph 包中函数背后的 C 代码?
- mysql - 无法连接到 mysql 我在做什么错?