Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用getEngine创建自定义label内容时,on回调的入参中data为undefined #3469

Closed
luhaifeng666 opened this issue Jun 9, 2021 · 3 comments

Comments

@luhaifeng666
Copy link

  • G2 Version: 4.1.16

  • Platform: Chrome

  • Mini Showcase(like screenshots):
    image

  • CodePen Link:

在使用getEngine创建自定义label时,添加label的点击事件:chart.on('label:click', ev => { console.log(ev.data) }), 此时的data返回的是undefined。

@hustcc
Copy link
Member

hustcc commented Jun 11, 2021

可以看看 ev 中的 target 中是有对应的数据的。

@luhaifeng666
Copy link
Author

可以看看 ev 中的 target 中是有对应的数据的。

target中确实有数据,但是那个数据不完整,不能返回label对应的所有原始数据,而返回的是点击区域的数据。
比如我点击“事例7”,返回的就是“事例7”以及其他相关信息,但是拿不到“事例7”对应的数值。

@hustcc
Copy link
Member

hustcc commented Oct 8, 2021

可以通过拿到的 “事例7” 去原始数据中找到自己要的数据。因为图形和 label 的绘制是基本分离的,所以有一定的隔离。

@hustcc hustcc closed this as completed Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants