From 72c433eb860ba8f79f161e67fdbc32e41a14cc92 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Thu, 10 Sep 2015 15:55:07 +0200 Subject: [PATCH] make sure circular layouts lots of nodes spreadout --- client/app/scripts/charts/nodes-chart.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index e1c20318f..7702b4e10 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -17,6 +17,10 @@ const MARGINS = { bottom: 0 }; +// make sure circular layouts lots of nodes spread out +const radiusDensity = d3.scale.sqrt() + .domain([12, 2]).range([2.5, 5]).clamp(true); + const NodesChart = React.createClass({ getInitialState: function() { @@ -226,8 +230,9 @@ const NodesChart = React.createClass({ const centerX = selectedLayoutNode.x; const centerY = selectedLayoutNode.y; - const radius = Math.min(props.width, props.height) / 3; const adjacentCount = adjacentLayoutNodes.length; + const density = radiusDensity(adjacentCount); + const radius = Math.min(props.width, props.height) / density; _.each(adjacentLayoutNodes, function(node, i) { const angle = Math.PI * 2 * i / adjacentCount;