I'd like to deal with overlapping SVG elements in D3.js using this method from StackOverflow.
However, due to the nature of my code, I want to use a D3 selector rather than this
to re-add the element to the DOM. My question is: how can I use a D3 selector to get the relevant node?
This is how the original example does it:
this.parentNode.appendChild(this);
This is my attempt, which fails with "Uncaught TypeError: Cannot call method 'appendChild' of undefined":
var thisNode = d3.select("#" + id);
thisNode.parentNode.appendChild(thisNode);
This JSFiddle (adapted from the original example) demonstrates the problem: http://jsfiddle.net/cpcj5/
How is my D3 selection different from the this
in the original example? I tried using thisNode.node().parentNode.appendChild(thisNode)
but that also failed.