score:4

Accepted answer

Try to empty the axis before build the graph

function ShowGraph(data) {
    d3.selectAll('.axis').remove();
    var vis = d3.select("#visualisation"),
    //...

EDIT OK maybe I found the solution

The problem is the axis that appends every time to call the function.

So, if you add a check like so:

var hasAxis = vis.select('.axis')[0][0];

if(!hasAxis) {
   vis.append("svg:g") // add a container for the axis
   .attr("class", "x axis") // add some classes so we can style it
   .attr("transform", "translate(0," + (HEIGHT - MARGINS.bottom) + ")") // move it into position
   .call(xAxis); // finally, add the axis to the visualisation


    vis.append("svg:g")
    .attr("class", "y axis")
    .attr("transform", "translate(" + (MARGINS.left) + ",0)")
    .call(yAxis);
}

it should works


Related Query

More Query from same tag