Skip to content

Commit 77671fc

Browse files
fix: switching back from 3M/6M/ALL froze the window buttons
setOption(...,true) re-creates the dataZoom component when returning from a band view (which has none) to a smoke view (which has one), and ECharts emits a dataZoom event for that rebuild — indistinguishable from a user drag. The handler treated it as a box-select, set sel, and re-rendered, which rebuilt dataZoom again: a self- feeding loop that looked like dead buttons. A redraw gate now ignores programmatic dataZoom events; only real user drags select a range.
1 parent 494e284 commit 77671fc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

static/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
}
186186

187187
let sel = null; // {from,to} 框选时间段(unix 秒)
188+
// setOption 重建 dataZoom 组件时 ECharts 会自发一次 dataZoom 事件,
189+
// 那不是用户操作 —— 重绘期间关闸,避免"点档位反被框选回调劫持"的死循环。
190+
let redrawing = false;
188191
let renderSeq = 0;
189192
async function render() {
190193
const seq = ++renderSeq;
@@ -245,6 +248,7 @@
245248
$('conclusion').textContent = (t.down ? '🔴 ' : '🟢 ') + `${t.name}: ${win} P99 ${pool.length ? q(.99).toFixed(1) : '–'} ms · loss ${lossPct.toFixed(2)}% · ${bursts} bursts`;
246249

247250
const phos = cssv('--phos');
251+
redrawing = true;
248252
chart.setOption({
249253
animation: false,
250254
grid: { left: 52, right: 46, top: 18, bottom: 56 },
@@ -301,11 +305,13 @@
301305
tooltip: { formatter: p => `◆ z-score ${p.value[2] ? p.value[2].toFixed(2) : '—'} · loss ${p.value[1].toFixed(0)}% (${p.value[3]}/${p.value[4]})` } }
302306
]
303307
}, true);
308+
setTimeout(() => { redrawing = false; }, 400); // 覆盖 ECharts 自发事件的窗口
304309
}
305310

306311
// 图上拖拽框选一段时间 -> 精确查询那一段(dataZoom 的 datazoom 事件给出可视范围)
307312
let zoomTimer = null;
308313
chart.on('dataZoom', () => {
314+
if (redrawing) return; // 程序重绘引发的,不是用户拖拽
309315
clearTimeout(zoomTimer);
310316
zoomTimer = setTimeout(() => {
311317
const opt = chart.getOption();
@@ -399,6 +405,7 @@
399405
const win = days >= 300 ? 'all' : days >= 30 ? (days/30) + 'M' : days + 'd';
400406
$('conclusion').textContent = (t.down ? '🔴 ' : '🟢 ') + `${t.name}: ${win} peak P99 ${p99max.toFixed(1)} ms · loss ${lp.toFixed(2)}% · ${burstSum} bursts`;
401407
const phos = cssv('--phos');
408+
redrawing = true;
402409
chart.setOption({
403410
animation: false,
404411
grid: { left: 52, right: 46, top: 18, bottom: 42 },
@@ -443,6 +450,7 @@
443450
tooltip: { formatter: p => `◆ ${p.value[2]} bursts · loss ${p.value[1].toFixed(1)}%` } }
444451
]
445452
}, true);
453+
setTimeout(() => { redrawing = false; }, 400); // 覆盖 ECharts 自发事件的窗口
446454
}
447455

448456
$('themeBtn').onclick = () => {

0 commit comments

Comments
 (0)