Skip to content

Commit 2bff2f4

Browse files
ryan-williamsclaude
andcommitted
HourlyChart: categorical hour labels + every-hour ticks
The unified-hover header read the raw x value (`8`) instead of the `ticktext` mapping, so hovering at 8 am showed "8" rather than "8am". Switch to a categorical x axis whose values are already the "12am"…"11pm" labels, and tick every hour (rotated -45° on narrow screens to fit). Header now shows "8am" naturally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ade7c99 commit 2bff2f4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

www/src/components/HourlyChart.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export default function HourlyChart({ data }: { data: HourlyRecord[] }) {
9595
return {
9696
type: 'bar' as const,
9797
name: labels[key] ?? key,
98-
x: HOURS,
98+
// Categorical x using formatted hour labels — so the `x unified`
99+
// tooltip header shows "8am" instead of the raw `8`.
100+
x: HOURS.map(h => HOUR_LABELS[h]),
99101
y: HOURS.map(h => hourMap.get(h) ?? 0),
100102
marker: { color: colors[key] },
101103
hovertemplate: `%{y:,.0f}<extra>${labels[key] ?? key}</extra>`,
@@ -111,8 +113,11 @@ export default function HourlyChart({ data }: { data: HourlyRecord[] }) {
111113
bargap: 0.15,
112114
xaxis: {
113115
...baseLayout.xaxis,
114-
tickvals: HOURS.filter(h => h % 3 === 0),
115-
ticktext: HOURS.filter(h => h % 3 === 0).map(h => HOUR_LABELS[h]),
116+
type: 'category' as const,
117+
// Tick every hour. On narrow viewports labels are rotated to fit.
118+
tickmode: 'array' as const,
119+
tickvals: HOURS.map(h => HOUR_LABELS[h]),
120+
tickangle: narrow ? -45 : 0,
116121
},
117122
yaxis: {
118123
...baseLayout.yaxis,

0 commit comments

Comments
 (0)