Add a day timeline, trend chart and goal history to the dashboard
Test and publish / test (push) Failing after 47s
Test and publish / publish (push) Has been skipped

The dashboard gains a per-kind timeline of the selected day, a 14-day
trend chart per kind, and a goal history grid with streaks, sharing a
tooltip and a fixed color per top series. The activities limit rises
to 5000 so busy days fit on the timeline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-14 22:50:00 +01:00
co-authored by Claude Opus 5.5
parent cfe17ecf5d
commit 7f7650252d
8 changed files with 395 additions and 11 deletions
+14 -1
View File
@@ -39,5 +39,18 @@ export function dur(s: number): string {
}
// Friendlier names for the kinds collectors send; anything else shows as is.
const KINDS: Record<string, string> = { app_focus: "desktop", tab_focus: "browser", at_desk: "at desk", in_bed: "in bed" };
const KINDS: Record<string, string> = { app_focus: "desktop", tab_focus: "browser", at_desk: "at desk", in_bed: "in bed", place: "location" };
export const kindName = (k: string) => KINDS[k] || k;
// Series colors: the day's biggest (kind, label) pairs get a fixed slot each,
// in order; the rest share a neutral "other" color.
export const SLOTS = 7;
export const IDLE = new Set(["idle", "locked"]);
export const seriesKey = (kind: string, label: string) => kind + "\0" + label;
export function seriesSlots(totals: Total[]): Map<string, number> {
const m = new Map<string, number>();
[...totals].filter(t => !IDLE.has(t.kind)).sort((a, b) => b.seconds - a.seconds)
.slice(0, SLOTS).forEach((t, i) => m.set(seriesKey(t.kind, t.label), i));
return m;
}
export const slotColor = (i: number | undefined) => i === undefined ? "var(--other)" : `var(--s${i + 1})`;
+99
View File
@@ -0,0 +1,99 @@
<script setup lang="ts">
import { computed } from "vue";
import { IDLE, dur, kindName, seriesKey, slotColor, type Activity } from "../api";
import { useTip } from "../tip";
import Tooltip from "./Tooltip.vue";
const props = defineProps<{ activities: Activity[]; from: string; to: string; slots: Map<string, number> }>();
const { tip, show, hide } = useTip();
// Lanes in a fixed order so they don't jump between days; unknown kinds go last.
const ORDER = ["place", "app_focus", "tab_focus", "at_desk", "in_bed", "away", "idle", "locked"];
const t0 = computed(() => +new Date(props.from));
const span = computed(() => +new Date(props.to) - t0.value);
const at = (t: number) => Math.min(Math.max((t - t0.value) / span.value, 0), 1) * 100;
const time = (t: string) => new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
const lanes = computed(() => {
const by = new Map<string, Activity[]>();
for (const a of props.activities) by.set(a.kind, [...by.get(a.kind) ?? [], a]);
const rank = (k: string) => ORDER.includes(k) ? ORDER.indexOf(k) : ORDER.length;
return [...by.entries()].sort(([a], [b]) => rank(a) - rank(b) || a.localeCompare(b)).map(([kind, acts]) => ({
kind,
segs: acts.map(a => {
const l = at(+new Date(a.started_at));
return {
a, left: l, width: at(+new Date(a.ended_at)) - l,
color: IDLE.has(kind) ? "var(--idle)" : slotColor(props.slots.get(seriesKey(a.kind, a.label))),
};
}).filter(s => s.width > 0),
}));
});
// Gridlines every three hours (by elapsed time, so DST days still line up).
const ticks = computed(() => {
const out = [];
for (let h = 0; h * 3600e3 <= span.value; h += 3) {
const t = t0.value + h * 3600e3;
out.push({ left: at(t), text: new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) });
}
return out;
});
const now = computed(() => {
const n = Date.now();
return n > t0.value && n < t0.value + span.value ? at(n) : null;
});
const legend = computed(() => {
const seen = new Map<string, { label: string; kind: string; color: string }>();
let other = false, idle = false;
for (const a of props.activities) {
if (IDLE.has(a.kind)) { idle = true; continue; }
const i = props.slots.get(seriesKey(a.kind, a.label));
if (i === undefined) other = true;
else seen.set(String(i), { label: a.label || kindName(a.kind), kind: kindName(a.kind), color: slotColor(i) });
}
const items = [...seen.entries()].sort(([a], [b]) => +a - +b).map(([, v]) => v);
if (other) items.push({ label: "Other", kind: "", color: slotColor(undefined) });
if (idle) items.push({ label: "Idle or locked", kind: "", color: "var(--idle)" });
return items;
});
function enter(e: MouseEvent, s: { a: Activity; color: string }) {
show(e, [
{ text: dur(s.a.duration_s) },
{ text: `${s.a.label || kindName(s.a.kind)} · ${kindName(s.a.kind)}`, color: s.color },
{ text: `${time(s.a.started_at)}–${time(s.a.ended_at)}` },
]);
}
</script>
<template>
<div class="timeline" @mouseleave="hide">
<div v-for="l in lanes" :key="l.kind" class="lane">
<div class="lane-name">{{ kindName(l.kind) }}</div>
<div class="track">
<div v-for="t in ticks" :key="t.left" class="grid" :style="{ left: t.left + '%' }"></div>
<div v-for="(s, i) in l.segs" :key="i" class="seg"
:style="{ left: s.left + '%', width: `max(1px, calc(${s.width}% - 1px))`, background: s.color }"
@mousemove="enter($event, s)" @mouseleave="hide"></div>
<div v-if="now !== null" class="now" :style="{ left: now + '%' }"></div>
</div>
</div>
<div class="lane axis">
<div class="lane-name"></div>
<div class="track">
<span v-for="(t, i) in ticks" :key="t.left" class="tick"
:class="{ first: i === 0, last: i === ticks.length - 1 }" :style="{ left: t.left + '%' }">{{ t.text }}</span>
</div>
</div>
<p v-if="!lanes.length" class="muted">Nothing recorded.</p>
<div v-else class="legend">
<span v-for="it in legend" :key="it.label + it.kind" class="legend-item">
<span class="swatch" :style="{ background: it.color }"></span>{{ it.label }}
<span v-if="it.kind" class="muted small-text">{{ it.kind }}</span>
</span>
</div>
<Tooltip :tip="tip" />
</div>
</template>
+48
View File
@@ -0,0 +1,48 @@
<script setup lang="ts">
import { computed } from "vue";
import { dur, kindName, type Goal, type Summary } from "../api";
import { useTip } from "../tip";
import Tooltip from "./Tooltip.vue";
const props = defineProps<{ days: { date: string; sum: Summary | null }[]; selected: string }>();
const emit = defineEmits<{ select: [date: string] }>();
const { tip, show, hide } = useTip();
const key = (g: Goal) => [g.kind, g.label, g.op, g.target_s].join("\0");
const noon = (d: string) => new Date(d + "T12:00:00");
const rows = computed(() => {
const goals = new Map<string, Goal>();
for (const d of props.days) for (const g of d.sum?.goals ?? []) goals.set(key(g), g);
return [...goals.entries()].map(([k, g]) => {
const cells = props.days.map(d => ({ date: d.date, g: d.sum?.goals.find(x => key(x) === k) }));
// Days met in a row, counting back from the selected day.
let streak = 0;
for (let i = cells.findIndex(c => c.date === props.selected); i >= 0 && cells[i].g?.met; i--) streak++;
return { k, name: `${kindName(g.kind)}${g.label ? " · " + g.label : ""} ${g.op} ${dur(g.target_s)}`, cells, streak };
});
});
function enter(e: MouseEvent | FocusEvent, date: string, g?: Goal) {
const day = noon(date).toLocaleDateString([], { weekday: "short", day: "numeric", month: "short" });
show(e, g ? [{ text: `${g.met ? "✓ met" : "✗ missed"} · ${dur(g.actual_s)}` }, { text: day }] : [{ text: "–" }, { text: day }]);
}
</script>
<template>
<div class="history" @mouseleave="hide">
<div v-for="r in rows" :key="r.k" class="hrow">
<div class="name">{{ r.name }}</div>
<div class="cells">
<button v-for="c in r.cells" :key="c.date" class="cell"
:class="[c.g ? (c.g.met ? 'met' : 'miss') : 'none', { sel: c.date === selected }]"
:aria-label="`${c.date}: ${c.g ? (c.g.met ? 'met' : 'missed') : 'no data'}`"
@click="emit('select', c.date)" @mousemove="enter($event, c.date, c.g)"
@focus="enter($event, c.date, c.g)" @blur="hide">{{ c.g ? (c.g.met ? "✓" : "✗") : "" }}</button>
</div>
<div class="streak muted small-text">{{ r.streak ? `${r.streak}d streak` : "" }}</div>
</div>
<p v-if="!rows.length" class="muted">No goals yet.</p>
<Tooltip :tip="tip" />
</div>
</template>
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import type { TipRow } from "../tip";
defineProps<{ tip: { show: boolean; x: number; y: number; rows: TipRow[] } }>();
</script>
<template>
<Teleport to="body">
<div v-if="tip.show" class="tooltip" role="tooltip"
:style="{ left: tip.x + 'px', top: tip.y + 'px' }">
<div v-for="(r, i) in tip.rows" :key="i" :class="i ? 'muted' : 'strong'">
<span v-if="r.color" class="key" :style="{ background: r.color }"></span>{{ r.text }}
</div>
</div>
</Teleport>
</template>
+71
View File
@@ -0,0 +1,71 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { IDLE, dur, kindName, type Summary } from "../api";
import { useTip } from "../tip";
import Tooltip from "./Tooltip.vue";
const props = defineProps<{ days: { date: string; sum: Summary | null }[]; selected: string }>();
const emit = defineEmits<{ select: [date: string] }>();
const { tip, show, hide } = useTip();
const kinds = computed(() => {
const s = new Map<string, number>();
for (const d of props.days)
for (const [k, v] of Object.entries(d.sum?.by_kind ?? {})) if (!IDLE.has(k)) s.set(k, (s.get(k) ?? 0) + v);
return [...s.entries()].sort((a, b) => b[1] - a[1]).map(([k]) => k);
});
const kind = ref("app_focus");
watch(kinds, ks => { if (ks.length && !ks.includes(kind.value)) kind.value = ks[0]; });
const noon = (d: string) => new Date(d + "T12:00:00");
const cols = computed(() => props.days.map(d => ({
date: d.date,
loaded: !!d.sum,
s: d.sum?.by_kind[kind.value] ?? 0,
day: noon(d.date).getDate(),
long: noon(d.date).toLocaleDateString([], { weekday: "short", day: "numeric", month: "short" }),
})));
// A clean step (in hours) that gives at most four gridlines.
const scale = computed(() => {
const max = Math.max(...cols.value.map(c => c.s), 1);
const step = [0.25, 0.5, 1, 2, 3, 4, 6, 8, 12].find(h => max / (h * 3600) <= 4) ?? 12;
const n = Math.max(1, Math.ceil(max / (step * 3600)));
return { top: n * step * 3600, lines: Array.from({ length: n + 1 }, (_, i) => i * step * 3600) };
});
const h = (s: number) => `${s / scale.value.top * 100}%`;
const tick = (s: number) => s === 0 ? "0" : s < 3600 ? `${s / 60}m` : `${s / 3600}h`;
function enter(e: MouseEvent | FocusEvent, c: (typeof cols.value)[number]) {
show(e, [{ text: c.loaded ? dur(c.s) : "–" }, { text: `${kindName(kind.value)} · ${c.long}` }]);
}
</script>
<template>
<div class="trend">
<div class="row spread">
<h2>Last {{ days.length }} days</h2>
<select v-model="kind" aria-label="Measure">
<option v-for="k in kinds" :key="k" :value="k">{{ kindName(k) }}</option>
</select>
</div>
<div class="plot">
<div class="yaxis">
<span v-for="l in scale.lines" :key="l" :style="{ bottom: h(l) }">{{ tick(l) }}</span>
</div>
<div class="area" @mouseleave="hide">
<div v-for="l in scale.lines" :key="l" class="grid" :class="{ base: l === 0 }" :style="{ bottom: h(l) }"></div>
<button v-for="c in cols" :key="c.date" class="col" :class="{ sel: c.date === selected }"
:aria-label="`${c.long}: ${c.loaded ? dur(c.s) : 'not loaded'}`"
@click="emit('select', c.date)" @mousemove="enter($event, c)" @focus="enter($event, c)" @blur="hide">
<span v-if="c.date === selected && c.s" class="cap" :style="{ bottom: h(c.s) }">{{ dur(c.s) }}</span>
<span class="bar-v" :style="{ height: h(c.s) }"></span>
</button>
</div>
</div>
<div class="xaxis">
<span v-for="c in cols" :key="c.date" :class="{ sel: c.date === selected }">{{ c.day }}</span>
</div>
<Tooltip :tip="tip" />
</div>
</template>
+69
View File
@@ -2,11 +2,18 @@
:root {
--bg:#f6f6f4; --card:#ffffff; --fg:#1b1b1b; --muted:#6b6b6b; --line:#e4e4e0;
--accent:#3d6fc4; --accent-soft:#e8eefa; --ok:#2e8b57; --bad:#c0392b; --code:#f2f2ef;
/* Chart series, in fixed order (validated for colour-blind separation). */
--s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100; --s5:#e87ba4; --s6:#008300; --s7:#6250d6;
--other:#b9b8b1; --idle:#e6e5e0; --grid:#ecebe6; --axis:#c3c2b7;
--ok-soft:#e3f2e9; --bad-soft:#f8e4e1;
}
@media (prefers-color-scheme: dark) {
:root {
--bg:#121212; --card:#1b1b1b; --fg:#e8e8e8; --muted:#9a9a9a; --line:#2c2c2c;
--accent:#7aa2ea; --accent-soft:#1e2a40; --ok:#5cc28a; --bad:#e2685a; --code:#232323;
--s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500; --s5:#d55181; --s6:#008300; --s7:#9085e9;
--other:#5a5955; --idle:#2e2e2c; --grid:#262625; --axis:#383835;
--ok-soft:#18301f; --bad-soft:#3a1f1c;
}
}
* { box-sizing:border-box; }
@@ -80,3 +87,65 @@ details.collector > summary::before { content:"▸"; color:var(--muted); }
details.collector[open] > summary::before { content:"▾"; }
details.collector > summary b { font-size:15px; }
details.collector > .body { padding:0 16px 16px; }
/* ---- charts ---- */
.tooltip { position:fixed; z-index:10; pointer-events:none; transform:translate(-50%, calc(-100% - 12px));
background:var(--card); border:1px solid var(--line); border-radius:8px; padding:6px 10px;
box-shadow:0 4px 14px rgba(0,0,0,.12); font-size:13px; white-space:nowrap; max-width:80vw; overflow:hidden; text-overflow:ellipsis; }
.tooltip .strong { font-weight:650; font-size:14px; font-variant-numeric:tabular-nums; }
.tooltip .key { display:inline-block; width:10px; height:2px; margin:0 6px 3px 0; vertical-align:middle; border-radius:1px; }
.legend { display:flex; flex-wrap:wrap; gap:6px 14px; margin-top:12px; font-size:13px; }
.legend-item { display:inline-flex; align-items:center; gap:6px; overflow-wrap:anywhere; }
.swatch { width:10px; height:10px; border-radius:3px; flex:none; }
.timeline .lane { display:flex; align-items:center; gap:8px; }
.timeline .lane + .lane { margin-top:6px; }
.timeline .lane-name { width:64px; flex:none; font-size:13px; color:var(--muted); text-align:right; }
.timeline .track { position:relative; flex:1; height:18px; min-width:0; }
.timeline .axis .track { height:16px; }
.timeline .grid { position:absolute; top:-3px; bottom:-3px; width:1px; background:var(--grid); }
.timeline .seg { position:absolute; top:0; bottom:0; border-radius:3px; }
.timeline .seg:hover { filter:brightness(1.15); }
.timeline .now { position:absolute; top:-4px; bottom:-4px; width:2px; margin-left:-1px; background:var(--fg); border-radius:1px; }
.timeline .tick { position:absolute; transform:translateX(-50%); font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.timeline .tick.first { transform:none; }
.timeline .tick.last { transform:translateX(-100%); }
@media (max-width:520px) { .timeline .tick:nth-child(even) { display:none; } }
.meter { position:relative; height:6px; margin-top:6px; border-radius:3px; background:var(--accent-soft); max-width:320px; }
.meter .fill { height:100%; border-radius:3px; background:var(--accent); }
.meter.bad .fill { background:var(--bad); }
.meter .target { position:absolute; top:-3px; bottom:-3px; width:2px; margin-left:-1px; background:var(--fg); border-radius:1px; }
.trend .plot { display:flex; gap:8px; height:140px; margin-top:22px; }
.trend .yaxis { position:relative; width:32px; flex:none; }
.trend .yaxis span { position:absolute; right:0; transform:translateY(50%); font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.trend .area { position:relative; flex:1; display:flex; min-width:0; }
.trend .grid { position:absolute; left:0; right:0; height:1px; background:var(--grid); }
.trend .grid.base { background:var(--axis); }
.trend .col { position:relative; flex:1; height:100%; display:flex; align-items:flex-end; justify-content:center;
background:none; border:0; border-radius:4px; padding:0; }
.trend .col:hover { background:var(--accent-soft); }
.trend .bar-v { width:min(24px, calc(100% - 4px)); background:var(--s1); border-radius:4px 4px 0 0; opacity:.55; }
.trend .col.sel .bar-v { opacity:1; }
.trend .cap { position:absolute; transform:translateY(-4px); font-size:12px; font-weight:600; white-space:nowrap; font-variant-numeric:tabular-nums; }
.trend .xaxis { display:flex; margin-left:40px; margin-top:4px; }
.trend .xaxis span { flex:1; text-align:center; font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.trend .xaxis span.sel { color:var(--fg); font-weight:650; }
.history .hrow { display:grid; grid-template-columns:minmax(0, 1fr) auto 76px; gap:6px 12px; align-items:center;
padding:7px 0; border-bottom:1px solid var(--line); }
.history .hrow:last-of-type { border-bottom:0; }
.history .name { overflow-wrap:anywhere; }
.history .cells { display:flex; gap:2px; }
.history .streak { text-align:right; white-space:nowrap; }
@media (max-width:620px) {
.history .hrow { grid-template-columns:1fr auto; }
.history .cells { grid-row:2; grid-column:1 / -1; }
}
.history .cell { width:22px; height:22px; padding:0; border:0; border-radius:4px; font-size:12px; line-height:22px; text-align:center; flex:none; }
@media (max-width:420px) { .history .cell { width:auto; flex:1; } }
.history .cell.met { background:var(--ok-soft); color:var(--ok); }
.history .cell.miss { background:var(--bad-soft); color:var(--bad); }
.history .cell.none { background:var(--code); }
.history .cell.sel { outline:2px solid var(--fg); outline-offset:1px; }
+19
View File
@@ -0,0 +1,19 @@
import { reactive } from "vue";
// One floating tooltip per chart. The first line is the value, shown strongest.
export interface TipRow { text: string; color?: string }
export function useTip() {
const tip = reactive({ show: false, x: 0, y: 0, rows: [] as TipRow[] });
function show(e: MouseEvent | FocusEvent, rows: TipRow[]) {
if (e instanceof MouseEvent) {
tip.x = e.clientX; tip.y = e.clientY;
} else {
const r = (e.target as Element).getBoundingClientRect();
tip.x = r.left + r.width / 2; tip.y = r.top;
}
tip.rows = rows;
tip.show = true;
}
const hide = () => { tip.show = false; };
return { tip, show, hide };
}
+59 -10
View File
@@ -1,8 +1,12 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { api, dur, kindName, type Activity, type Summary } from "../api";
import { computed, reactive, ref, watch } from "vue";
import { api, dur, kindName, seriesKey, seriesSlots, slotColor, type Activity, type Summary } from "../api";
import DayTimeline from "../components/DayTimeline.vue";
import GoalHistory from "../components/GoalHistory.vue";
import TrendChart from "../components/TrendChart.vue";
const LIMIT = 500;
const LIMIT = 5000;
const TREND_DAYS = 14;
const today = () => new Date().toLocaleDateString("en-CA"); // YYYY-MM-DD in local time
const noon = (d: string) => new Date(d + "T12:00:00");
@@ -11,6 +15,9 @@ const sum = ref<Summary | null>(null);
const activities = ref<Activity[]>([]);
const loading = ref(false);
const error = ref("");
// Summaries for the trend charts, kept across day changes. The selected day's
// is always refetched since today's is still growing.
const history = reactive<Record<string, Summary>>({});
const daysAgo = computed(() => Math.round((+noon(today()) - +noon(date.value)) / 864e5));
const title = computed(() => daysAgo.value === 0 ? "Today" : daysAgo.value === 1 ? "Yesterday"
@@ -29,6 +36,7 @@ async function load() {
if (n !== seq) return;
sum.value = s;
activities.value = acts;
history[s.date] = s;
} catch (e) {
if (n === seq) error.value = (e as Error).message;
} finally {
@@ -37,11 +45,31 @@ async function load() {
}
watch(date, load, { immediate: true });
function shift(days: number) {
const d = noon(date.value);
d.setDate(d.getDate() + days);
date.value = d.toLocaleDateString("en-CA");
}
const addDays = (d: string, n: number) => {
const x = noon(d);
x.setDate(x.getDate() + n);
return x.toLocaleDateString("en-CA");
};
const trendDays = computed(() => {
// Runs up to a week past the selected day, but never past today.
let end = date.value;
for (let i = 0; i < TREND_DAYS / 2 && end < today(); i++) end = addDays(end, 1);
return Array.from({ length: TREND_DAYS }, (_, i) => addDays(end, i - TREND_DAYS + 1))
.map(d => ({ date: d, sum: history[d] ?? null }));
});
const pending = new Set<string>();
watch(() => trendDays.value.map(d => d.date), days => {
for (const d of days) {
if (d in history || d === date.value || pending.has(d)) continue;
pending.add(d);
api<Summary>("GET", "summary/daily?date=" + d)
.then(s => { history[d] = s; }, () => {})
.finally(() => pending.delete(d));
}
}, { immediate: true });
const shift = (days: number) => { date.value = addDays(date.value, days); };
const slots = computed(() => seriesSlots(sum.value?.totals ?? []));
const top = computed(() => sum.value?.totals
.filter(t => t.kind === "app_focus" || t.kind === "tab_focus")
@@ -57,6 +85,11 @@ const timeline = computed(() => activities.value.filter(a => a.duration_s >= 60)
const time = (t: string) => new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
const pct = (v: number, max: number) => `${v / (max || 1) * 100}%`;
// The goal meter's scale fits both the target and the actual time.
const meter = (g: Summary["goals"][number]) => {
const max = Math.max(g.target_s, g.actual_s, 1);
return { fill: pct(g.actual_s, max), target: pct(g.target_s, max) };
};
</script>
<template>
@@ -87,13 +120,29 @@ const pct = (v: number, max: number) => `${v / (max || 1) * 100}%`;
<section class="card"><h2>Goals</h2><div class="tablewrap"><table>
<tr v-for="(g, i) in sum.goals" :key="i">
<td class="label">{{ kindName(g.kind) }}{{ g.label ? " · " + g.label : "" }}
<span class="muted">{{ g.op }} {{ dur(g.target_s) }}</span></td>
<span class="muted">{{ g.op }} {{ dur(g.target_s) }}</span>
<div class="meter" :class="g.met ? 'ok' : 'bad'">
<div class="fill" :style="{ width: meter(g).fill }"></div>
<div class="target" :style="{ left: meter(g).target }" title="Target"></div>
</div></td>
<td class="num">{{ dur(g.actual_s) }}</td>
<td class="num" :class="g.met ? 'ok' : 'bad'">{{ g.met ? "✓ met" : "✗ missed" }}</td>
</tr>
<tr v-if="!sum.goals.length"><td class="muted">No goals yet. See <RouterLink to="/setup#goals">Setup</RouterLink>.</td></tr>
</table></div></section>
<section class="card"><h2>Day at a glance</h2>
<DayTimeline :activities="activities" :from="sum.from" :to="sum.to" :slots="slots" />
</section>
<section class="card">
<TrendChart :days="trendDays" :selected="date" @select="date = $event" />
</section>
<section v-if="sum.goals.length" class="card"><h2>Goal history</h2>
<GoalHistory :days="trendDays" :selected="date" @select="date = $event" />
</section>
<section class="card"><h2>By kind</h2><div class="tablewrap"><table>
<tr v-for="[k, s] in kinds" :key="k">
<td class="label">{{ kindName(k) }}<div class="bar" :style="{ width: pct(s, kinds[0][1]) }"></div></td>
@@ -105,7 +154,7 @@ const pct = (v: number, max: number) => `${v / (max || 1) * 100}%`;
<section class="card"><h2>Top labels</h2><div class="tablewrap"><table>
<tr v-for="t in labels" :key="t.kind + '\0' + t.label">
<td class="label">{{ t.label || "—" }} <span class="badge">{{ kindName(t.kind) }}</span>
<div class="bar" :style="{ width: pct(t.seconds, labels[0].seconds) }"></div></td>
<div class="bar" :style="{ width: pct(t.seconds, labels[0].seconds), background: slotColor(slots.get(seriesKey(t.kind, t.label))) }"></div></td>
<td class="num">{{ dur(t.seconds) }}</td>
</tr>
<tr v-if="!labels.length"><td class="muted">Nothing recorded.</td></tr>