From 4d980d7fc3cca344f46b6809762b9fe4a8effc0e Mon Sep 17 00:00:00 2001 From: Carsten Rehfeld Date: Sun, 17 May 2026 01:49:37 +0200 Subject: [PATCH] =?UTF-8?q?fix(admin):=20single=20update=20path=20per=20po?= =?UTF-8?q?ll=20=E2=80=94=20no=20competing=20D3=20transitions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed separate setInterval for buf flush. Flush + redraw now happen together inside poll() — one atomic step, one D3 transition(950ms). Two independent 1 s timers were firing out of phase and interrupting each other's transitions, causing flicker and apparent 2 s cadence. Co-Authored-By: Mira Rehfeld --- .../main/resources/META-INF/resources/admin.js | 16 +++------------- .../templates/DashboardResource/global.html | 2 +- .../templates/DashboardResource/sandbox.html | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/apix-admin/src/main/resources/META-INF/resources/admin.js b/apix-admin/src/main/resources/META-INF/resources/admin.js index 0234481..7e2272a 100644 --- a/apix-admin/src/main/resources/META-INF/resources/admin.js +++ b/apix-admin/src/main/resources/META-INF/resources/admin.js @@ -214,18 +214,6 @@ return Math.min(Math.round(sum * (60000 / CHART_TICK)), rateLimit); } - // Redraw: historical buf + live bucket at right edge, with smooth transition - function redraw() { - var view = buf.slice(1).concat([liveRpm()]); - path.transition().duration(900).ease(d3.easeLinear).attr('d', areaFn(view)); - } - - // Every 1 s: snapshot the sliding-window rate into the history buffer - // Smaller buckets (1 s each, 72 s total) so the chart scrolls visibly every second - setInterval(function () { - buf.push(liveRpm()); buf.shift(); - }, 1000); - async function poll() { try { var r = await fetch('/sandbox/' + sid + '/poll'); @@ -240,7 +228,9 @@ } var rpm = liveRpm(); updateLabel(rpm); - redraw(); + // Flush + redraw in one step — no separate timer, no competing transitions + buf.push(rpm); buf.shift(); + path.transition().duration(950).ease(d3.easeLinear).attr('d', areaFn(buf)); } lastTotal = total; currentInterval = (Date.now() - lastActivity > IDLE_AFTER_MS) ? IDLE_INTERVAL : FAST_INTERVAL; diff --git a/apix-admin/src/main/resources/templates/DashboardResource/global.html b/apix-admin/src/main/resources/templates/DashboardResource/global.html index 1d66d87..22b49e0 100644 --- a/apix-admin/src/main/resources/templates/DashboardResource/global.html +++ b/apix-admin/src/main/resources/templates/DashboardResource/global.html @@ -106,6 +106,6 @@ nav { - + diff --git a/apix-admin/src/main/resources/templates/DashboardResource/sandbox.html b/apix-admin/src/main/resources/templates/DashboardResource/sandbox.html index 2b3e271..42da7b7 100644 --- a/apix-admin/src/main/resources/templates/DashboardResource/sandbox.html +++ b/apix-admin/src/main/resources/templates/DashboardResource/sandbox.html @@ -151,6 +151,6 @@ button.promote:hover { background: #2ea043; } - +