Skip to content

No.422 · Analytics

Cohort Retention

Who keeps coming back: a retention triangle of monthly cohorts on one blue ramp that fills in along its diagonal, where pointing at (or arrowing to) a cell lights its row and column and the linked curves show that cohort against the size-weighted average.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Light

Build a cohort retention view: a real HTML table as the heatmap, linked to a small curve chart. Table: one row per monthly cohort (label, guest count) and one column per month since first booking (M0…M9), triangular because later cohorts have fewer months (the missing cells are faint empties). border-spacing 2px gives the surface gap between cells (4px radius). Each cell is shaded on the reference sequential blue ramp (13 steps, 100 → 700) by its share, with the percentage printed in ink (white on the darker steps). On first view the cells scale and fade in along the diagonal (45ms × (row + column)). Interaction: pointer or focus on a cell lights its row and column (row/column headers turn to full ink, other cells desaturate to 35%), outlines the cell, and updates the linked chart and a polite readout ("Mar, month 3: 46% — 371 of 806 guests (+8 pts vs average)"). Cells use roving tabindex; arrow keys move within the triangle. Each cell has a full aria-label. Linked chart (SVG): every cohort as a faint hairline, the size-weighted average as a dashed ink line, and the focused cohort (default: the best at month 3) in series slot 1 with a dot at the focused month; 0–100% gridlines; a caption legend. Header insight: "Mar's guests held on best — 46% still booking at month 3, against 38% on average." A 0–100% ramp legend under the table. Two columns, stacking under 760px (the table scrolls sideways if needed). Light and dark themes. Reduced motion: no reveal. Selected variant — Light (light): Palette for this theme (Light): --axis #c3c2b7; --empty #f3f2ee; --grid #e1e0d9; --ink #0b0b0b; --ink-2 #52514e; --ring rgba(11, 11, 11, 0.1); --s1 #2a78d6; --surface #fcfcfb. Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "light". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. 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: Point at a cell (or Tab into the table and use the arrows) to light its row and column and compare that cohort with the average. Motion: Diagonal reveal (45ms steps); dimming 150ms; the focused curve fades in 500ms. Accessibility: The heatmap is a real table with headers, a caption and per-cell labels; keyboard navigation; the readout is announced politely. Percentages are printed, so colour is never the only channel. Responsive behavior: Two columns on wide screens, stacked under 760px; the table keeps a minimum width and scrolls horizontally inside its card. Touch: Tap a cell to select it. 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
Point at a cell (or Tab into the table and use the arrows) to light its row and column and compare that cohort with the average.
Motion
Diagonal reveal (45ms steps); dimming 150ms; the focused curve fades in 500ms.
Accessibility
The heatmap is a real table with headers, a caption and per-cell labels; keyboard navigation; the readout is announced politely. Percentages are printed, so colour is never the only channel.
Responsive
Two columns on wide screens, stacked under 760px; the table keeps a minimum width and scrolls horizontally inside its card.
On touch
Tap a cell to select it.