桑基图的边的value决定了节点的宽度,所以只能传数值,但是边的模板(tooltip.formatter)只能使用a/b/c,也就是说不能使用比例,查看官方资料,自己也试着尝试过,边是没有模板的,而节点和option都有模板,但是节点的模板权重比option的高,会覆盖option的模板,导致节点和边都使用了节点的模板,所以有没有什么方式可以解决这个问题?
我不知道我使用的方式是否有错,希望指正!谢谢各位大佬们!
配置项如下
option = {
title: {
text: '桑基图'
},
tooltip: {
trigger: 'item',
triggerOn: 'mousemove',
formatter: "{b} <br/>比例:{c} {d} %"
},
series: [{
type: 'sankey',
layout: 'none',
data: [{
name: 'a',
value: '数量:' + 10 + ' \n 流量比例:' + 100 + '%',
tooltip: {
trigger: 'item',
formatter: "{b} <br/>{c}"
},
}, {
name: 'b',
value: '数量:' + 1 + ' \n 流量比例:' + 10 + '%',
tooltip: {
trigger: 'item',
formatter: "{b} <br/>{c}"
},
}, {
name: 'c',
value: '数量:' + 9 + ' \n 流量比例:' + 90 + '%',
tooltip: {
trigger: 'item',
formatter: "{b} <br/>{c}"
},
}],
links: [{
source: 'a',
target: 'b',
value: 10
},{
source: 'a',
target: 'c',
value: 90
}],
itemStyle: {
normal: {
borderWidth: 1,
borderColor: '#aaa'
}
},
lineStyle: {
normal: {
curveness: 0.5
}
}
}]
};