usage: a 5-hour window draws its current cycle only, not a comb of drops (@xxxxxthhh on X)

The "Left over time" curve drew one descending segment per recorded cycle
of every window. Over the cycle range of a weekly window, the 5-hour
window therefore showed a run of sawtooth drops, each resetting to 100%
and falling again. @xxxxxthhh: "the 5-hour window's lines dropping one by
one are too messy, like bugs crawling".

Chosen: a window far shorter than the span (the existing `short` case in
drawQuotaPlot) keeps only the points of its current cycle, so the plot has
one drop at the right edge and the legend carries its figure. Past 5-hour
cycles are not drawn faint or banded: they say nothing the weekly line
beside them doesn't, and a band or a second style would add marks to a
52px plot. Longer windows, the 2-day range, the picked past cycle, the
colours and the layout are unchanged; the short line is now one
segment, so it is a little firmer (1.25px, .7) than the faint comb was.

Run on mote: quota-curve.test.cjs in chromium and webkit (en, zh, zh-TW,
ja, de) with its 5-hour assertion now one subpath; it fails on the old
assets (two subpaths). Before/after screenshots in
magpie-wt/leftover-chart-scratch/shots. Whole GUI suite and
internal/gui Go tests are run after this commit; see the follow-up note.
Not tried: a real account's week of readings.
This commit is contained in:
yetone
2026-11-12 10:36:47 +08:00
parent 1e2857730a
commit 32c592d3fb
3 changed files with 10 additions and 6 deletions
+3 -3
View File
@@ -1161,9 +1161,9 @@ body.panel .row.pref.flash { border-radius: 10px; }
.balance-curve .bc-pace { color: var(--muted); }
.qc-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.qc-line { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
/* a window far shorter than the span drawn (a 5-hour one over a week) is a
comb of drops: faint, and without its upright even burn */
.qc-line.qc-short { stroke-width: 1; opacity: .45; }
/* a window far shorter than the span drawn (a 5-hour one over a week) draws
its current cycle only, lighter, and without its upright even burn */
.qc-line.qc-short { stroke-width: 1.25; opacity: .7; }
.qc-even { stroke-width: 1; stroke-dasharray: 3 3; opacity: .45; vector-effect: non-scaling-stroke; }
.qc-now { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 1 2; vector-effect: non-scaling-stroke; }
.quota-curve .qc-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
+6 -2
View File
@@ -16800,13 +16800,17 @@ function drawQuotaPlot(g, lines, x0, x1, w, h, now, thin) {
const s = i % 7, color = `var(--c${s + 1})`;
const c = l.cycle || quotaCycle(l, now);
// a window far shorter than the span (a 5-hour one over a week) is
// drawn faint, without its even burn, an all but upright dash
// drawn without its even burn, an all but upright dash
const short = !thin && c.reset && c.reset - c.start < (x1 - x0) / 12;
if (c.reset && c.start < c.reset && !short) {
const e = sv("line", { x1: X(c.start), y1: 0, x2: X(c.reset), y2: h, class: "qc-even", "data-series": s }, { stroke: color });
g.append(e);
}
const d = quotaPaths(l.points, x0, x1, w, h);
// and only its current cycle: the cycles before it, each a drop of its
// own, crawled across the week like a comb of bugs (@xxxxxthhh on X)
let pts = l.points;
if (short) { const now1 = pts.filter((p) => p.at >= c.start); pts = now1.length ? now1 : pts.slice(-1); }
const d = quotaPaths(pts, x0, x1, w, h);
if (d) g.append(sv("path", { d, class: "qc-line" + (short ? " qc-short" : ""), "data-name": l.name, "data-series": s }, { stroke: color }));
});
// a spark ends at now already, and in 16px the dotted now line read as a
+1 -1
View File
@@ -325,7 +325,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(await curve.locator("path.qc-line.qc-short").getAttribute("data-name"), "5 hours");
assert.equal(await curve.locator("line.qc-now").count(), 1);
const five = await curve.locator('path.qc-line[data-name="5 hours"]').getAttribute("d");
assert.equal((five.match(/M/g) || []).length, 2, "the 5-hour line breaks where its window started again: " + five);
assert.equal((five.match(/M/g) || []).length, 1, "the 5-hour line is its current cycle only, no comb of earlier drops: " + five);
const legend = await curve.locator(".qc-key").allTextContents();
assert.deepEqual(legend, [w.five + "40%", w.week + "70%"]);
assert.equal(await page.locator(".subscription-card", { hasText: "Kimi" }).locator(".quota-curve").count(), 0, "no readings, no curve");