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

Remove this from selection #4587

Closed
pearmini opened this issue Jan 16, 2023 · 1 comment
Closed

Remove this from selection #4587

pearmini opened this issue Jan 16, 2023 · 1 comment
Assignees
Labels

Comments

@pearmini
Copy link
Member

因为参考 d3-selection,在 G2 内部的 selection 有如下的写法:

selection.each(function(d, index) {
  console.log(d); // 对应的数据
  console.log(index); // 索引
  console.log(this); // 对应的 G Element
})

这样确实会有问题:

  • 可读性较差
  • 不能使用箭头函数

所以需要移除这个设计,通过显示的参数指定。

selection.each(function(data, index, element) {
  console.log(element); // 对应的 G Element
})
@pearmini
Copy link
Member Author

fixed: #5468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants