Fixed Link force jiggling

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-24 21:14:09 +00:00
parent 3d55117977
commit 7c63fec0f7
2 changed files with 1 additions and 2 deletions

View File

@@ -35,7 +35,6 @@ function startLinkSimulation() {
return distanceFunction(n.source, n.target, props, norm); return distanceFunction(n.source, n.target, props, norm);
}) })
// Set the parameter for the algorithm (optional). // Set the parameter for the algorithm (optional).
.strength(1);
// Restart the simulation. // Restart the simulation.
simulation.alpha(1).restart(); simulation.alpha(1).restart();
} }

View File

@@ -45,7 +45,7 @@ export default function(links) {
x = target.x + target.vx - source.x - source.vx || jiggle(); x = target.x + target.vx - source.x - source.vx || jiggle();
y = target.y + target.vy - source.y - source.vy || jiggle(); y = target.y + target.vy - source.y - source.vy || jiggle();
l = Math.sqrt(x * x + y * y); l = Math.sqrt(x * x + y * y);
l = (l - distances[i]) / l * alpha/* * strengths[i]*/; l = (l - distances[i]) / l * alpha * strengths[i];
x *= l, y *= l; x *= l, y *= l;
target.vx -= x * (b = bias[i]); target.vx -= x * (b = bias[i]);
target.vy -= y * b; target.vy -= y * b;