How to get data of parent node in d3.js

后端 未结 3 1587
北恋
北恋 2020-12-14 14:52

I am doing nesting in D3 and in a nested element, I need to reach data object on its parent.

Right now I am doing

d3.select(this).node().parentNode._         


        
3条回答
  •  甜味超标
    2020-12-14 15:13

    d3.select(this).node() is the same as just this in the context of a function passed to a D3 selection. You could rework it like this d3.select(this.parentNode).datum() and get the correct value back without having to use the ugly double-underscore property.

提交回复
热议问题