I am trying to create a beautiful tree with D3.
And for the nodes, I have an SVG template in a hidden div. But I tried to "clone" the "template" with many D3 functions, but everything did not work.
Latest javascript code:
...
var node = svg.selectAll("g.node")
.data(nodes)
.enter()
.append("svg:g")
.attr("transform",
function(d)
{
return "translate(" + d.y + "," + d.x + ")";
}
);
var template_box = d3.select("#layer1");
console.log(template_box);
node.insert(template_box);
...
A html patch:
...
<body>
<svg width="400" height="400">
<g
id="layer1"
transform="translate(-208.375,-410.5)">
<rect
...
Sincerely.
source
share