VChart icon indicating copy to clipboard operation
VChart copied to clipboard

[Bug] 监听事件触发不生效

Open ZhangTomLiang opened this issue 1 year ago • 3 comments

如何在area图标上注册事件,比如移入不同的markArea,就触发事件,不知道怎么去获取移入当前的这条markarea数据。

image

ZhangTomLiang avatar Sep 12 '24 10:09 ZhangTomLiang

@ZhangTomLiang 现在怎么监听事件的? 事件监听相关文档: https://www.visactor.io/vchart/api/API/event

e.node.getDatum() 试试

xile611 avatar Sep 13 '24 06:09 xile611

不行啊

chart.on('click', async (e) => { console.log(e.node.getDatum()) })

image

ZhangTomLiang avatar Sep 14 '24 02:09 ZhangTomLiang

不行啊

chart.on('click', async (e) => { console.log(e.node.getDatum()) })

image

加一下判断

chart.on('click', (e) => {
const element = e?.item;

if (element && element.mark.markType === 'area') {
  console.log(element.getDatum())
}
})

xile611 avatar Sep 18 '24 08:09 xile611

@ZhangTomLiang 使用上述方法测试一下,如果还是有问题,可以新开issue

xile611 avatar Oct 21 '24 04:10 xile611