Fix bug divide by 0 by adding jiggle

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-31 15:59:00 +00:00
parent 8422175f0a
commit e700df5059
3 changed files with 7 additions and 7 deletions

View File

@@ -22,7 +22,7 @@ export default function(links) {
for (var k = 0, n = nodes.length, source, target, i, j, x, y, l; k < iterations; ++k) {
// For each link
for (i = 1; i < n; i++) for (j = 0; j < i; j++) {
// jiggle so it wont divide / multiply by zero after this
// jiggle so l won't be zero and divide by zero error after this
source = nodes[i];
target = nodes[j];
x = target.x + target.vx - source.x - source.vx || jiggle();