score:1

Accepted answer
var svg = d3.select("#tooltip-chart")
    .append("svg")
    .attr("width", w)
    .attr("height", h)
    .append("g")
    .attr("transform", "translate(" + w/2 + "," + h/2 + ")");

Your code is just appending new svg´s to the tooltip-chart div. Delete the old one first:

var svg = d3.select("#tooltip-chart")
    .html("")
    .append("svg")
    .attr("width", w)
    .attr("height", h)
    .append("g")
    .attr("transform", "translate(" + w/2 + "," + h/2 + ")");

.html("") will remove the childrens of the div.


Related Query

More Query from same tag