MCPcopy Create free account
hub / github.com/breck7/scroll / force

Function force

external/.d3.js:8407–8421  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8405 if (y == null) y = 0;
8406
8407 function force() {
8408 var i,
8409 n = nodes.length,
8410 node,
8411 sx = 0,
8412 sy = 0;
8413
8414 for (i = 0; i < n; ++i) {
8415 node = nodes[i], sx += node.x, sy += node.y;
8416 }
8417
8418 for (sx = (sx / n - x) * strength, sy = (sy / n - y) * strength, i = 0; i < n; ++i) {
8419 node = nodes[i], node.x -= sx, node.y -= sy;
8420 }
8421 }
8422
8423 force.initialize = function(_) {
8424 nodes = _;

Callers 1

tickFunction · 0.85

Calls 2

quadtreeFunction · 0.85
jiggleFunction · 0.85

Tested by

no test coverage detected