diff --git a/src/app.js b/src/app.js
index a1964f1..75254b6 100644
--- a/src/app.js
+++ b/src/app.js
@@ -2073,59 +2073,72 @@
// marked ones: a puppy never sleeps 0h, so it is a day nobody logged, and
// fitting it as a real zero would drag the line through the floor.
const trend = dailyTrend(days, d => d.sleepHours > 0 ? d.sleepHours : null);
- if (trend) {
- const cx = (i) => ML + i * (barW + gap) + barW / 2;
- const cy = (h) => MT + innerH * (1 - Math.min(Math.max(h, 0), yMax) / yMax);
- parts.push(
- ``
- );
- }
- renderSleepTrendNote(days, trend);
+ if (trend) parts.push(trendLineSVG("sleep-trend", trend, { ML, MT, innerH, barW, gap, yMax }));
+ const blank = days.filter((d, i) => i < days.length - 1 && !d.excluded && !(d.sleepHours > 0)).length;
+ renderTrendNote("sleep-note", sleepTrendSentence(trend, chartDays()), blank, "with no sleep logged");
setChartSVG(svg, parts);
}
- // The food trend's rules in hours: figures rounded to the half hour (the
- // fitted ends are the line's guess, not a reading), and no direction claimed
- // unless the move outruns the day-to-day scatter and is worth acting on.
- function sleepTrendSentence(trend, windowDays) {
+ // The food trend's rules in other units: figures rounded to a step (the
+ // fitted ends are the line's guess, not a reading — `step` hours for sleep,
+ // minutes for walks), and no direction claimed unless the move outruns the
+ // day-to-day scatter and is at least `minChange`, worth acting on.
+ function amountTrendSentence(trend, windowDays, { what, step, minChange, fmt }) {
const window = `the last ${windowDays} days`;
if (!trend) {
return `Not enough complete days in ${window} to draw a trend — it needs four, and today doesn't count until it's over.`;
}
- const half = (v) => Math.round(Math.max(0, v) * 2) / 2;
- const hours = (v) => `${half(v)}h`;
- const slight = Math.abs(trend.change) < 0.25 || Math.abs(trend.change) < trend.mean * 0.05;
+ const round = (v) => Math.round(Math.max(0, v) / step) * step;
+ const amount = (v) => fmt(round(v));
+ const slight = Math.abs(trend.change) < minChange || Math.abs(trend.change) < trend.mean * 0.05;
if (!trend.clear || slight) {
- return `Over ${window}, daily sleep is roughly steady, averaging about ${hours(trend.mean)} a day` +
+ return `Over ${window}, ${what} is roughly steady, averaging about ${amount(trend.mean)} a day` +
` — day-to-day variation is larger than any trend.`;
}
// From the rounded ends, so the two figures on screen subtract to the one quoted.
- const from = half(trend.at(trend.first));
- const to = half(trend.at(trend.last));
+ const from = round(trend.at(trend.first));
+ const to = round(trend.at(trend.last));
if (from === to) {
- return `Over ${window}, daily sleep is roughly steady at about ${hours(from)} a day.`;
+ return `Over ${window}, ${what} is roughly steady at about ${fmt(from)} a day.`;
}
- return `Over ${window}, daily sleep is ${to > from ? "up" : "down"} about ${hours(Math.abs(to - from))}` +
- ` — from roughly ${hours(from)} a day to ${hours(to)}.`;
+ return `Over ${window}, ${what} is ${to > from ? "up" : "down"} about ${fmt(Math.abs(to - from))}` +
+ ` — from roughly ${fmt(from)} a day to ${fmt(to)}.`;
}
- function renderSleepTrendNote(days, trend) {
- const note = document.getElementById("sleep-note");
+ function sleepTrendSentence(trend, windowDays) {
+ return amountTrendSentence(trend, windowDays,
+ { what: "daily sleep", step: 0.5, minChange: 0.25, fmt: (h) => `${h}h` });
+ }
+ function walkTrendSentence(trend, windowDays) {
+ return amountTrendSentence(trend, windowDays,
+ { what: "daily walking", step: 5, minChange: 5, fmt: (m) => formatDuration(m * 60_000) });
+ }
+
+ // Says, after the sentence, how many days the line was not fitted on and
+ // why, so an empty bar isn't taken for data the line ignored.
+ function renderTrendNote(noteId, sentence, skipped, reason) {
+ const note = document.getElementById(noteId);
if (!note) return;
- const lines = [sleepTrendSentence(trend, chartDays())];
- // Days before logging began (or a gap in it) read as empty bars; say they
- // were skipped so the line isn't taken to have ignored real data.
- const blank = days.filter((d, i) => i < days.length - 1 && !d.excluded && !(d.sleepHours > 0)).length;
- if (blank > 0) {
- lines.push(`${blank} ${blank === 1 ? "day" : "days"} with no sleep logged ${blank === 1 ? "is" : "are"} left out.`);
+ const lines = [sentence];
+ if (skipped > 0) {
+ lines.push(`${skipped} ${skipped === 1 ? "day" : "days"} ${reason} ${skipped === 1 ? "is" : "are"} left out.`);
}
note.textContent = lines.join(" ");
note.hidden = false;
}
+ // The dashed fit, over the days it was fitted on and clamped to the plot so
+ // a steep one can't draw outside the axes. Shared by the sleep and walk bars,
+ // which lay out their slots the same way.
+ function trendLineSVG(cls, trend, { ML, MT, innerH, barW, gap, yMax }) {
+ const cx = (i) => ML + i * (barW + gap) + barW / 2;
+ const cy = (v) => MT + innerH * (1 - Math.min(Math.max(v, 0), yMax) / yMax);
+ return ``;
+ }
+
function drawCountsChart(days) {
const svg = document.getElementById("chart-counts");
const W = 320, H = 180;
@@ -2560,7 +2573,7 @@
// Minutes walked per day. Hidden until there's a walk to show, like the
// grams chart — no point in an empty panel for someone who doesn't log walks.
- function drawWalkChart(days) {
+ function drawWalkChart(days, firstWalkYmd) {
const wrap = document.getElementById("walk-chart-wrap");
const svg = document.getElementById("chart-walk");
if (!days.some(d => d.walkMinutes > 0)) { wrap.hidden = true; return; }
@@ -2613,6 +2626,15 @@
}
});
+ // Unlike sleep, a day with no walk is a real figure — a rest day, a wet
+ // one — so zeros are fitted. What isn't is the days before the first walk
+ // ever logged: those are from before anyone was tracking walks, and would
+ // start the line at zero and show a climb that never happened.
+ const trend = dailyTrend(days, d => d.ymd < firstWalkYmd ? null : d.walkMinutes);
+ if (trend) parts.push(trendLineSVG("walk-trend-line", trend, { ML, MT, innerH, barW, gap, yMax }));
+ const before = days.filter((d, i) => i < days.length - 1 && !d.excluded && d.ymd < firstWalkYmd).length;
+ renderTrendNote("walk-note", walkTrendSentence(trend, chartDays()), before, "from before the first walk was logged");
+
setChartSVG(svg, parts);
}
@@ -2620,7 +2642,8 @@
const days = weeklyData(events);
drawSleepChart(days);
drawCountsChart(days);
- drawWalkChart(days);
+ const firstWalk = events.reduce((m, e) => e.type === "walk-start" && (m == null || e.at < m) ? e.at : m, null);
+ drawWalkChart(days, firstWalk == null ? "" : ymd(new Date(firstWalk)));
drawGramsChart(days);
}
diff --git a/src/changelog.json b/src/changelog.json
index 320ca68..66bc213 100644
--- a/src/changelog.json
+++ b/src/changelog.json
@@ -1,4 +1,5 @@
[
+ { "date": "2026-09-29", "text": "The Walks chart (minutes per day) has a trend line too, with a sentence under it in the same style as the sleep one: “daily walking is up about 20m — from roughly 35m a day to 55m”, or roughly steady with the average when the days vary more than they move. A day with no walk counts as a real zero — a rest day is a real figure — but the days before the very first walk you logged are left out, so starting to track walks partway through the window doesn't read as a sudden climb. Today and days marked “not counted” are left out as on every other trend" },
{ "date": "2026-09-29", "text": "The Sleep chart on the Sleep tab has a trend line through it, like the Food (grams) chart, so you can see whether he is sleeping less as he grows — the day-to-day bars vary enough to hide a steady change. A line under the chart puts it in figures: “daily sleep is down about 1.5h — from roughly 17h a day to 15.5h”, or, when the days scatter more than they move, that it is roughly steady and what the average is. Today is left out until it's over, as are days marked “not counted” and days with no sleep logged at all, which the sentence mentions so an empty bar isn't mistaken for a night without sleep. It follows the 7 / 14 / 30 day picker like the rest of the charts" },
{ "date": "2026-09-29", "text": "The Timing panel no longer counts the night. The gap from each day's last pee, poo or meal to the next morning's first was being measured like any other, so every window held several eight-hour-plus “gaps” that were really just bedtime — the longest figure was a sleep figure and the typical gap was pulled up with it. Only gaps within a single day are measured now, so the bars show how often he needs to go out while he's up and about. The “since the last one” marker is unchanged, so first thing in the morning it still reads as overdue — which, before the first trip out, it is" },
{ "date": "2026-09-26", "text": "Tapping the tab you are already on scrolls back to the top of the page, the way it does in most phone apps — handy after scrolling a long way down Habits or the history. Switching to a different tab still leaves you where you were, as before" },
diff --git a/src/index.html b/src/index.html
index 95526ed..26e204a 100644
--- a/src/index.html
+++ b/src/index.html
@@ -334,7 +334,9 @@
No walks yet for this day. Use 🦮 Walk start / 🏁 Walk end to time one.
Minutes per day (last 7 days)
-
+
+
+
diff --git a/src/style.css b/src/style.css
index 8c7fa59..996a024 100644
--- a/src/style.css
+++ b/src/style.css
@@ -17,6 +17,9 @@
flip with the theme; the brights don't. --sleep itself was doing both
jobs and failing the second — 2.6:1 on the timer pill it painted. */
--sleep-ink: #4258cc;
+ /* Same idea for walks: the green is a fill, and a line drawn over the
+ green bars needs a shade that stands off them in either theme. */
+ --walk-ink: #22683d;
--wake: #f2b705;
--wake-ink: #6f4d00;
/* The two timers, on the dark theme, take a near-white with a sixth of the
@@ -47,6 +50,7 @@
--accent: #a690ff;
--accent-soft: #2a2640;
--sleep-ink: #8ba4ff;
+ --walk-ink: #7fd49c;
--wake-ink: #f5c451;
--wake-timer-ink: #fdf4da;
--border: #2c2a3a;
@@ -61,6 +65,7 @@
--accent: #a690ff;
--accent-soft: #2a2640;
--sleep-ink: #8ba4ff;
+ --walk-ink: #7fd49c;
--wake-ink: #f5c451;
--wake-timer-ink: #fdf4da;
--border: #2c2a3a;
@@ -1369,15 +1374,18 @@ input.switch:checked::after { transform: translateX(18px); }
stroke-linecap: round;
fill: none;
}
-/* The sleep bars are --sleep, so the fit through them takes the ink shade —
- darker in light mode, lighter in dark — to stay visible where it crosses one. */
-.chart-svg .sleep-trend {
+/* The sleep and walk bars are filled with --sleep and --walk, so the fit
+ through each takes its ink shade — darker in light mode, lighter in dark —
+ to stay visible where it crosses a bar. */
+.chart-svg .sleep-trend,
+.chart-svg .walk-trend-line {
stroke: var(--sleep-ink);
stroke-width: 2;
stroke-dasharray: 5 3;
stroke-linecap: round;
fill: none;
}
+.chart-svg .walk-trend-line { stroke: var(--walk-ink); }
.legend .sw.food-sw { background: var(--food-color, var(--muted)); }
.kind-field { margin-bottom: 10px; }