forcegraph: fix links losing nodes

This commit is contained in:
Nils Schneider 2015-04-08 01:21:52 +02:00
parent 03d0c5488f
commit 74e640f899

View file

@ -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")