forcegraph: fix links losing nodes
This commit is contained in:
parent
03d0c5488f
commit
74e640f899
|
@ -8,6 +8,7 @@ define(["d3"], function (d3) {
|
||||||
var el
|
var el
|
||||||
var doAnimation = false
|
var doAnimation = false
|
||||||
var intNodes = []
|
var intNodes = []
|
||||||
|
var intLinks = []
|
||||||
var highlight
|
var highlight
|
||||||
|
|
||||||
var LINK_DISTANCE = 70
|
var LINK_DISTANCE = 70
|
||||||
|
@ -212,13 +213,26 @@ define(["d3"], function (d3) {
|
||||||
newNodesDict[d.o.id] = d
|
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
|
return !d.vpn
|
||||||
}).map( function (d) {
|
}).map( function (d) {
|
||||||
var source = newNodesDict[d.source.id]
|
var e
|
||||||
var target = newNodesDict[d.target.id]
|
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")
|
link = vis.select("g.links")
|
||||||
|
|
Loading…
Reference in a new issue