Fixed Link force jiggling
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user