Add a Sleep trend chart: cumulative sleep today vs yesterday and the recent average

Answers "is the puppy behind on sleep right now?": cumulative hours
slept sampled at each hour boundary, today's line ending at the current
moment, with yesterday and the mean of the last N days as reference
curves. N follows the 7/14/30 chart-days picker, and days with no sleep
logged are skipped so a young log doesn't drag the average down.
This commit is contained in:
Alexander Heldt
2026-07-15 10:18:08 +00:00
parent b030cfb72a
commit 8dc4fca4e2
4 changed files with 163 additions and 0 deletions
+27
View File
@@ -900,6 +900,33 @@ input.switch:checked::after { transform: translateX(18px); }
.chart-svg .stl-hit { fill: transparent; cursor: pointer; }
.chart-svg .stl-hit:hover { fill: var(--accent); fill-opacity: 0.08; }
/* Sleep trend lines: today strongest, the reference curves lighter/dashed. */
.chart-svg .trend-today {
stroke: var(--sleep);
stroke-width: 2.5;
stroke-linejoin: round;
fill: none;
}
.chart-svg .trend-yesterday {
stroke: var(--muted);
stroke-width: 1.5;
stroke-linejoin: round;
fill: none;
opacity: 0.75;
}
.chart-svg .trend-avg {
stroke: var(--sleep);
stroke-width: 1.5;
stroke-dasharray: 4 3;
stroke-linejoin: round;
fill: none;
opacity: 0.7;
}
.lg.trend-today .sw { background: var(--sleep); }
.lg.trend-yesterday .sw { background: var(--muted); }
.lg.trend-avg .sw { background: color-mix(in srgb, var(--sleep) 55%, var(--surface)); }
.lg[hidden] { display: none; }
.chart-svg .hm-cell { stroke: none; }
.chart-svg .hm-pee { fill: var(--pee); }
.chart-svg .hm-poo { fill: var(--poo); }