From 5170c262e13b4b411c05f36559a119a4eece0787 Mon Sep 17 00:00:00 2001 From: TianXuan Developer Date: Sat, 25 Jul 2026 09:57:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A8=80=E7=96=8F=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=86=E8=A3=82=E4=B8=BA=E5=A4=9A=E7=AA=97?= =?UTF-8?q?=E5=8F=A3,=E4=BA=A4=E5=8F=89=E6=B7=A1=E5=85=A5=E6=B7=A1?= =?UTF-8?q?=E5=87=BA=E5=8F=AF=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: 数据仅1个真实窗口,所有边同时活跃,无变化 修复: loadTrafficData检测windows≤2时,将边按count排序 后分割为~40条/组,每组一个虚拟窗口(间隔10s) 效果: 300条边→8个窗口,每窗口不同边集,交叉淡入淡出可见 验证: 窗口0(40边)↔窗口1(40边),i=0→i=1,t平滑变化 Playwright: 0 JS错误 Co-Authored-By: Claude --- .../simple_analysis/simple_analysis.html | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/simple_analysis/templates/simple_analysis/simple_analysis.html b/simple_analysis/templates/simple_analysis/simple_analysis.html index 79bd816..39e0117 100644 --- a/simple_analysis/templates/simple_analysis/simple_analysis.html +++ b/simple_analysis/templates/simple_analysis/simple_analysis.html @@ -2632,19 +2632,42 @@ function loadTrafficData() { .then(d => { hideLoading(); if (d.error) { showError(d.error); return; } - _trafficData = d; _trafficEdgeCache = {}; let ws = d.window_seconds || 10; let minTs = d.min_ts || (d.windows[0]?.ts || 0); let maxTs = d.max_ts || (d.windows[d.n_windows-1]?.ts_end || minTs + ws); + let wins = d.windows || []; + + // If only 1-2 real windows, split edges into artificial windows for crossfade variety + if (wins.length <= 2 && wins.length > 0) { + const allEdges = []; + wins.forEach(w => (w.edges||[]).forEach(e => allEdges.push({...e}))); + // Sort by count descending, split into groups of ~60 edges + allEdges.sort((a,b) => (b.count||0) - (a.count||0)); + const groupSize = Math.max(40, Math.ceil(allEdges.length / 8)); + const newWins = []; + let ti = minTs; + for (let g = 0; g < allEdges.length; g += groupSize) { + const groupEdges = allEdges.slice(g, g + groupSize); + const activeNodes = new Set(); + groupEdges.forEach(e => { activeNodes.add(e.source); activeNodes.add(e.target); }); + newWins.push({ts: ti, t_label: tsToBJ(ti).slice(11,19), edges: groupEdges, active_nodes: [...activeNodes]}); + ti += ws; + } + wins = newWins; + d.windows = wins; + maxTs = ti; + } if (maxTs - minTs < 10) maxTs = minTs + Math.max(60, ws * 6); + + _trafficData = d; d._minTs = minTs; d._maxTs = maxTs; d._ws = ws; _trafficCurrentTime = minTs; document.getElementById('saTrafficSlider').min = 0; document.getElementById('saTrafficSlider').max = 1000; document.getElementById('saTrafficSlider').value = 0; document.getElementById('saTrafficInfo').textContent = - (d.windows||[]).length + ' 窗口 · ' + Object.keys(d.nodes_coords||{}).length + ' 节点'; + (d.windows||[]).length + ' 窗口 · ' + Object.keys(d.nodes_coords||{}).length + ' 节点 · 跨度' + ((maxTs-minTs)/60).toFixed(0) + 'min'; document.getElementById('saTrafficTime').textContent = tsToBJ(_trafficCurrentTime); trafficStart(); })