Leave a day that doesn't count off the trends entirely
The Sleep and Walk trends already kept a day marked "not counted" out of the window average and out of the "yesterday" comparison. What they still drew was that day's own curve, when it was the day you had selected — as the boldest line on the panel. So the single day you had said not to trust was the one the chart led with, against references that had carefully excluded it. It is left off now, along with its legend chip and, for the sleep trend, the projected tail that continued it. What remains is the average and yesterday, which is what you would want to look at on a day like that. This reverses part of an earlier fix. That one stopped the curve being drawn as a flat zero, on the reasoning that marking a day means "don't let it drag the average" rather than "pretend nothing happened". The flat zero was certainly wrong, but so was the conclusion: a real curve for an untrusted day is still the wrong thing to lead with. Absent is the honest third option. The walk trend gets the same treatment. It is the same panel in different units, and the two disagreeing about what a marked day means would be worse than either answer.
This commit is contained in:
+28
-9
@@ -1997,9 +1997,12 @@
|
||||
};
|
||||
const totalOf = (pts) => pts[pts.length - 1].y;
|
||||
|
||||
const today = curveFor(dayStartTs(0), isToday ? Date.now() : null);
|
||||
// Same as the sleep trend: a day that doesn't count is dropped as a
|
||||
// comparison rather than drawn flat at zero.
|
||||
// Left off entirely when the day is marked "not counted" — same reasoning
|
||||
// as the sleep trend: it is already out of the average and out of
|
||||
// "yesterday", so drawing it as the boldest line would contradict that.
|
||||
const dayExcluded = isExcluded(day);
|
||||
const today = dayExcluded ? null : curveFor(dayStartTs(0), isToday ? Date.now() : null);
|
||||
// Same rule for the comparison day: dropped rather than drawn flat at zero.
|
||||
const prev = curveFor(dayStartTs(1));
|
||||
const yesterday = (!isExcluded(dayAgo(1)) && totalOf(prev) > 0) ? prev : null;
|
||||
|
||||
@@ -2023,7 +2026,7 @@
|
||||
const fmtDay = (daysAgo) =>
|
||||
new Date(dayStartTs(daysAgo)).toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
||||
return {
|
||||
today, yesterday, avg, avgDays,
|
||||
today, yesterday, avg, avgDays, dayExcluded,
|
||||
dayLabel: isToday ? "Today" : fmtDay(0),
|
||||
prevDayLabel: isToday ? "Yesterday" : fmtDay(1),
|
||||
};
|
||||
@@ -2086,7 +2089,11 @@
|
||||
|
||||
const chip = (id) => document.getElementById(id);
|
||||
const mins = (pts) => `${Math.round(pts[pts.length - 1].y)} min`;
|
||||
chip("legend-wtrend-today-text").textContent = `${curves.dayLabel} ${mins(curves.today)}`;
|
||||
// No line for a day that doesn't count, so no chip for it either.
|
||||
chip("legend-wtrend-today").hidden = !curves.today;
|
||||
if (curves.today) {
|
||||
chip("legend-wtrend-today-text").textContent = `${curves.dayLabel} ${mins(curves.today)}`;
|
||||
}
|
||||
|
||||
const yLegend = chip("legend-wtrend-yesterday");
|
||||
yLegend.hidden = !curves.yesterday;
|
||||
@@ -2239,7 +2246,14 @@
|
||||
};
|
||||
|
||||
// A past day is complete, so its curve runs the full 24h uncapped.
|
||||
const today = curveFor(dayStartTs(0), isToday ? Date.now() : null);
|
||||
//
|
||||
// Unless the day is marked "not counted", in which case it is left off the
|
||||
// chart entirely. It is already out of the average and out of "yesterday",
|
||||
// and drawing it as the headline curve would put the one day you have said
|
||||
// not to trust in the boldest line on the panel. What remains is the
|
||||
// references — which is what you would want to see on a day like that.
|
||||
const dayExcluded = isExcluded(day);
|
||||
const today = dayExcluded ? null : curveFor(dayStartTs(0), isToday ? Date.now() : null);
|
||||
|
||||
// A day that doesn't count is no comparison at all, so it is dropped
|
||||
// outright rather than drawn as a flat line at zero. Checked explicitly
|
||||
@@ -2275,7 +2289,7 @@
|
||||
// No history → no average → no projection. Past days are already complete,
|
||||
// so there is nothing to project.
|
||||
let projected = null;
|
||||
if (avg && isToday) {
|
||||
if (avg && isToday && today) {
|
||||
const nowPt = today[today.length - 1];
|
||||
const avgAt = (x) => {
|
||||
const lo = Math.floor(x);
|
||||
@@ -2295,7 +2309,7 @@
|
||||
const dayLabel = isToday ? "Today" : fmtDay(0);
|
||||
const prevDayLabel = isToday ? "Yesterday" : fmtDay(1);
|
||||
|
||||
return { today, yesterday, avg, avgDays, projected, dayLabel, prevDayLabel };
|
||||
return { today, yesterday, avg, avgDays, projected, dayLabel, prevDayLabel, dayExcluded };
|
||||
}
|
||||
|
||||
function drawSleepTrendChart(curves, target) {
|
||||
@@ -2392,7 +2406,12 @@
|
||||
// write each curve's slept-hours total into its chip.
|
||||
const chip = (id) => document.getElementById(id);
|
||||
const hrs = (pts) => `${pts[pts.length - 1].y.toFixed(1)}h`;
|
||||
chip("legend-trend-today-text").textContent = `${curves.dayLabel} ${hrs(curves.today)}`;
|
||||
// No curve for a day that doesn't count, so no chip for it either — a
|
||||
// legend entry pointing at a line that isn't drawn is worse than none.
|
||||
chip("legend-trend-today").hidden = !curves.today;
|
||||
if (curves.today) {
|
||||
chip("legend-trend-today-text").textContent = `${curves.dayLabel} ${hrs(curves.today)}`;
|
||||
}
|
||||
const yLegend = chip("legend-trend-yesterday");
|
||||
yLegend.hidden = !curves.yesterday;
|
||||
if (curves.yesterday) {
|
||||
|
||||
Reference in New Issue
Block a user