echarts桑基图展示label,代码示例
option = {
series: {
type: 'sankey',
layout: 'none',
data: [
{ name: '类别1', value: 100, compare: 0.2 },
{ name: '类别2', value: 200, compare: -0.1 },
{ name: '类别3', value: 150, compare: 0.3 },
{ name: '类别4', value: 120, compare: -0.2 }
],
links: [
{ source: '类别1', target: '类别2', value: 50 },
{ source: '类别2', target: '类别3', value: 100 },
{ source: '类别3', target: '类别4', value: 80 }
],
label: {
show: true,
formatter: function(params) {
if (params.value > 0) {
return params.name + '(金额:' + params.value + ')\n同比:' + params.data.compare;
} else {
return params.name;
}
}
},
itemStyle: {
normal: {
borderWidth: 1,
bo