Problem: I'm attempting to wrap text associated with Nodes of a D3 Tree but can't seem to properly assign text to HTML links.
I'm trying to use the approach of appending a "foreignObject" element, where I can then append a "div" element, in order to control width. Once I have the "div", I try to append an HTML "a" element with an HTML link and associated text.
The HTML DOM object shows that the "a" element is constructed properly but it doesn't render in the browser. It doesn't seem to work either wrapped or not wrapped by a "body" element.
Code:
nodeEnter.append("svg:foreignObject")
.attr("width", "50")
//.append("xhtml:body")
//.attr("xmlns", "http://www.w3.org/1999/xhtml")
.append("svg:div").attr("class", "NODE_LABEL_DIV")
.append("svg:a")
.attr("xlink:href", function(d) { return d.hlink; })
.text(function(d) { return d.name; })
.attr("x", function(d) { return d.children || d._children ? horizontalNodeOffset : horizontalNodeOffsetLeaf; })
.attr("dy", "-10")
.attr("fill", "Blue")
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
.style("fill-opacity", 1e-6);
My Question: What's the right way to add the HTML "a" element to the "div" within the foreignObject, so it renders properly and so I can wrap the text using the "div" element?