Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slowing down link animation in D3 force layout

In a force layout, I'd like to slow down the animation when two distant nodes are linked.

For example: if I have 2 nodes that are 400px apart and a link is established between them (after the inital tick has completely cooled down), I'd like to link to start at 400px and then animate down towards say 100 (or as standard link distance is set).

like image 407
greenafrican Avatar asked Jan 25 '26 21:01

greenafrican


1 Answers

You can set the linkStrength to a lower value to make the linking less abrupt. Like so:

force.linkStrength(0.1);

linkStrength is a value between 0 and 1. https://github.com/mbostock/d3/wiki/Force-Layout#linkStrength

like image 166
Donderbos Avatar answered Jan 28 '26 21:01

Donderbos