vue2 桑基图点击子节点, click事件不触发,有什么方法能触发,或者替代点击事件吗

关注
// 在 mounted 或更新图表的方法中
this.chartInstance.setOption(option, true);
this.$nextTick(() => {
this.chartInstance.off('click'); // 先解除旧事件,避免重复绑定
this.chartInstance.on('click', (e) => {
console.log('桑基图点击事件详情', e);
// 判断是否为桑基图子节点点击
if (e.componentType === 'sankey' && e.seriesType === 'sankey') {
console.log('子节点名称:', e.name);
console.log('子节点值:', e.value);
// 这里写你的业务逻辑
}
});
});
option = {
sankey: {
node: {
itemStyle: {
opacity: 0.8, // 节点默认透明度(确保可见可交互)
borderWidth: 1
},
emphasis: {
focus: 'self', // 悬浮时聚焦自身,强化交互感知
itemStyle: {
opacity: 1 // 悬浮时完全显示
}
}
},
link: {
itemStyle: {
opacity: 0.5 // 链接默认透明度
},
emphasis: {
itemStyle: {
opacity: 0.8 // 悬浮时链接高亮
}
}
},
// 其他配置(如数据、布局等)
}
};