score:1

Accepted answer

I've investigated your code a bit and found two mistakes you made:

1) In the code below you're creating array of nodes that lose touch with a, b and c objects

var a = { id: "a" },
  b = { id: "b" },
  c = { id: "c" },
  links = [];

var nodes = [{ id: "a" }, { id: "b" }, { id: "c" }];

You need to keep the same reference in array to the original objects:

var nodes = [a, b, c];

2) You set two wrong delay:

d3.interval(function () {
  nodes.pop(); // Remove c.
  links.pop(); // Remove c-a.
  links.pop(); // Remove b-c.
  restart();
}, 4000, d3.now());
   ^^^^^
 should be 2000 as in original example

Forked Stackblitz Example


More Query from same tag