No.426 · Analytics
Calendar Heatmap
A year of daily activity, one square per day on a single-hue ramp; hover or arrow through the year to read any day exactly.
The prompt
Written for the variant you picked above: Light
Build a calendar heatmap of a year of daily values in SVG with no chart library: 53 Monday-first week columns of seven 12px rounded squares (3px gaps), month labels over the first week of each month and Mon/Wed/Fri row labels. Each day is shaded on a six-step single-hue sequential ramp (empty, then light to dark blue, with the dark theme re-stepped rather than inverted) by its value relative to the year's maximum. The headline is the year's total; three derived stats sit under it — busiest day, longest streak of active days, quietest weekday. Hover a day (or focus the calendar and move with the arrow keys: ±1 day vertically, ±1 week horizontally, Home/End) to outline it and read "Sat 14 Feb: 37 bookings" in a polite live line below. A Less → More legend shows the ramp. A year switch recolours the squares with a short fill transition that sweeps across the weeks (6ms per column). Monthly totals are also in a visually hidden table. The demo data is seeded and plausible: busier in winter and at weekends, quiet on Fridays, softer during Ramadan. Selected variant — Light (light): Apply the light theme. Where the brief above gives no colour values for it, choose a restrained light palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Hover a day, or focus the calendar and use the arrow keys, to read exact values; switch the year above. Motion: Year switch: fills transition 420ms, staggered 6ms per week column. Accessibility: The calendar is a focusable role="img" with a summary and full arrow-key reading through a polite live line; monthly totals are in a visually hidden table; the legend explains the ramp. Reduced motion recolours instantly. Responsive behavior: Scales with its container; the calendar scrolls horizontally inside its card on narrow screens rather than shrinking squares. Touch: Tap to highlight; the table view covers precise reading. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Hover a day, or focus the calendar and use the arrow keys, to read exact values; switch the year above.
- Motion
- Year switch: fills transition 420ms, staggered 6ms per week column.
- Accessibility
- The calendar is a focusable role="img" with a summary and full arrow-key reading through a polite live line; monthly totals are in a visually hidden table; the legend explains the ramp. Reduced motion recolours instantly.
- Responsive
- Scales with its container; the calendar scrolls horizontally inside its card on narrow screens rather than shrinking squares.
- On touch
- Tap to highlight; the table view covers precise reading.