From 7a0e1027dd7d8c0cbf60f406a64b24c0a9f284b8 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 6 Oct 2014 15:05:49 +0300 Subject: rhizicore: update: add no_relayout parameter, plus don't keep assigning tick event handler --- scripts/rhizicore.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/rhizicore.js b/scripts/rhizicore.js index d96e7226..0b7253a0 100644 --- a/scripts/rhizicore.js +++ b/scripts/rhizicore.js @@ -24,8 +24,8 @@ var force; function myGraph(el) { - this.update = function(){ - update(); + this.update = function(no_relayout) { + update(no_relayout); } ///FUNCTIONS @@ -488,6 +488,7 @@ function myGraph(el) { .gravity(0.12) .charge(-1800) .size([w, h]) + .on("tick", tick) .start(); nodes = force.nodes(); @@ -498,7 +499,7 @@ function myGraph(el) { exit:'exitlink graph', }; - var update = function() { + var update = function(no_relayout) { link = vis.select("#link-group").selectAll(".link") .data(links); @@ -677,8 +678,6 @@ function myGraph(el) { node.exit().remove(); - force.on("tick", tick); - //update deliverables deliverables = []; for (var i = 0; i < nodes.length; i++) { @@ -696,6 +695,13 @@ function myGraph(el) { force.nodes(nodes) .links(links) .start(); + if (no_relayout) { + // XXX If we are stopped we need to update the text of the links at least, + // and this is the simplest way + tick(); + } else { + force.alpha(0.1).start(); + } } update(); -- cgit v1.3.1