aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-01 20:15:13 +0100
committertv <tv@krebsco.de>2026-11-01 20:15:13 +0100
commit8b8ed72a91a211092fd2d0c2e2797dbde0b55a04 (patch)
tree051409e8c028473f731c635136167567547587dc /src
parent333a211ec3e7860e8d746696cec3fc96451f5c41 (diff)
dashboard: one spring per edge
Diffstat (limited to 'src')
-rw-r--r--src/api/dashboard/dashboard.html10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/api/dashboard/dashboard.html b/src/api/dashboard/dashboard.html
index 6490cd5..6a365a8 100644
--- a/src/api/dashboard/dashboard.html
+++ b/src/api/dashboard/dashboard.html
@@ -574,19 +574,21 @@ function relax(nodes, pairs, width, height, gain, most, only) {
// them a little every frame (`settle`), not at once.
let byRtt = false;
try { byRtt = localStorage.getItem("continuum-by-rtt") === "1"; } catch (_) {}
+// One spring per pair of nodes, intended or measured or both, all pulling alike: a pair
+// both intended and measured doesn't pull twice as hard as one only intended.
function lengths(intended, measured, count, width, height) {
const ideal = idealLength(count, width, height);
const rtts = [...measured.values()].map(edge => edge.link.rttMs)
.filter(rtt => typeof rtt === "number" && rtt > 0).sort((x, y) => x - y);
const median = rtts[Math.floor(rtts.length / 2)];
- const pairs = [...intended.values()].map(([a, b]) => [a, b, ideal]);
- for (const { a, b, link } of measured.values()) {
+ const pairs = new Map([...intended].map(([key, [a, b]]) => [key, [a, b, ideal]]));
+ for (const [key, { a, b, link }] of measured) {
const rtt = link.rttMs;
const length = byRtt && median && typeof rtt === "number" && rtt > 0
? ideal * Math.min(2.5, Math.max(.4, Math.sqrt(rtt / median))) : ideal;
- pairs.push([a, b, Math.round(length)]);
+ pairs.set(key, [a, b, Math.round(length)]);
}
- return pairs;
+ return [...pairs.values()];
}
// What `settle` moves the map towards: the latest render's nodes and lengths.
let settling = false, settleTo = null, lastLengths = "";