From c42a98459a5e4ed92ceba6424fe9d8963ef5a773 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Thu, 24 Feb 2022 02:35:27 +0100 Subject: [PATCH] add vertical/radial force --- docs/morphisms/js/d3_visualisation.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/morphisms/js/d3_visualisation.js b/docs/morphisms/js/d3_visualisation.js index f1a1411..770b598 100644 --- a/docs/morphisms/js/d3_visualisation.js +++ b/docs/morphisms/js/d3_visualisation.js @@ -81,11 +81,14 @@ async function create_svg( .text(n=>n.id) const simulation = d3.forceSimulation(nodes) + // .alphaTarget(0.35) + // .alphaDecay(0.5) .force("link", d3.forceLink(links).id(d => d.id)) - .force("charge", d3.forceManyBody().strength(-400)) + .force("charge", d3.forceManyBody().strength(-500)) .force("center", d3.forceCenter(width/2, height/2)) .force("x", d3.forceX()) - .force("y", d3.forceY()); + .force("y", d3.forceY().y(d => 100 * (2 * d.level + 1))) + .force("radial", d3.forceRadial(d => 20 * (2*d.level), width/2, 0)) const svg = d3.create("svg") .attr("preserveAspectRatio", "xMinYMin meet")