diff --git a/webui/app.js b/webui/app.js index 2bbf5c7..9d2e2e3 100644 --- a/webui/app.js +++ b/webui/app.js @@ -654,12 +654,26 @@ function renderTimeline(containerId, timeline) { axis.setAttribute("fill", "none"); svg.appendChild(axis); + // 水平网格线(4 等分),淡色 dashed + const gridSteps = 4; + for (let i = 1; i <= gridSteps; i++) { + const gy = padT + ((H - padT - padB) * i / gridSteps); + const gline = document.createElementNS("http://www.w3.org/2000/svg", "path"); + gline.setAttribute("d", `M ${padL} ${gy.toFixed(2)} L ${W - padR} ${gy.toFixed(2)}`); + gline.setAttribute("stroke", "var(--border)"); + gline.setAttribute("stroke-opacity", "0.5"); + gline.setAttribute("stroke-dasharray", "2 4"); + gline.setAttribute("fill", "none"); + svg.appendChild(gline); + } + const mkText = (x, y, txt, anchor = "start") => { const el = document.createElementNS("http://www.w3.org/2000/svg", "text"); el.setAttribute("x", String(x)); el.setAttribute("y", String(y)); el.setAttribute("fill", "var(--muted)"); - el.setAttribute("font-size", "11"); + el.setAttribute("font-size", "10"); + el.setAttribute("font-family", "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"); el.setAttribute("text-anchor", anchor); el.textContent = txt; return el; @@ -677,8 +691,13 @@ function renderTimeline(containerId, timeline) { return (H - padB) - (vv / maxY) * h; }; - // y 轴 max 标记 - svg.appendChild(mkText(padL, padT + 10, String(maxY), "start")); + // y 轴刻度(0 / mid / max) + const yMid = Math.round(maxY / 2); + svg.appendChild(mkText(padL - 6, padT + 4, String(maxY), "end")); + if (yMid > 0 && yMid < maxY) { + svg.appendChild(mkText(padL - 6, padT + (H - padT - padB) / 2 + 4, String(yMid), "end")); + } + svg.appendChild(mkText(padL - 6, H - padB + 4, "0", "end")); // x 轴 3 个时间刻度 const fmtShort = (ts) => { diff --git a/webui/index.html b/webui/index.html index 8b05938..a65a695 100644 --- a/webui/index.html +++ b/webui/index.html @@ -15,7 +15,7 @@ } catch (e) {} })(); - +