[BUGFIX] forcegraph show only online nodes

This commit is contained in:
Geno 2017-10-29 11:21:55 +01:00 committed by Xaver Maierhofer
parent 914f6a344b
commit 35fd75e4f6
No known key found for this signature in database
GPG Key ID: 7FDCE23FD2EC9FE8

View File

@ -1,5 +1,5 @@
define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease', 'd3-interpolate', 'utils/math', 'forcegraph/draw'], define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease', 'd3-interpolate', 'helper', 'utils/math', 'forcegraph/draw'],
function (d3Selection, d3Force, d3Zoom, d3Drag, d3Timer, d3Ease, d3Interpolate, math, draw) { function (d3Selection, d3Force, d3Zoom, d3Drag, d3Timer, d3Ease, d3Interpolate, helper, math, draw) {
'use strict'; 'use strict';
return function (config, linkScale, sidebar, router) { return function (config, linkScale, sidebar, router) {
@ -197,11 +197,9 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
}); });
self.setData = function setData(data) { self.setData = function setData(data) {
intNodes = data.nodes.all.map(function (d) { intNodes = data.nodes.all.filter(helper.online).map(function (d) {
var e; var e = dictNodes[d.node_id];
if (d.node_id in dictNodes) { if (!e) {
e = dictNodes[d.node_id];
} else {
e = {}; e = {};
dictNodes[d.node_id] = e; dictNodes[d.node_id] = e;
} }
@ -211,15 +209,16 @@ define(['d3-selection', 'd3-force', 'd3-zoom', 'd3-drag', 'd3-timer', 'd3-ease',
return e; return e;
}); });
intLinks = data.links.map(function (d) { intLinks = data.links.filter(function (d) {
var e = {}; return dictNodes[d.source.node_id] && dictNodes[d.target.node_id];
e.o = d; }).map(function (d) {
e.source = dictNodes[d.source.node_id]; return {
e.target = dictNodes[d.target.node_id]; o: d,
e.color = linkScale(d.source_tq); source: dictNodes[d.source.node_id],
e.color_to = linkScale(d.target_tq); target: dictNodes[d.target.node_id],
color: linkScale(d.source_tq),
return e; color_to: linkScale(d.target_tq)
};
}); });
force.nodes(intNodes); force.nodes(intNodes);