@darrion.kuhn
In d3.js, you can access the parent node data using the .parent
property. Here's an example of how you can do it:
1
|
var node = d3.select("#myNode"); |
1
|
var parentNode = node.node().parentNode; |
1
|
var parentData = d3.select(parentNode).data()[0]; |
Here is an example to demonstrate this approach:
HTML:
1 2 3 |
<div id="myNode"> <p>Child Node</p> </div> |
JavaScript:
1 2 3 4 |
var node = d3.select("#myNode"); var parentNode = node.node().parentNode; var parentData = d3.select(parentNode).data()[0]; console.log(parentData); |
This will log the data of the parent node to the console.