score:1

Accepted answer

You need to add the update functions for the circles and links.

Since you only had add and remove, the elements were being added and removed properly, but when an element needed to be updated, nothing was being done. By adding the update functions for circles and links when anything changes they will be "updated" to their new position.

// ** UPDATE CIRCLES ***
node.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })

// *** UPDATE LINK ***
link.attr("d", diagonal);

Here is the corrected fiddle: http://jsfiddle.net/t0mhsauf/15/

Hope this helps.


Related Query

More Query from same tag