2015-07-08 00:36:57 +02:00
|
|
|
define([], function () {
|
|
|
|
return function (filter) {
|
|
|
|
return function (data) {
|
|
|
|
var n = Object.create(data)
|
|
|
|
n.nodes = {}
|
|
|
|
|
2016-06-02 22:43:53 +02:00
|
|
|
for (var key in data.nodes)
|
2015-07-08 00:36:57 +02:00
|
|
|
n.nodes[key] = data.nodes[key].filter(filter)
|
|
|
|
|
|
|
|
var filteredIds = new Set()
|
|
|
|
|
|
|
|
n.graph = {}
|
|
|
|
n.graph.nodes = data.graph.nodes.filter( function (d) {
|
2016-02-28 01:24:04 +01:00
|
|
|
var r
|
|
|
|
if (d.node)
|
|
|
|
r = filter(d.node)
|
|
|
|
else
|
|
|
|
r = filter({})
|
2015-07-08 00:36:57 +02:00
|
|
|
|
|
|
|
if (r)
|
|
|
|
filteredIds.add(d.id)
|
|
|
|
|
|
|
|
return r
|
|
|
|
})
|
|
|
|
|
|
|
|
n.graph.links = data.graph.links.filter( function (d) {
|
2016-02-28 01:24:04 +01:00
|
|
|
return filteredIds.has(d.source.id) && filteredIds.has(d.target.id)
|
2015-07-08 00:36:57 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|