select 父节点在 D3 树中的多个父节点的最简单方法
Easiest way to select parent nodes multiple parents up in the tree in D3
我正在尝试 select 树中的父级从我当前的 selection 向上四层。
做不到
d3.select(d3.select(this.parentNode)[0][0].parentNode)
最多四个级别,是否有更简单的方法来访问父级的父级或类似的?
您可以跳过嵌套选择并执行 d3.select(this.parentNode.parentNode.parentNode...etc)
,但仅此而已 - .parentNode 是唯一的方法,根据作者的说法,它是设计使然:https://groups.google.com/forum/#!topic/d3-js/mEjem7IPshY
我正在尝试 select 树中的父级从我当前的 selection 向上四层。
做不到
d3.select(d3.select(this.parentNode)[0][0].parentNode)
最多四个级别,是否有更简单的方法来访问父级的父级或类似的?
您可以跳过嵌套选择并执行 d3.select(this.parentNode.parentNode.parentNode...etc)
,但仅此而已 - .parentNode 是唯一的方法,根据作者的说法,它是设计使然:https://groups.google.com/forum/#!topic/d3-js/mEjem7IPshY