To create an svg element in memory, use document.createElementNS .
Using document.createElementNS:
// Create the svg elem var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); // Create ag elem var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); // Create a d3 Selection with the elem var d3Svg = d3.select(svg); var d3g = d3.select(g);
Add d3 selection to another d3 selection:
d3Svg.append(function(){ return d3g.node(); });
borracciaBlu
source share