Compare commits

..

2 commits

Author SHA1 Message Date
Ruben van de Ven
f9dec8a947 simulation prerendering is now a config var 2021-03-13 13:31:00 +01:00
Ruben van de Ven
f348decd02 Prevent jump in hte beginning, and format code 2021-03-13 13:29:40 +01:00

View file

@ -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,
},
@ -129,7 +130,7 @@ function buildGraph(data) {
.iterations(2) // increase to make more rigid
)
.force("charge", d3.forceManyBody()
.strength(-50)
.strength(-40)
)
.force("center", d3.forceCenter(width / 2, height / 2))
.force("collision", d3.forceCollide(function (d) {
@ -300,6 +301,15 @@ function buildGraph(data) {
});
// simulate the first bit without drawing, so we don't have the 'jumping' graph in the beginning
if (CONFIG.preSimulate) {
for (var i = 0, n = Math.ceil(Math.log(simulation.alphaMin()) / Math.log(1 - simulation.alphaDecay())); i < n; ++i) {
simulation.tick();
}
}
return svg.node();
}