From 2b6149374b5ef58796807c0e4798d7f314b84bff Mon Sep 17 00:00:00 2001 From: Tom Gallacher Date: Mon, 7 Nov 2016 16:36:53 +0000 Subject: [PATCH] spikes: architecture diagram nodes repel from each other --- spikes/architecture/d3/index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spikes/architecture/d3/index.html b/spikes/architecture/d3/index.html index 0c7c0b5d..b1774319 100644 --- a/spikes/architecture/d3/index.html +++ b/spikes/architecture/d3/index.html @@ -29,9 +29,10 @@ var svg = d3.select('svg'), var color = d3.scaleOrdinal(d3.schemeCategory20); var simulation = d3.forceSimulation() + .force('charge', d3.forceManyBody().strength(() => -50).distanceMin(() => 30)) .force('link', d3.forceLink().distance(() => 200).id(function(d) { return d.id; })) - .force('charge', d3.forceManyBody()) - .force('center', d3.forceCenter(width / 2, height / 2)); + .force('collide', d3.forceCollide().radius(function(d) { return 128 + 0.5; }).iterations(2)) + .force('center', d3.forceCenter(width / 2, height / 2)) function rightRoundedRect(x, y, width, height, radius) { return 'M' + x + ',' + y // Move to (absolute)