Skip to content

Commit 2243444

Browse files
remove chart box-select entirely; it was the source of the 3M/6M/ALL switch bug
Box-select was my own addition, not something you asked for, and its dataZoom listener caused the frozen-window-buttons bug plus two failed fix attempts. Removed the component and its handler outright: 30 lines deleted, 1 changed. The custom time-range query you actually wanted (datetime inputs + Go) is untouched.
1 parent 6f43541 commit 2243444

1 file changed

Lines changed: 1 addition & 30 deletions

File tree

static/index.html

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,7 @@
247247
const phos = cssv('--phos');
248248
chart.setOption({
249249
animation: false,
250-
grid: { left: 52, right: 46, top: 18, bottom: 56 },
251-
dataZoom: [
252-
{ type: 'inside', filterMode: 'none' },
253-
{ type: 'slider', height: 16, bottom: 8, filterMode: 'none',
254-
borderColor: cssv('--line'), fillerColor: 'color-mix(in srgb, var(--phos) 12%, transparent)',
255-
handleStyle: { color: cssv('--phos') }, moveHandleStyle: { color: cssv('--dim') },
256-
dataBackground: { lineStyle: { color: cssv('--dim') }, areaStyle: { color: cssv('--grid-split') } },
257-
textStyle: { color: cssv('--dim'), fontSize: 9 } }
258-
],
250+
grid: { left: 52, right: 46, top: 18, bottom: 42 },
259251
xAxis: { type: 'time', axisLine: { lineStyle: { color: cssv('--grid-axis') } },
260252
axisLabel: { color: cssv('--dim'), fontSize: 10 }, splitLine: { lineStyle: { color: cssv('--grid-split') } },
261253
axisPointer: { show: true, snap: false,
@@ -303,27 +295,6 @@
303295
}, true);
304296
}
305297

306-
// 图上拖拽框选一段时间 -> 精确查询那一段(dataZoom 的 datazoom 事件给出可视范围)
307-
let zoomTimer = null;
308-
chart.on('dataZoom', () => {
309-
clearTimeout(zoomTimer);
310-
zoomTimer = setTimeout(() => {
311-
const opt = chart.getOption();
312-
const dz = opt.dataZoom && opt.dataZoom[0];
313-
if (!dz || dz.startValue == null) return;
314-
const from = Math.floor(dz.startValue / 1000), to = Math.ceil(dz.endValue / 1000);
315-
if (to - from < 120) return; // 太窄忽略
316-
// ECharts 在 setOption 重建 dataZoom 时会自发一次事件,其范围≈整个视图窗口。
317-
// 用户真正拖拽总是选取子区间,所以覆盖 ~99% 视图宽度的事件视为组件重建,忽略。
318-
const viewSpan = sel ? (sel.to - sel.from)
319-
: days > 0 ? days * 86400
320-
: minutes * 60;
321-
if (viewSpan > 0 && (to - from) >= viewSpan * 0.99) return;
322-
sel = { from, to };
323-
$('selReset').style.display = '';
324-
render();
325-
}, 350);
326-
});
327298

328299
document.querySelectorAll('.rng button[data-m], .rng button[data-d]').forEach(b => b.onclick = () => {
329300
sel = null; $('selReset').style.display = 'none';

0 commit comments

Comments
 (0)