Accepted answer

It looks like you're adding nodes only to the DOM, not to the force layout. To recap, here's what you need to do to add nodes to the force layout.

  • Add elements to the array that the force layout uses for its nodes. This needs to be the same array that you passed in initially, i.e. you can't create a new array and pass that it if you want smooth behaviour. Modifying force.nodes() should work fine.
  • Do the same for the links.
  • Add the new DOM elements using .data().enter() with the new data.
  • No change to the tick function should be required as adding the nodes and DOM elements is done elsewhere.

After adding the new nodes/links, you need to call force.start() again to have it take them into account.

Related Query