From 24987f4963346eafd8992d6445af9192c55d4b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20P=C3=A4ssler?= Date: Wed, 2 Mar 2016 21:55:44 +0100 Subject: [PATCH] forcegraph: draw unseen nodes orange --- lib/forcegraph.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 995fd8a..fac79bd 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -19,7 +19,9 @@ define(["d3"], function (d3) { var nodes = [] var uplinkNodes = [] var nonUplinkNodes = [] + var unseenNodes = [] var unknownNodes = [] + var graphNodes = [] var savedPanZoom var draggedNode @@ -313,6 +315,7 @@ define(["d3"], function (d3) { var unknownColor = "#D10E2A" var nonUplinkColor = "#F2E3C6" var uplinkColor = "#5BAAEB" + var unseenColor = "#FFA726" var highlightColor = "rgba(252, 227, 198, 0.15)" var nodeRadius = 6 var cableColor = "#50B0F0" @@ -364,6 +367,11 @@ define(["d3"], function (d3) { ctx.drawImage(uplinkNode, scale * r * d.x - uplinkNode.width / 2, scale * r * d.y - uplinkNode.height / 2) }) + var unseenNode = drawNode(unseenColor, nodeRadius, scale, r) + unseenNodes.filter(visibleNodes).forEach(function (d) { + ctx.drawImage(unseenNode, scale * r * d.x - unseenNode.width / 2, scale * r * d.y - unseenNode.height / 2) + }) + ctx.restore() // -- draw clients -- @@ -695,10 +703,12 @@ define(["d3"], function (d3) { }) }) - nodes = intNodes.filter(function (d) { return d.o.node }) + nodes = intNodes.filter(function (d) { return !d.o.unseen && d.o.node }) uplinkNodes = nodes.filter(function (d) { return d.o.node.flags.uplink }) nonUplinkNodes = nodes.filter(function (d) { return !d.o.node.flags.uplink }) + unseenNodes = intNodes.filter(function (d) { return d.o.unseen && d.o.node }) unknownNodes = intNodes.filter(function (d) { return !d.o.node }) + graphNodes = nodes.concat(unseenNodes).concat(unknownNodes) if (localStorageTest()) { var save = JSON.parse(localStorage.getItem("graph/nodeposition")) @@ -718,9 +728,9 @@ define(["d3"], function (d3) { } } - var diameter = graphDiameter(intNodes) + var diameter = graphDiameter(graphNodes) - force.nodes(intNodes) + force.nodes(graphNodes) .links(intLinks) .size([diameter, diameter])