Highcharts Sankey 图表中链接和节点的不同工具提示文本
Different ToolTip text For Links and Nodes in Highcharts Sankey Charts
我有一个 Highcharts sankey 图,希望将鼠标悬停在节点上时的工具提示文本与 link 文本不同。当我只使用工具提示的 formatter() 方法时,我得到了我想为 link 看到的文本,而不是节点。除了 formatter() 方法之外,我还尝试使用 nodeFormatter() 方法代替它,但这完全覆盖了我试图用 links.
做的事情
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
}
}
});
知道如何让节点说 "Category: number" 和 link 之类的话,以便在工具提示中包含更复杂的细节吗?
您可以使用 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
我有一个 Highcharts sankey 图,希望将鼠标悬停在节点上时的工具提示文本与 link 文本不同。当我只使用工具提示的 formatter() 方法时,我得到了我想为 link 看到的文本,而不是节点。除了 formatter() 方法之外,我还尝试使用 nodeFormatter() 方法代替它,但这完全覆盖了我试图用 links.
做的事情 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
}
}
});
知道如何让节点说 "Category: number" 和 link 之类的话,以便在工具提示中包含更复杂的细节吗?
您可以使用 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