From 61043350f85ef750d63426b03b726ad22280c7c1 Mon Sep 17 00:00:00 2001 From: mathieudutour Date: Fri, 24 Jul 2020 15:44:48 +0200 Subject: [PATCH 1/3] fix missing d3 namespace --- static/webview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/webview.html b/static/webview.html index bd8d2cb..28f7e50 100644 --- a/static/webview.html +++ b/static/webview.html @@ -176,7 +176,7 @@ node.attr("r", zoomOrKeep(RADIUS)); svg .selectAll("circle") - .filter((_d, i, nodes) => select(nodes[i]).attr("active")) + .filter((_d, i, nodes) => d3.select(nodes[i]).attr("active")) .attr("r", zoomOrKeep(ACTIVE_RADIUS)); document.getElementById("zoom").innerHTML = zoomLevel.toFixed(2); From 21109d091ae324afddb7ea6e33ba25f85f5e087d Mon Sep 17 00:00:00 2001 From: mathieudutour Date: Fri, 24 Jul 2020 15:45:09 +0200 Subject: [PATCH 2/3] fix typo when checking the label --- static/webview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/webview.html b/static/webview.html index 28f7e50..aaa0ece 100644 --- a/static/webview.html +++ b/static/webview.html @@ -85,7 +85,7 @@ for (const node of next) { const found = map.get(node.id); - if (!found || found !== node.title) { + if (!found || found !== node.label) { return false; } } From 2dd90d78b8462de443a76bf16d55fcbce4a65167 Mon Sep 17 00:00:00 2001 From: mathieudutour Date: Fri, 24 Jul 2020 15:45:58 +0200 Subject: [PATCH 3/3] keep the nodes if we have already placed them --- static/webview.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/static/webview.html b/static/webview.html index aaa0ece..e8e42cf 100644 --- a/static/webview.html +++ b/static/webview.html @@ -93,6 +93,21 @@ return true; }; + const mergeNodes = (previous, next) => { + for (const node of next) { + const found = previous.find((x) => x.id === node.id); + if (found) { + node.index = found.index; + node.x = found.x; + node.y = found.y; + node.vy = found.vy; + node.vx = found.vx; + } + } + + return next; + }; + const sameEdges = (previous, next) => { if (next.length !== previous.length) { return false; @@ -193,7 +208,7 @@ return; } - nodesData = nodes; + nodesData = mergeNodes(nodesData, nodes); linksData = edges; restart(); break;