diff options
| author | tv <tv@krebsco.de> | 2026-11-01 20:15:13 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-01 20:15:13 +0100 |
| commit | fc4f3398c3029b1b77903095b81223f7c4705c90 (patch) | |
| tree | 3c3e5e8678081f70121401b8cb3cadee587ce12c /src/api | |
| parent | b27e1e0d349d490c08b15d024064301382dc6f58 (diff) | |
dashboard: one spring per edge
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/dashboard/dashboard.html | 10 |
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 = ""; |
