From a35a28cafe963cd41f8483be756f0413f684436b Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 12 Jun 2012 16:16:37 +0200 Subject: [PATCH] fix counting of vpn links --- html/force.js | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/html/force.js b/html/force.js index a6b2f9e..90f7c9d 100644 --- a/html/force.js +++ b/html/force.js @@ -277,29 +277,17 @@ function reload() { if (typeof d.target == "number") d.target = json.nodes[d.target]; }) - // count uplinks + // count vpn links json.nodes.forEach(function(d) { - d.uplinks = undefined + d.vpns = 0 }) json.links.forEach(function(d) { var node, other - if (d.source.flags.vpn) { - node = d.target - other = d.source - } - - if (d.target.flags.vpn) { - node = d.source - other = d.target - } - - if (node) { - if (node.uplinks === undefined) - node.uplinks = 0 - - node.uplinks++ + if (d.type == "vpn") { + d.source.vpns++ + d.target.vpns++ } }) @@ -376,9 +364,6 @@ function update() { if (!visible.vpn && d.flags.vpn) return false - if (!visible.vpn && d.flags.client && d.uplinks) - return false - if (!visible.clients && d.flags.client) return false @@ -446,10 +431,7 @@ function update() { if (!visible.vpn) { var uplink_info = node.filter(function (d) { - if (d.uplinks !== undefined) - return d.uplinks > 0 - else - return false + return d.vpns > 0 }) .append("g") .attr("class", "uplinks") @@ -463,7 +445,7 @@ function update() { uplink_info.append("text") .attr("text-anchor", "middle") .attr("y", 3 - 20) - .text(function (d) {return d.uplinks}) + .text(function (d) {return d.vpns}) } node.exit().remove()