From f9dec8a947c74f126c1e2c007df89448778e4b21 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Sat, 13 Mar 2021 13:31:00 +0100 Subject: [PATCH] simulation prerendering is now a config var --- graph.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/graph.js b/graph.js index 4eb0479..3f65cf6 100644 --- a/graph.js +++ b/graph.js @@ -3,6 +3,7 @@ const CONFIG = { 'nodeSize': 16, 'baseUrl': 'https://www.securityvision.io/wiki/index.php/', 'dataUrl': 'semantic_data.json', + 'preSimulate': true, // run simulation before starting, so we don't start with lines jumping around 'labels': { 'rotate': true, }, @@ -302,8 +303,10 @@ function buildGraph(data) { // simulate the first bit without drawing, so we don't have the 'jumping' graph in the beginning - for (var i = 0, n = Math.ceil(Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())); i < n; ++i) { - simulation.tick(); + if (CONFIG.preSimulate) { + for (var i = 0, n = Math.ceil(Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())); i < n; ++i) { + simulation.tick(); + } }