forked from security_vision/semantic_graph
Prevent jump in hte beginning, and format code
This commit is contained in:
parent
d471ab197a
commit
f348decd02
1 changed files with 76 additions and 69 deletions
9
graph.js
9
graph.js
|
@ -129,7 +129,7 @@ function buildGraph(data) {
|
||||||
.iterations(2) // increase to make more rigid
|
.iterations(2) // increase to make more rigid
|
||||||
)
|
)
|
||||||
.force("charge", d3.forceManyBody()
|
.force("charge", d3.forceManyBody()
|
||||||
.strength(-50)
|
.strength(-40)
|
||||||
)
|
)
|
||||||
.force("center", d3.forceCenter(width / 2, height / 2))
|
.force("center", d3.forceCenter(width / 2, height / 2))
|
||||||
.force("collision", d3.forceCollide(function (d) {
|
.force("collision", d3.forceCollide(function (d) {
|
||||||
|
@ -300,6 +300,13 @@ 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return svg.node();
|
return svg.node();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue