antvis/G2

Remove this from selection #4587

pearmini posted onGitHub

因为参考 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
})

posted by pearmini over 1 year ago

Fund this Issue

$0.00
Funded

Pull requests