Who Came Back · A Cohort Retention Heatmap
Of the customers who joined in a given month, how many are still around? Twenty-three monthly cohorts for a fictional outdoor brand, and the onboarding change that kept more of them.
What you’re looking at
Each row is a group of customers who placed their first order with Northwind Outfitters, a fictional outdoor brand, in the same month. Each cell shows the share who came back one month later, two months later, and so on. Warmer cells mean more customers stayed. Month 0 is everyone, so it stays grey and the colour spends its range on the months after. The triangle shape comes from time: newer groups simply have fewer months behind them.
Watch March 2026. Northwind changed its onboarding that month, and every group since keeps more customers: about 44% still order three months in, up from 38%. November 2025 tells the opposite story. Holiday shoppers arrived in a crowd, and only 31% stayed for three months.
Hover or tap a row and its retention curve lights up above the heatmap, with the other cohorts dimmed. Play builds the cohorts row by row and pauses where the colour warms at March 2026. The +5.6 point lift compares average month-3 retention for the six cohorts since March 2026 (43.6%) with the thirteen before it (38.0%), leaving out the November 2025 holiday cohort. The Dark / Light button under the colour key redraws the same view on a paper background, with its own violet, coral and gold scale. That button is only on this page; in ThoughtSpot the chart follows the app’s own light or dark mode.
The same view answers whether a product change kept more people around, shows growth teams which acquisition months brought loyal customers, and is the retention view SaaS apps build for their own customers. The data is synthetic, generated for this showcase.
How it was built
Muze supplies the heatmap, the curve lines, scales, hover, tooltip and the link between the two canvases. This example adds the pinned notes, the side panel and Play.
1. Read the Answer. Studio provides viz and getDataFromSearchQuery(), as shown in the Studio Quick Start. The FIELD block maps Cohort Month, Month Offset and Retention %, plus the optional Cohort Size; getField(...).data() reads each column once. The adapter accepts cohort months as text such as 2026-03 or as dates, checks every offset and percentage, then loads one DataModel that both canvases read. Month 0 is left out of its Curve field, so the lines start at month 1 like the colour scale.
2. Bind fields to marks. Muze draws a heatmap as a bar layer on two discrete axes: .rows(["Cohort"]), .columns(["Offset"]) and .color("Retention") give one rect per cohort and month. legend.color sets the violet, coral and gold range on a 15–60% domain. A second bar layer, whose source keeps only month 0, paints those cells grey. Custom ordering keeps cohorts in calendar order and offsets in numeric order, and the theme font matches the CSS so Muze sizes rows from the labels it draws. The canvas above is a line layer with .detail(["Cohort"]) for one line per cohort, coloured by whether the cohort started before or after March 2026.
3. Connect hover to the curve. Two custom side effects are registered through ActionModel. On the heatmap, cohort-link reads the hovered cell and dispatches a highlight for its cohort on the curve canvas. There, curve-focus puts that cohort’s rows into an empty “focus” line layer with setLayerData, as in Update layer data on interaction, and redraws its unit with renderLayers; CSS dims the other lines. Pointer hover on the curve canvas itself is unhooked: on a month axis it would select every cohort in that column, not one curve.
4. Add overlays and replay. After animationEnd, the curve canvas is shifted and narrowed so its plot spans exactly the heatmap’s columns. The pinned notes on March 2026 and November 2025 and the onboarding rule are placed from the heatmap’s own band axes: getScaleValue and getScaleBandwidth give every cohort row and month column in plot pixels, whether or not Muze has drawn it. When the canvas is too short for every row, Muze scrolls the rows itself; a listener on its virtualScrolling state re-places the overlays, and the overlay clips to the visible rows. Play lifts a curtain one cohort at a time while the curve layer receives the cohorts built so far and lights the newest, pausing at March 2026. A resize observer rebuilds both canvases; one disposer owns the current render.
Both modes share one layout. A THEMES table holds the colours Muze draws (the cell palette, month 0, axis text, the two curve colours and the hovered curve), and CSS variables on the app and the tooltip hold the rest. Switching modes redraws both canvases, because Muze writes colours into its marks. In Studio, the mode follows ThoughtSpot’s own through viz.env.isDarkMode with no button (the artifact passes themeToggle: false), and the Studio CSS makes the chart fill its Answer or Liveboard tile, dropping the intro, the facts, then the curves and side panel as the tile gets smaller.
Take it with you
Load the CSV into a Worksheet or Model with Month Offset as an attribute, and build an Answer with Cohort Month, Month Offset, Retention % and Cohort Size. Paste these complete artifacts into Muze Studio and set the FIELD names at the top of the JavaScript to match your Answer columns.
JavaScript
Answer bindings, the Muze heatmap and curve canvases, the hover link, notes, side panel, Play and the dark and light themes.
Preview
const { muze, getDataFromSearchQuery } = viz;
const data = getDataFromSearchQuery();
// Who Came Back: monthly customer cohorts for Northwind Outfitters (synthetic data).
// Muze draws both canvases (the cohort × month heatmap and the retention curves above it), their
// scales, hover, tooltip and the link between them. The notes, side panel and Play are glue.
const FIELD = {
cohort: "Cohort Month", // "2026-03", a date, or epoch milliseconds
offset: "Month Offset", // whole months since the first order: 0, 1, 2…
retention: "Retention %", // 0–100
size: "Cohort Size", // optional: customers in the cohort, for the tooltip and facts
};
const COLOR_DOMAIN = [15, 60]; // colour spends its range on months 1+; month 0 is always 100%
// "auto" follows Charts Studio's viz.env.isDarkMode (passed to buildViz as options.isDarkMode),
// and opens dark where the host gives no flag. "dark" (the observatory) or "light" (paper) fix it.
// The docs page adds a Dark / Light button under the colour key (options.themeToggle); in Studio
// the mode follows ThoughtSpot alone, so the Studio artifact passes themeToggle: false.
const THEME = "auto";
// The colours Muze draws. Everything else (text, panel, notes, tooltip) is in the CSS.
// Each palette runs violet → coral → gold, from the background's own tone to the brightest ink.
const THEMES = {
dark: {
palette: ["#2e1a63", "#6a2c9c", "#b8418a", "#ec6a5c", "#f9a94b", "#ffe08a"],
month0: "#2a3150",
axis: "#8f9cc4",
eras: ["#7b6fc9", "#f9a94b"], // curves before / since the onboarding change
focus: "#fff3c4", // the hovered cohort's curve
},
light: {
palette: ["#ece5f8", "#c6a8ea", "#c160ad", "#ea6458", "#f2943a", "#e3a400"],
month0: "#e2e4ec",
axis: "#5f6788",
eras: ["#a79ddb", "#ef8a3c"],
focus: "#2c1d5e",
},
};
const ONBOARDING = "2026-03"; // new onboarding ships
const HOLIDAY = "2025-11"; // holiday rush cohort
const STAT_OFFSET = 3; // the headline compares retention three months in
const MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ");
function cohortKey(value) {
if (value instanceof Date) value = value.getTime();
if (typeof value === "number" && Number.isFinite(value)) {
const d = new Date(value); // Answer dates arrive as UTC epoch milliseconds
return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, "0")}`;
}
const match = /^(\d{4})-(\d{1,2})\b/.exec(String(value ?? "").trim());
return match && +match[2] >= 1 && +match[2] <= 12
? `${match[1]}-${match[2].padStart(2, "0")}`
: null;
}
const cohortLabel = (key) => `${MONTHS[+key.slice(5) - 1]} ${key.slice(0, 4)}`;
function readCohorts(data) {
// A measure left aggregated comes back as "Total Retention %" or "Average Retention %". With
// Cohort Month and Month Offset in the Answer each group is one cell, so its value is unchanged:
// accept the column under either name.
const names = data.getData().schema.map((f) => f.name);
const column = (field, required = true) => {
const name =
names.find((n) => n === field) ??
names.find((n) => n.endsWith(` ${field}`));
let values;
try {
values = name && data.getField(name)?.data();
} catch (_) {}
if (!values && required)
throw new Error(`Who Came Back requires the Answer column "${field}".`);
return values;
};
const cohorts = column(FIELD.cohort);
const offsets = column(FIELD.offset);
const retention = column(FIELD.retention);
const sizes = column(FIELD.size, false);
if (!cohorts.length)
throw new Error("Who Came Back needs at least one cohort.");
if (offsets.length !== cohorts.length || retention.length !== cohorts.length)
throw new Error(
"Who Came Back Answer columns must have the same number of rows.",
);
const seen = new Set();
const cells = cohorts.map((raw, i) => {
const fail = (why) => {
throw new Error(
`Who Came Back row ${i + 1}: ${why}. Make Month Offset an attribute so each row is one cohort and month offset.`,
);
};
const key = cohortKey(raw);
if (!key) fail(`"${FIELD.cohort}" must be a month such as 2026-03`);
const offset = Number(offsets[i]);
if (!Number.isInteger(offset) || offset < 0)
fail(`"${FIELD.offset}" must be a whole number of months`);
const value = Number(retention[i]);
if (
retention[i] === null ||
retention[i] === "" ||
!(value >= 0 && value <= 100)
)
fail(`"${FIELD.retention}" must be between 0 and 100`);
if (seen.has(`${key}|${offset}`))
fail(`${key} month ${offset} appears twice`);
seen.add(`${key}|${offset}`);
const size = sizes ? Number(sizes[i]) : NaN;
return {
key,
label: cohortLabel(key),
offset,
value,
size: Number.isFinite(size) ? size : null,
};
});
return cells.sort(
(a, b) => a.key.localeCompare(b.key) || a.offset - b.offset,
);
}
function buildViz(muze, data, mountId, options = {}) {
if (options.signal?.aborted) return null;
const cells = readCohorts(data);
const mount = document.getElementById(mountId);
let current;
let timer;
let disposed = false;
let plot;
let width, height;
let theme =
THEME === "light" || (THEME === "auto" && options.isDarkMode === false)
? "light"
: "dark";
// Muze canvases are sized in pixels: redraw once the heatmap's cell settles at a new size.
const observer = new ResizeObserver(() => {
if (!plot.isConnected) {
dispose();
return;
}
clearTimeout(timer);
if (!plot.clientWidth || !plot.clientHeight) {
width = height = 0; // revealing at the same size still needs fresh geometry
return;
}
if (plot.clientWidth === width && plot.clientHeight === height) return;
timer = setTimeout(render, 150);
});
function render(force = false) {
if (disposed || !mount.isConnected || (plot && !plot.isConnected)) {
dispose();
return;
}
if (
!force &&
plot &&
(!plot.clientWidth ||
!plot.clientHeight ||
(plot.clientWidth === width && plot.clientHeight === height))
)
return;
observer.disconnect();
current?.dispose();
const toggleTheme =
options.themeToggle === false
? null
: () => {
theme = theme === "dark" ? "light" : "dark";
render(true); // muze bakes colours into its marks, so the switch redraws both canvases
};
current = renderViz(muze, cells, mountId, dispose, theme, toggleTheme);
plot = mount.querySelector("#wcb-heat");
width = plot.clientWidth;
height = plot.clientHeight;
observer.observe(plot);
}
function dispose() {
if (disposed) return;
disposed = true;
clearTimeout(timer);
observer.disconnect();
current?.dispose();
}
render();
return { dispose };
}
function renderViz(muze, cells, mountId, onDetached, theme, toggleTheme) {
const { palette, month0, axis, eras, focus } = THEMES[theme];
const mount = document.getElementById(mountId);
const $ = (id) => mount.querySelector(`#${id}`);
mount.innerHTML = `
<div id="wcb-app">
<header>
<h2>Since March, More Customers Stay</h2>
<p id="wcb-lede"></p>
</header>
<section id="wcb-curves-wrap" aria-label="Retention curve for each cohort">
<p id="wcb-readout" aria-live="polite"></p>
<div id="wcb-curves"></div>
</section>
<section id="wcb-heat" aria-label="Retention by signup month and months since signup"></section>
<footer><p id="wcb-source"></p></footer>
<aside>
<div class="wcb-controls"><button id="wcb-play" type="button" disabled>Play</button><span id="wcb-step">Build the cohorts in order</span></div>
<p class="wcb-stat"><b id="wcb-lift">–</b><span id="wcb-lift-label"></span></p>
<ul id="wcb-facts"></ul>
<div class="wcb-key">
<span class="wcb-key-bar"></span>
<span class="wcb-key-ticks"><i>${COLOR_DOMAIN[0]}%</i><i>${(COLOR_DOMAIN[0] + COLOR_DOMAIN[1]) / 2}%</i><i>${COLOR_DOMAIN[1]}%+</i></span>
<span class="wcb-key-note"><span class="wcb-key-m0"></span>Month 0 is always 100%${toggleTheme ? `<button id="wcb-theme" type="button" aria-label="Switch to ${theme === "dark" ? "light" : "dark"} mode">${theme === "dark" ? "Light" : "Dark"}</button>` : ""}</span>
</div>
</aside>
<div id="wcb-overlay"><div id="wcb-curtain"></div></div>
</div>
<svg width="0" height="0" aria-hidden="true" style="position:absolute">
<filter id="${mountId}-glow" x="-5%" y="-5%" width="110%" height="110%" color-interpolation-filters="sRGB">
<feGaussianBlur in="SourceGraphic" stdDeviation="5" result="wide" />
<feComponentTransfer in="wide" result="wide"><feFuncA type="linear" slope="0.9" /></feComponentTransfer>
<feMerge><feMergeNode in="wide" /><feMergeNode in="SourceGraphic" /></feMerge>
</filter>
</svg>`;
mount.style.setProperty("--wcb-glow", `url(#${mountId}-glow)`);
const appRoot = $("wcb-app");
appRoot.classList.toggle("light", theme === "light");
if (toggleTheme) $("wcb-theme").addEventListener("click", toggleTheme);
const heatEl = $("wcb-heat");
const curvesEl = $("wcb-curves");
let disposed = false;
let playTimer = 0;
// ───────────────────────────── the story, from the data ─────────────────────────────
const keys = [...new Set(cells.map((c) => c.key))];
const labels = keys.map(cohortLabel);
const offsets = [...new Set(cells.map((c) => c.offset))]
.sort((a, b) => a - b)
.map(String);
const byKey = new Map(cells.map((c) => [`${c.label}|${c.offset}`, c]));
const sizeOf = new Map(
cells.filter((c) => c.size !== null).map((c) => [c.label, c.size]),
);
const at = (key, offset) =>
cells.find((c) => c.key === key && c.offset === offset)?.value;
const mean = (xs) => xs.reduce((a, b) => a + b, 0) / xs.length;
const statValues = (pick) =>
keys
.filter(pick)
.map((k) => at(k, STAT_OFFSET))
.filter((v) => v !== undefined);
const before = statValues((k) => k < ONBOARDING && k !== HOLIDAY);
const since = statValues((k) => k >= ONBOARDING);
const pct = (v) => `${v.toFixed(1)}%`;
const count = (n) => n.toLocaleString("en");
$("wcb-lede").textContent =
"Northwind Outfitters customers, grouped by the month of their first order. Each cell is the share still ordering that many months later. " +
"Hover or tap a row to light its curve, or press Play to build the cohorts in order.";
$("wcb-source").textContent =
`Synthetic data for a fictional company · ${cells.length} rows, ${keys.length} monthly cohorts, ${labels[0]} to ${labels.at(-1)}`;
const fact = (color, html) => {
const li = document.createElement("li");
li.style.setProperty("--c", color);
li.innerHTML = html;
$("wcb-facts").append(li);
};
if (before.length && since.length) {
const lift = mean(since) - mean(before);
$("wcb-lift").textContent =
`${lift >= 0 ? "+" : "−"}${Math.abs(lift).toFixed(1)} pts`;
$("wcb-lift-label").textContent =
`month-${STAT_OFFSET} retention since the ${cohortLabel(ONBOARDING)} onboarding change`;
fact(
palette[5],
`<b>${pct(mean(since))}</b> of customers from ${cohortLabel(ONBOARDING)} on still order at month ${STAT_OFFSET}, up from <b>${pct(mean(before))}</b> before<small>${since.length} cohorts since, ${before.length} before; the holiday cohort is left out</small>`,
);
}
const holiday = at(HOLIDAY, STAT_OFFSET);
if (holiday !== undefined) {
const size = sizeOf.get(cohortLabel(HOLIDAY));
fact(
palette[theme === "light" ? 2 : 1], // the palest lilac would vanish on paper
`${cohortLabel(HOLIDAY)}'s holiday rush${size ? ` brought <b>${count(size)}</b> customers, but` : ""} kept only <b>${pct(holiday)}</b> to month ${STAT_OFFSET}, the lowest of any cohort`,
);
}
const month1 = keys.map((k) => at(k, 1)).filter((v) => v !== undefined);
if (month1.length)
fact(
palette[3],
`Month 1 is the steepest drop: on average only <b>${pct(mean(month1))}</b> come back for a second month`,
);
// ───────────────────────────── muze ─────────────────────────────
const { DataModel, ActionModel, Operators } = muze;
const { GenericSideEffect, SurrogateSideEffect } = muze.SideEffects.standards;
const env = typeof muze === "function" ? muze() : muze;
const BEFORE = `Before ${cohortLabel(ONBOARDING)}`;
const SINCE = `Since ${cohortLabel(ONBOARDING)}`;
// One DataModel feeds both canvases. Offset is a dimension so each month gets its own column;
// Curve is Retention without month 0, so the lines start at month 1 like the colour scale.
const schema = [
{ name: "Cohort", type: "dimension" },
{ name: "Offset", type: "dimension" },
{ name: "Era", type: "dimension" },
{ name: "Retention", type: "measure", defAggFn: "avg" },
{ name: "Curve", type: "measure", defAggFn: "avg" },
];
const model = new DataModel(
DataModel.loadDataSync(
cells.map((c) => ({
Cohort: c.label,
Offset: String(c.offset),
Era: c.key < ONBOARDING ? BEFORE : SINCE,
Retention: c.value,
Curve: c.offset === 0 ? null : c.value,
})),
schema,
),
);
// Layers hold the DataStore muze wraps around the model. The focus layer's source keeps a
// handle on it so hover and Play can hand the curve layers new slices of the same data.
let store;
const cohorts = (values) =>
store.select({ field: "Cohort", operator: "in", value: values });
const nothing = (dm) => {
store = dm;
return cohorts([]);
};
// The one cell in a hover or tooltip selection.
const cellOf = (dataModel) => {
if (!dataModel) return null;
const { data, schema: s } = dataModel.getData();
const row = data[0];
if (!row) return null;
const col = (name) => row[s.findIndex((f) => f.name === name)];
return byKey.get(`${col("Cohort")}|${col("Offset")}`) ?? null;
};
const axisText = { labels: { style: { fill: axis } } };
// On a phone, label every third month so muze can fit all the columns without scrolling.
const narrow = heatEl.clientWidth < 600;
// Studio turns Muze's axis sort menu off on every canvas; do the same here so both match.
const offsetAxis = {
enableDirectSort: false,
showAxisName: false,
tickSize: 0,
ticks: axisText,
tickFormat: ({ rawValue }) => (narrow && rawValue % 3 ? "" : `${rawValue}`),
fields: { Offset: { ordering: { type: "custom", values: offsets } } },
};
// Muze measures labels with its theme font, so give it the one the CSS draws them in.
const muzeTheme = {
name: "who-came-back",
className: "wcb-theme",
font: {
fontSize: "10.5px",
fontFamily: "Inter, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif",
fontWeight: "400",
fontStyle: "normal",
},
loadCSS: () => {},
};
const common = {
theme: muzeTheme,
autoGroupBy: { disabled: true },
columns: { headers: { show: false } },
rows: { headers: { show: false } },
gridLines: { show: false },
gridBands: { x: { show: false }, y: { show: false } },
border: {
showValueBorders: {
left: false,
bottom: false,
top: false,
right: false,
},
},
};
// Heatmap: a bar mark on two discrete axes draws one rect per cohort × month.
const heat = env
.canvas()
.data(model)
.rows(["Cohort"])
.columns(["Offset"])
.color("Retention")
.layers([
{
mark: "bar",
name: "cells",
className: "wcb-cells",
source: (dm) =>
dm.select({ field: "Offset", operator: "neq", value: "0" }),
},
{
mark: "bar",
name: "month0",
className: "wcb-month0",
source: (dm) =>
dm.select({ field: "Offset", operator: "eq", value: "0" }),
encoding: { color: { value: () => month0 } },
},
])
.width(heatEl.clientWidth)
.height(heatEl.clientHeight)
.config({
...common,
legend: { show: false, color: { range: palette, domain: COLOR_DOMAIN } },
axes: {
x: {
...offsetAxis,
padding: 0.14,
showAxisName: true,
name: "Months since first order",
},
y: {
enableDirectSort: false,
showAxisName: false,
tickSize: 0,
padding: 0.18,
ticks: axisText,
fields: { Cohort: { ordering: { type: "custom", values: labels } } },
},
},
interaction: {
highlight: { sideEffects: { "cohort-link": {} } },
tooltip: {
formatter: ({ dataModel }) => {
const c = cellOf(dataModel);
if (!c) return [];
const size = c.size
? `<br /><span>${count(Math.round((c.value * c.size) / 100))} of ${count(c.size)} customers</span>`
: "";
const lead =
c.offset === 0
? "first order"
: `${c.offset} month${c.offset > 1 ? "s" : ""} later`;
return Operators.html`<div class="wcb-tip ${theme}"><b>${c.label} cohort</b> · ${lead}<br /><em>${pct(c.value)}</em> still ordering${size}</div>`;
},
},
},
})
.mount(`#${mountId} #wcb-heat`);
// Curves: one line per cohort (detail), coloured by whether it signed up before or after the change.
// The "focus" layer starts empty; the curve-focus side effect fills it with the hovered cohort.
const curves = env
.canvas()
.data(model)
.rows(["Curve"])
.columns(["Offset"])
.detail(["Cohort"])
.color("Era")
.layers([
{
mark: "line",
name: "curves",
className: "wcb-lines",
interaction: {
highlight: {
sideEffects: { "plot-highlighter": { enabled: false } },
},
},
},
{
mark: "line",
name: "focus",
className: "wcb-focus",
source: nothing,
encoding: { color: { value: () => focus } },
interactive: false,
},
])
.width(curvesEl.clientWidth)
.height(curvesEl.clientHeight)
.config({
...common,
legend: {
show: false,
color: {
fields: {
Era: {
range: eras,
ordering: { type: "custom", values: [BEFORE, SINCE] },
},
},
},
},
axes: {
x: { ...offsetAxis, padding: 0.14, show: false },
y: {
showAxisName: false,
showAxisLine: false,
tickSize: 0,
ticks: axisText,
domain: [15, 65],
tickValues: [15, 30, 45, 60], // the scale starts at 15%, the colour key's floor
tickFormat: ({ rawValue }) => `${rawValue}%`,
},
},
interaction: {
highlight: {
sideEffects: { tooltip: { enabled: false }, "curve-focus": {} },
},
},
})
.mount(`#${mountId} #wcb-curves`);
// ───────────────────────────── linked hover ─────────────────────────────
const readout = $("wcb-readout");
const idleReadout =
"Retention curve for each cohort · hover or tap a row below";
readout.textContent = idleReadout;
let focused = null;
const dispatchFocus = (label) =>
curves.firebolt().dispatchBehaviour("highlight", {
criteria: label ? { dimensions: [["Cohort"], [label]] } : null,
});
ActionModel.for(heat, curves)
// hover is the only interaction: unhook click → select and drag → brush
.dissociateBehaviour(
["select", "click"],
["select", "longtouch"],
["brush", "drag"],
["brush", "touchdrag"],
)
.registerSideEffects(
// heatmap hover → highlight the same cohort on the curve canvas
class extends GenericSideEffect {
static formalName() {
return "cohort-link";
}
apply(set) {
const label = cellOf(set.entrySet.model)?.label ?? null;
if (label !== focused) dispatchFocus(label);
}
},
// a cohort highlight dispatched on the curve canvas → draw that cohort's curve in the focus layer
class extends SurrogateSideEffect {
static formalName() {
return "curve-focus";
}
static target() {
return "visual-unit";
}
apply(set) {
const c = cellOf(set.entrySet.model);
focused = c?.label ?? null;
// setLayerData swaps the layer's data; renderLayers redraws this unit's layers with it
this.setLayerData(cohorts(focused ? [focused] : []), "focus");
this.firebolt.context.renderLayers({});
appRoot.classList.toggle("focused", !!focused);
if (!c) {
readout.textContent = idleReadout;
return this;
}
const m = at(c.key, STAT_OFFSET);
const size = sizeOf.get(c.label);
readout.innerHTML =
`<b>${c.label}</b>${size ? ` · ${count(size)} customers` : ""}` +
(m === undefined
? " · too new for a month-3 figure"
: ` · <b>${pct(m)}</b> at month ${STAT_OFFSET}`);
return this;
}
},
);
// The curves follow the heatmap. Their own hover would highlight a whole month column (every
// cohort at that offset), not one curve, so pointer hover is unhooked there.
ActionModel.for(curves).dissociateBehaviour(["highlight", "hover"]);
// Touch: a tap hovers; swallow touches so long-press select and drag brush cannot block scrolling.
heatEl.addEventListener("touchstart", (e) => e.stopPropagation(), true);
// ──────────────────────────── align the curves ────────────────────────────
// The curve canvas's y labels are narrower than the cohort names, so once both canvases are laid
// out (afterRendered, before their draw animations finish), shift and narrow it until its plot
// spans exactly the heatmap's columns: each curve point then sits above its cell. It stays
// invisible until then (CSS), so the first, unaligned draw is never seen.
const reveal = () => curvesEl.classList.add("aligned");
let laidOut = 0;
const align = () => {
if (++laidOut < 2 || disposed) return;
const plotRect = (el, mark) =>
el
.querySelector(`.muze-layer-${mark}`)
?.ownerSVGElement.getBoundingClientRect();
const heatPlot = plotRect(heatEl, "bar");
const curvePlot = plotRect(curvesEl, "line");
const left = heatPlot && curvePlot ? heatPlot.left - curvePlot.left : 0;
const right = heatPlot && curvePlot ? curvePlot.right - heatPlot.right : 0;
if (Math.abs(left) > 0.5 || Math.abs(right) > 0.5) {
const width = curvesEl.clientWidth;
curvesEl.style.marginLeft = `${left}px`; // the margin narrows the element, not the canvas
curves.once("afterRendered", () => requestAnimationFrame(reveal));
setTimeout(reveal, 600); // in case the redraw reports no afterRendered
curves.width(width - left - right);
} else {
reveal();
}
};
heat.once("afterRendered", align);
curves.once("afterRendered", align);
// ───────────────────────────── after first render ─────────────────────────────
let ready = 0;
const afterRender = () => {
if (++ready < 2) return;
if (disposed || !appRoot.isConnected) {
if (!disposed) onDetached();
return;
}
placeOverlays();
};
heat.once("animationEnd", afterRender);
curves.once("animationEnd", afterRender);
function placeOverlays() {
// Muze's band axes place every row and column; the plot svg moves inside its viewport when
// Muze scrolls the rows. So the overlay covers the viewport, clips to it, and every position
// is the axis value plus the plot's current offset, recomputed whenever Muze scrolls.
const unit = heat.composition().visualGroup.matrix().geom().getUnits()[0];
const xAxis = unit.axes().x[0];
const yAxis = unit.axes().y[0];
const plotSvg = heatEl.querySelector(".muze-layer-bar").ownerSVGElement;
const viewport = plotSvg.closest(".muze-grid-center") ?? plotSvg;
const overlay = $("wcb-overlay");
let dx = 0;
let dy = 0;
const rowTop = (label) => dy + yAxis.getScaleValue(label);
const rowBottom = (label) => rowTop(label) + yAxis.getScaleBandwidth();
const colLeft = (offset) => dx + xAxis.getScaleValue(String(offset));
const colWidth = () => xAxis.getScaleBandwidth();
const layoutItems = [];
// a rule where onboarding changed, between the last cohort before it and the first after
const first = labels.indexOf(cohortLabel(ONBOARDING));
if (first > 0) {
const rule = document.createElement("span");
rule.className = "wcb-rule";
overlay.append(rule);
layoutItems.push(() => {
rule.style.top = `${(rowBottom(labels[first - 1]) + rowTop(labels[first])) / 2}px`;
});
}
// pinned notes: a dot on the month-3 cell, the text out in the empty part of the triangle
const notes = [];
const pin = (key, text, cls) => {
const label = cohortLabel(key);
const last = cells.filter((c) => c.key === key).at(-1);
if (!last || last.offset < STAT_OFFSET) return;
const note = document.createElement("div");
note.className = `wcb-note ${cls}`;
note.dataset.cohort = label;
note.innerHTML = `<i></i><span>${text}</span>`;
overlay.append(note);
notes.push(note);
layoutItems.push(() => {
const x0 = colLeft(STAT_OFFSET) + colWidth() / 2;
const x1 = colLeft(last.offset) + colWidth() + 14;
note.style.top = `${(rowTop(label) + rowBottom(label)) / 2}px`;
note.style.left = `${x0}px`;
note.style.setProperty("--reach", `${x1 - x0}px`);
});
};
const onboard = at(ONBOARDING, STAT_OFFSET);
if (onboard !== undefined)
pin(
ONBOARDING,
`<b>${cohortLabel(ONBOARDING)} · new onboarding</b>${Math.round(onboard)}% still ordering at month ${STAT_OFFSET}`,
"warm",
);
if (holiday !== undefined)
pin(
HOLIDAY,
`<b>${cohortLabel(HOLIDAY)} · holiday rush</b>only ${Math.round(holiday)}% at month ${STAT_OFFSET}`,
"cool",
);
let playRow = -1; // the last cohort Play has revealed, or -1
const curtain = $("wcb-curtain");
const layout = () => {
if (disposed || !appRoot.isConnected) return;
const view = viewport.getBoundingClientRect();
const plot = plotSvg.getBoundingClientRect();
const app = appRoot.getBoundingClientRect();
Object.assign(overlay.style, {
left: `${view.left - app.left}px`,
top: `${view.top - app.top}px`,
width: `${view.width}px`,
height: `${view.height}px`,
});
dx = plot.left - view.left;
dy = plot.top - view.top;
layoutItems.forEach((place) => place());
if (playRow >= 0)
curtain.style.top = `${rowBottom(labels[playRow]) + 1}px`;
};
layout();
// Muze moves the plot before it records the new scroll position, so this sees the new layout.
heat
.store()
.registerChangeListener(
["virtualScrolling.scrollTop", "virtualScrolling.scrollLeft"],
layout,
false,
);
// ── Play: a curtain over the heatmap lifts one cohort row at a time while the curve canvas
// draws the cohorts built so far and lights the newest one.
const play = $("wcb-play");
const step = $("wcb-step");
const curvesUnit = curves
.composition()
.visualGroup.matrix()
.geom()
.getUnits()[0];
const curvesLayer = curvesUnit.layers().find((l) => l.alias() === "curves");
play.disabled = false;
const stop = () => {
clearTimeout(playTimer);
playTimer = 0;
playRow = -1;
overlay.classList.remove("playing");
notes.forEach((n) => n.classList.remove("hidden"));
curvesLayer.resetData();
dispatchFocus(null); // redraws the curve unit, now with every cohort again
play.textContent = "Play";
step.textContent = "Build the cohorts in order";
};
const show = (i) => {
if (!appRoot.isConnected) {
onDetached();
return;
}
if (i >= labels.length) {
playTimer = setTimeout(stop, 1200);
return;
}
const label = labels[i];
playRow = i;
curtain.style.top = `${rowBottom(label) + 1}px`;
notes.forEach((n) =>
n.classList.toggle("hidden", labels.indexOf(n.dataset.cohort) > i),
);
curvesLayer.data(cohorts(labels.slice(0, i + 1)));
dispatchFocus(label); // lights the newest cohort and redraws the unit with the cohorts so far
step.innerHTML =
keys[i] < ONBOARDING
? label
: `<b>${label}</b> · ${keys[i] === ONBOARDING ? "new onboarding starts" : "new onboarding"}`;
playTimer = setTimeout(
() => show(i + 1),
keys[i] === ONBOARDING ? 1100 : 330,
);
};
const start = () => {
heat.firebolt().dispatchBehaviour("highlight", { criteria: null }); // clear any hover and tooltip
overlay.classList.add("playing");
curtain.style.transition = "none";
curtain.style.top = "0px";
void curtain.offsetHeight; // start the slide from the top
curtain.style.transition = "";
play.textContent = "Stop";
show(0);
};
play.addEventListener("click", () => (playTimer ? stop() : start()));
}
function dispose() {
if (disposed) return;
disposed = true;
clearTimeout(playTimer);
heat.dispose();
curves.dispose();
model.dispose();
if (appRoot.parentNode === mount) mount.replaceChildren();
}
return { dispose };
}
buildViz(muze, data, "chart", { isDarkMode: viz.env?.isDarkMode, themeToggle: false });
CSS
Chart-scoped layout, glow, curve dimming, notes, tooltip and the Play curtain, in dark and light, plus a block that fits the chart to Answer and Liveboard tiles.
Preview
/* Muze mounts tooltips outside #chart. Only our uniquely named content opts in. */
#chart,
.muze-tooltip-box:has(.wcb-tip) {
--bg: #080f24;
--ink: #dfe4f5;
--text: #8f9cc4;
--dim: #7f8bb2;
--gold: #ffe08a;
--violet-note: #b89cff;
--axis: #8f9cc4;
--axis-line: rgba(120, 150, 220, 0.18);
--glow-a: rgba(90, 60, 170, 0.22);
--glow-b: rgba(236, 106, 92, 0.1);
--panel-line: rgba(140, 160, 220, 0.08);
--btn: #282d4a;
--btn-hover: #323860;
--btn-edge: rgba(255, 255, 255, 0.06);
--stat-glow: rgba(255, 200, 100, 0.35);
--dot-glow: 6px;
--key-bar: linear-gradient(
90deg,
#2e1a63,
#6a2c9c,
#b8418a,
#ec6a5c,
#f9a94b,
#ffe08a
);
--month0: #2a3150;
--cell-ring: #fff6d0;
--focus-glow: drop-shadow(0 0 5px rgba(255, 224, 138, 0.8));
--tip-bg: rgba(10, 14, 34, 0.95);
--tip-edge: rgba(140, 160, 220, 0.22);
--tip-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
--rule: rgba(255, 224, 138, 0.45);
--note-bg: rgba(8, 15, 36, 0.88);
font-family:
Inter,
"Avenir Next",
-apple-system,
"Segoe UI",
Roboto,
"Helvetica Neue",
Arial,
sans-serif;
font-variant-numeric: tabular-nums;
color: var(--text);
* {
box-sizing: border-box;
}
table {
display: table;
margin: 0;
overflow: visible;
}
td,
th {
padding: 0;
border: 0;
}
tr {
background: transparent;
border: 0;
}
#wcb-app {
color: var(
--text
); /* re-read here so the light set reaches inherited text */
position: relative;
width: min(1300px, 100%);
height: 955px;
margin: 0 auto;
background:
radial-gradient(70% 50% at 30% 0%, var(--glow-a) 0%, transparent 70%),
radial-gradient(60% 50% at 60% 100%, var(--glow-b) 0%, transparent 70%),
var(--bg);
border-radius: 10px;
overflow: hidden;
display: grid;
grid-template-columns: minmax(0, 1fr) 290px;
grid-template-rows: auto 225px minmax(0, 1fr) 36px;
grid-template-areas:
"head rail"
"curves rail"
"heat rail"
"foot rail";
}
/* ── header ── */
header {
grid-area: head;
padding: 22px 0 4px 28px;
}
h2 {
margin: 0 0 6px;
padding: 0;
border: 0;
font-family: inherit;
font-size: 22px;
font-weight: 600;
letter-spacing: -0.01em;
line-height: normal;
color: var(--ink);
}
#wcb-lede {
margin: 0;
max-width: 820px;
font-size: 12px;
line-height: 1.45;
}
/* ── curves (top) and heatmap ── */
#wcb-curves-wrap {
grid-area: curves;
display: flex;
flex-direction: column;
padding: 8px 8px 0 12px;
min-width: 0;
}
#wcb-readout {
margin: 0 0 2px 16px;
min-height: 16px;
font-size: 11.5px;
color: var(--dim);
}
#wcb-readout b {
font-weight: 600;
color: var(--ink);
}
#wcb-curves {
flex: 1;
min-height: 0;
position: relative;
opacity: 0; /* shown once aligned with the heatmap's columns, so it never jumps sideways */
transition: opacity 0.25s;
}
#wcb-curves.aligned {
opacity: 1;
}
#wcb-heat {
grid-area: heat;
position: relative;
margin: 0 8px 0 12px; /* margin, not padding: muze is sized from clientWidth */
min-width: 0;
}
/* ── footer ── */
footer {
grid-area: foot;
padding: 10px 0 0 28px;
}
#wcb-source {
margin: 0;
font-size: 10.5px;
color: var(--dim);
}
/* ── side panel: Play, the big stat, facts, colour key ── */
aside {
grid-area: rail;
padding: 24px 26px 0 20px;
display: flex;
flex-direction: column;
border-left: 1px solid var(--panel-line);
}
.wcb-controls {
display: flex;
align-items: center;
gap: 12px;
min-height: 28px;
}
#wcb-play {
min-width: 56px;
padding: 6px 12px;
border: 0;
border-radius: 5px;
background: var(--btn);
color: var(--gold);
font: inherit;
font-size: 12px;
font-weight: 600;
cursor: pointer;
box-shadow: inset 0 1px 0 var(--btn-edge);
}
#wcb-play:hover,
#wcb-theme:hover {
background: var(--btn-hover);
}
/* Dark / Light switch: a small second button after the step label */
#wcb-theme {
margin-left: auto;
padding: 4px 9px;
border: 1px solid var(--panel-line);
border-radius: 5px;
background: transparent;
color: var(--dim);
font: inherit;
font-size: 11px;
cursor: pointer;
}
#wcb-play:disabled {
opacity: 0.5;
cursor: default;
}
#wcb-step {
font-size: 11.5px;
color: var(--dim);
}
#wcb-step b {
font-weight: 600;
color: var(--gold);
}
.wcb-stat {
margin: 28px 0 22px;
display: flex;
flex-direction: column;
}
.wcb-stat b {
font-size: 46px;
font-weight: 300;
line-height: 1;
letter-spacing: -0.02em;
color: var(--gold);
text-shadow: 0 0 22px var(--stat-glow);
}
.wcb-stat span {
margin-top: 8px;
font-size: 12px;
line-height: 1.4;
color: var(--text);
}
#wcb-facts {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 12px;
font-size: 11.5px;
line-height: 1.4;
}
#wcb-facts li {
position: relative;
padding-left: 13px;
}
#wcb-facts li::before {
content: "";
position: absolute;
left: 0;
top: 5px;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--c, #fff);
box-shadow: 0 0 var(--dot-glow) var(--c, #fff);
}
#wcb-facts b {
font-weight: 600;
color: var(--ink);
}
#wcb-facts small {
display: block;
margin-top: 2px;
font-size: 10.5px;
color: var(--dim);
}
.wcb-key {
margin-top: auto;
padding-bottom: 22px;
display: flex;
flex-direction: column;
gap: 5px;
font-size: 10.5px;
color: var(--dim);
}
.wcb-key-bar {
height: 8px;
border-radius: 2px;
background: var(--key-bar);
}
.wcb-key-ticks {
display: flex;
justify-content: space-between;
}
.wcb-key-ticks i {
font-style: normal;
}
.wcb-key-note {
display: flex;
align-items: center;
gap: 6px;
margin-top: 4px;
}
.wcb-key-m0 {
width: 12px;
height: 8px;
border-radius: 2px;
background: var(--month0);
}
/* ── muze restyling (pure CSS, no source changes) ── */
:is(#wcb-heat, #wcb-curves) svg text {
fill: var(--axis) !important;
font-family: inherit !important;
font-size: 10.5px !important;
}
:is(#wcb-heat, #wcb-curves) .muze-axis path,
:is(#wcb-heat, #wcb-curves) .muze-axis line {
stroke: var(--axis-line) !important;
}
/* the glow: one filter on the layer group, not one per rect */
#wcb-heat .wcb-cells {
filter: var(--wcb-glow);
}
#wcb-heat .muze-layer-bar rect {
rx: 2px;
}
/* the hovered cell: muze outlines it with an overlay path; make that a light ring */
#wcb-heat [class*="muze-layer-overlay-path"] path {
fill: none !important;
stroke: var(--cell-ring) !important;
stroke-width: 1.5px !important;
}
#wcb-curves .wcb-lines path {
stroke-width: 1.4px !important;
stroke-opacity: 0.55;
transition: stroke-opacity 0.15s;
}
#wcb-curves .wcb-lines [class*="disconnected"] {
opacity: 0.55;
}
.focused #wcb-curves .wcb-lines path {
stroke-opacity: 0.16;
}
.focused #wcb-curves .wcb-lines [class*="disconnected"] {
opacity: 0.16;
}
#wcb-curves .wcb-focus path {
stroke-width: 2.6px !important;
filter: var(--focus-glow);
}
#wcb-curves .wcb-focus circle,
#wcb-curves .muze-layer-line circle {
display: none;
}
/* muze's brush sets touch-action: none inline on touch devices; let the page scroll */
:is(#wcb-heat, #wcb-curves) g {
touch-action: auto !important;
}
/* tooltip */
&.muze-tooltip-box {
background: var(--tip-bg) !important;
border: 1px solid var(--tip-edge) !important;
border-radius: 6px !important;
box-shadow: var(--tip-shadow) !important;
padding: 8px 10px !important;
}
.wcb-tip {
font-size: 11px;
line-height: 1.5;
color: var(--text);
}
.wcb-tip b {
color: var(--ink);
font-weight: 600;
}
.wcb-tip em {
font-style: normal;
font-size: 13px;
font-weight: 600;
color: var(--gold);
}
/* ── overlay on the heatmap plot: onboarding rule, pinned notes, Play curtain ── */
#wcb-overlay {
position: absolute;
pointer-events: none;
overflow: hidden; /* rows Muze has scrolled out of view take their rule and notes with them */
}
#wcb-overlay.playing {
pointer-events: auto; /* no hovering while Play builds the rows */
}
#wcb-curtain {
display: none;
position: absolute;
left: -2px;
right: -2px;
bottom: -2px;
top: 0;
background: var(--bg);
transition: top 0.3s ease-out;
}
#wcb-overlay.playing #wcb-curtain {
display: block;
}
.wcb-rule {
position: absolute;
left: 0;
width: 100%;
border-top: 1px dashed var(--rule);
}
/* a dot on the month-3 cell, a leader out to the empty side of the triangle, then the text */
.wcb-note {
position: absolute;
z-index: 1;
transition: opacity 0.3s;
}
.wcb-note.hidden {
opacity: 0;
}
/* hovering a row: the notes and rule step back so the tooltip reads cleanly over them */
.focused:not(:has(.playing)) :is(.wcb-note, .wcb-rule) {
opacity: 0.12;
}
.wcb-rule {
transition: opacity 0.3s;
}
.wcb-note i {
position: absolute;
left: -4px;
top: -4px;
width: 8px;
height: 8px;
border-radius: 50%;
border: 1.5px solid var(--note);
box-shadow: 0 0 8px var(--note);
}
.wcb-note i::after {
content: "";
position: absolute;
left: 7px;
top: 2.5px;
width: calc(var(--reach) - 9px);
border-top: 1px solid var(--note);
opacity: 0.6;
}
.wcb-note span {
position: absolute;
left: var(--reach);
top: 0;
transform: translateY(-50%);
white-space: nowrap;
padding: 3px 7px;
border-radius: 4px;
border-left: 2px solid var(--note);
background: var(--note-bg);
font-size: 11px;
line-height: 1.35;
color: var(--text);
}
.wcb-note b {
display: block;
font-weight: 600;
color: var(--ink);
}
.wcb-note.warm {
--note: var(--gold);
}
.wcb-note.cool {
--note: var(--violet-note);
}
/* Muze's scrollbar (shown when the heatmap is too short for every row), in the chart's colours rather than its default light grey */
.muze-scroll-bar {
background: transparent;
}
.muze-scroll-mover,
.muze-scroll-arrow {
background: var(--btn-hover);
}
.muze-scroll-arrow-chevron::before,
.muze-scroll-arrow-chevron::after {
background: var(--text);
}
/* ── light mode: the same layout on a paper canvas. Muze's colours come from THEMES in the JS;
the tooltip lives outside #wcb-app, so it reads the light set from its .light content ── */
#wcb-app.light,
&.muze-tooltip-box:has(.wcb-tip.light) {
--bg: #fbfaf7;
--ink: #1f2240;
--text: #545c7c;
--dim: #687090;
--gold: #b0670a;
--violet-note: #7350d0;
--axis: #5f6788;
--axis-line: rgba(60, 70, 110, 0.22);
--glow-a: rgba(140, 110, 220, 0.12);
--glow-b: rgba(240, 150, 90, 0.1);
--panel-line: rgba(40, 50, 90, 0.12);
--btn: #f1ecf8;
--btn-hover: #e6def4;
--btn-edge: rgba(255, 255, 255, 0.8);
--stat-glow: transparent;
--dot-glow: 0px;
--key-bar: linear-gradient(
90deg,
#ece5f8,
#c6a8ea,
#c160ad,
#ea6458,
#f2943a,
#e3a400
);
--month0: #e2e4ec;
--cell-ring: #1f2240;
--focus-glow: drop-shadow(0 1px 2px rgba(40, 20, 90, 0.35));
--tip-bg: rgba(255, 255, 255, 0.97);
--tip-edge: rgba(40, 50, 90, 0.16);
--tip-shadow: 0 6px 20px rgba(30, 30, 60, 0.16);
--rule: rgba(176, 103, 10, 0.55);
--note-bg: rgba(251, 250, 247, 0.92);
}
/* paper has no glow: the cells sit flat with a hairline edge instead */
#wcb-app.light #wcb-heat .wcb-cells {
filter: none;
}
#wcb-app.light #wcb-heat .muze-layer-bar rect {
stroke: rgba(40, 30, 80, 0.06);
}
#wcb-app.light #wcb-curves .wcb-lines path {
stroke-opacity: 0.7;
}
#wcb-app.light.focused #wcb-curves .wcb-lines path {
stroke-opacity: 0.18;
}
/* ── phones: one column, panel below ── */
@media (max-width: 900px) {
#wcb-app {
height: auto;
border-radius: 0;
grid-template-columns: minmax(0, 1fr);
grid-template-rows: auto 225px 600px auto auto;
grid-template-areas:
"head"
"curves"
"heat"
"foot"
"rail";
}
header,
footer {
padding: 16px 16px 0;
}
aside {
padding: 16px;
border-left: 0;
}
.wcb-stat {
margin: 16px 0;
}
.wcb-key {
margin-top: 18px;
padding-bottom: 0;
}
.wcb-note span {
display: none; /* keep the narrow grid clear; the dots and the facts carry the notes */
}
}
}
/* Charts Studio: fill the Answer or Liveboard tile, dropping detail as it gets smaller.
Below about 24px per cohort row Muze scrolls the heatmap rows itself. */
html,
body {
height: 100%;
margin: 0;
}
#chart {
height: 100%;
overflow: hidden;
#wcb-app {
width: 100%;
height: 100%;
border-radius: 0;
grid-template-columns: minmax(0, 1fr) clamp(180px, 24%, 290px);
grid-template-rows: auto 225px minmax(0, 1fr) 36px;
grid-template-areas:
"head rail"
"curves rail"
"heat rail"
"foot rail";
}
header {
padding: 22px 0 4px 28px;
}
footer {
padding: 10px 0 0 28px;
}
aside {
padding: 22px 20px 0 18px;
border-left: 1px solid var(--panel-line);
overflow: hidden;
}
.wcb-key {
margin-top: auto;
padding-bottom: 18px;
}
@media (max-height: 760px) {
#wcb-app {
grid-template-rows: auto 165px minmax(0, 1fr) 30px;
}
#wcb-lede,
#wcb-facts small {
display: none;
}
.wcb-stat {
margin: 18px 0 14px;
}
}
@media (max-height: 560px) {
#wcb-app {
grid-template-rows: auto 180px minmax(0, 1fr) 0;
}
header {
padding: 14px 0 0 20px;
}
h2 {
font-size: 18px;
}
footer,
#wcb-facts {
display: none;
}
aside {
padding-top: 14px;
}
.wcb-stat b {
font-size: 36px;
}
}
@media (max-height: 340px) {
#wcb-app {
grid-template-rows: auto 0 minmax(0, 1fr) 0;
}
#wcb-curves-wrap,
.wcb-key,
#wcb-step {
visibility: hidden;
}
header {
padding: 8px 0 2px 14px;
}
h2 {
font-size: 15px;
}
aside {
padding: 8px 12px 0;
}
.wcb-stat {
margin: 10px 0 0;
}
.wcb-stat b {
font-size: 30px;
}
}
@media (max-width: 520px) {
#wcb-app {
grid-template-columns: minmax(0, 1fr);
grid-template-areas: "head" "curves" "heat" "foot";
}
aside {
display: none;
}
}
}
HTML
The mount element. JavaScript creates the canvases, side panel and notes.
Preview
<div id="chart"></div>
Dataset (CSV)
Synthetic data: cohort month, month offset, cohort size, active customers and retention % for 23 monthly cohorts, Jan 2025 to Nov 2026.