score:4

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

More Query from same tag