1

I'm currently using d3 for a fun interactive navigation where each node is a location on my web site. The hope is that when resizing the window or when a user drags a node around, the users can have fun seeing the interactions of the navigation.

The issue is that upon clicking on a node, I'd like to alter the node to indicate which node is currently "active". However, whenever I call a draw on the force layout to incite the modifications, the force layout "wiggles" and recomputes the locations of all nodes. Is there an easy way to change the nodes without changing their positions or recomputing their positions?

VividD
  • 10,456
  • 6
  • 64
  • 111
Mike Axiak
  • 11,827
  • 2
  • 33
  • 49

1 Answers1

0

I solved a similar issue with the following snippet:

if (force.alpha() == 0) {
    force.start();
    force.stop();
}

The if statement guards against stopping the graph layout before it is done. You call this after you've applied the new styles and attributes to your node.

Gene Golovchinsky
  • 6,101
  • 7
  • 53
  • 81