diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 5a8fa3e..0a97e44 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -8,6 +8,7 @@ define(["d3"], function (d3) { var el var doAnimation = false var intNodes = [] + var intLinks = [] var highlight var LINK_DISTANCE = 70 @@ -212,13 +213,26 @@ define(["d3"], function (d3) { newNodesDict[d.o.id] = d }) - var intLinks = data.graph.links.filter( function (d) { + var oldLinks = {} + + intLinks.forEach( function (d) { + oldLinks[d.o.id] = d + }) + + intLinks = data.graph.links.filter( function (d) { return !d.vpn }).map( function (d) { - var source = newNodesDict[d.source.id] - var target = newNodesDict[d.target.id] + var e + if (d.id in oldLinks) + e = oldLinks[d.id] + else + e = {} - return {o: d, source: source, target: target} + e.o = d + e.source = newNodesDict[d.source.id] + e.target = newNodesDict[d.target.id] + + return e }) link = vis.select("g.links")