How can I remove or replace SVG content?
Setting the id attribute when appending the svg element can also let d3 select so remove() later on this element by id :
var svg = d3.select("theParentElement").append("svg")
.attr("id","the_SVG_ID")
.attr("width",...
...
d3.select("#the_SVG_ID").remove();
If you want to get rid of all children,
svg.selectAll("*").remove();
will remove all content associated with the svg.
Here is the solution:
d3.select("svg").remove();
This is a remove
function provided by D3.js.