Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(funnels): use quill FunnelChart for the steps bar viz (#70772)

Sam Pennington1a4acacd9f14
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ff76237dbe4e..e1ab5c186af5 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -165,9 +165,9 @@ snapshots:
components-cards-insight-card--access-control-manager-access--light:
hash: v1.k794b7964.ce90a8d28a7c96d6906f3dfc923a72170b34ae1f86bcff632ef293f8b486e10a.oC_u_-gOLmHCxg6nutx9wXeZ4rJbmDfkzKvJ4CkqlsA
components-cards-insight-card--access-control-mixed-permissions--dark:
- hash: v1.k794b7964.f6045c5331d0b24c23106baba3f35a4df92dbfbd5b7cebdebe4bdbe3022c425b.g2AB9A2ug99EceRn-rLmzEhqHbj7D4TLXEMmjE6B1O0
+ hash: v1.k794b7964.ec40f4f4b9d63fa0348a62f350eb17a98552b98a0529357a3044cb23c3ccd538.XNuAyCNAAJRCVNbp_uhtxIIYMkAHp7wphVA9n10-h1E
components-cards-insight-card--access-control-mixed-permissions--light:
- hash: v1.k794b7964.676bdd451a3b01dd6083a2f2a92d4046b17ed5f7c99b4565b834ce84960fc792.MY3DBesHV73V0HJWY72z2pkWaEUnnB9sYxw4bG-mkbY
+ hash: v1.k794b7964.a41413b39e5f0734544b5ac649723b2e2c2d39f9d9506872b2e5cb0d28716be9.e2IrHFsMyjjq1iks5oLk68pNZ9u0SFCLRrvej1Ok9Mo
components-cards-insight-card--access-control-no-access--dark:
hash: v1.k794b7964.f6f28bb570a00daeab77829db57d01e81916eab508812a58a591e7b80d9b7b38.xEfUn7QLkpze4Q36ko7BBbyupxpuvTwJg1aHxreqTzc
components-cards-insight-card--access-control-no-access--light:
@@ -673,9 +673,9 @@ snapshots:
components-hogcharts-funnelchart--single-series--light:
hash: v1.k794b7964.4e42a2b211d9f45405ea8d54c8d6d88c9b1baa7d42fa8d311ca9af29c1e093e8.YuR6d8ueW0hVPHY2giOTPQQHzVsadrsVILGTImSUX_Y
components-hogcharts-funnelchart--with-step-footer--dark:
- hash: v1.k794b7964.c14c5f1138464e78ff0eb8423db2caab871c81e6a523734c154b63b5a3c05bd6.qbFArRbm4iHI18T08hWXVMZC69S5dkQ5cQ5VoCSgVmw
+ hash: v1.k794b7964.ea1a39d373ac1a59d455df7be066e067e933c5b089a753157173d0afcf379871.UrzbUOgFtKZDYNhip8wYMp85R0Wl5Jl9oNvu6Pgg4Z8
components-hogcharts-funnelchart--with-step-footer--light:
- hash: v1.k794b7964.03968d655b2ee1d4993ab6c3c19755623f8e37118c5a165bf2e48e6f4452e971.eKZ1yGNS6PiIf_9dy5m3yFNFf4pWA95vzKdma9W0J5g
+ hash: v1.k794b7964.9cd8b07fd999044121ce2bf7528a70443fb6ebf619ae020e7fca062acdc51c84.rZBafni2q_9C67ZQRvq8Oc57oavSmPBnUTUHoAJ8A-M
components-hogcharts-highlightedrange--mirroring-drag-selection--dark:
hash: v1.k794b7964.64a7d4555eda0a387b3b7b159397ed36aec00739db9ca101281ace1d84ea742e.t3Qju4H0HxPL1ROhKqavpuowJ_DeePAa0O0r5eIHeBs
components-hogcharts-highlightedrange--mirroring-drag-selection--light:
@@ -2665,41 +2665,41 @@ snapshots:
insights-funnelpropertycorrelationtable--default--light:
hash: v1.k794b7964.056fc912fbb2878e0a70884298f340ea9af0f1a57c80aebc7967fa1715982135.SbiTtmaSnj5V3ocDF2cHYLFAghsAJzD45d1x-3LS1co
insights-funnelstepsbarchart--breakdown--dark:
- hash: v1.k794b7964.3e5ef1d039b89f592b7018fa3848deede16aeee982752b15d3f38558e4293436.cQ8QtEaOsYecz-srdinHKpN-du5WQ0HpajMwtI3-bRA
+ hash: v1.k794b7964.9d29432994ad06bfd84e610ad278f98c9f35c949afcfdc699801b08601933731.9c4f6BMn_2Nwsug1F9C8kiELsnkcYv3wDBmOmzLcnl8
insights-funnelstepsbarchart--breakdown--light:
- hash: v1.k794b7964.7a364d7196c08cc7f98206e746b42877cd4b5e1b1186006af0d7c443299dbd7c.9u2TNQ1yYenvs_NrBbjDQ1uoPkJxske3DQKai3VvKik
+ hash: v1.k794b7964.4630750f85adeaeefa231f845448b5bab66ff0bbccaed49f9e4d9ab98eb0e8b8.K6AkpTH6GbV2jVqBh9PDzmVr0_p5tsQf9YnU1xlJG9U
insights-funnelstepsbarchart--breakdown-and-compare--dark:
- hash: v1.k794b7964.e5536790de372f0737d9c0953777bd9e9b0bcb8ac926c43c66f05d1dcca975b8.RAaGDrRyrpLcY9vlvwD353lV5y92VnyfRFlxG7y_wqI
+ hash: v1.k794b7964.2e98f6aa4cecbf7cba9f155edb72425384d54978fda6e14edace8bf797c64e4e.uzeXLJ1A-ToIR6DLfZAQ5ooBp2pRX8oFuFoXxgpXExA
insights-funnelstepsbarchart--breakdown-and-compare--light:
- hash: v1.k794b7964.2b003d85bb9317937ea9a32887299f284f5ed86a1cf62db472d5c22efc82593a.Z9vNrMFIj3E4gSDktvUZhEuMTm6CovAlsTRRBT6m_a4
+ hash: v1.k794b7964.79c892a6b76968d08a66b908800c3ee451648548bb8324a9869151c524ae4508.lIm3klT60r5nuJXGknDdOd8pNGxTJyeXK6yq_es6sjM
insights-funnelstepsbarchart--compare--dark:
- hash: v1.k794b7964.f9514bd297a44b7b925f76f5837c1d3d15c622409363adb82f22f2448c586158.tzzxAkngJgOIjK0j9LTUwOsqXxRFwVv1Bi8bzktxLi4
+ hash: v1.k794b7964.e4dda0645520f559b7f17c458ef892b1102626d89c2dd5320293837d97406bd7.iQm8yXcWKOJ-ST9BMsTH18oqltlT5IEZ-oJMuxYqr6A
insights-funnelstepsbarchart--compare--light:
- hash: v1.k794b7964.cc4c4aaae116274b88217b54515ddf06fa5ec9cffcc700910c944cf97bcdfe86.BTJLpddK0ybMmsDkc0IFvbzkIQtMFOydl8cm8Swz0u4
+ hash: v1.k794b7964.eaca1df07c05317b0a173b7f1bce481e0e38755e647f831556a8a0dee62ae784.MxAWDlQBv-2BJ_2zU3sZtj4_VocEp-MxfeAGYIC_A4M
insights-funnelstepsbarchart--default--dark:
- hash: v1.k794b7964.44ddc53023dad710da2cfceb41a404e624ef724455cd5a93da7cb428f4aa7f37.2wi30P-mcC3hUjT0QdlKS6g_RztKIr6MtEPwqtPK8Y8
+ hash: v1.k794b7964.4a9d9a22475acddcb3a7b67c5f3a5febd87e75bec3d1e618ac361262123a3b9c.uYsT3ZO9HzosqVn6NcjS8XqYt14pqJ7uNM_ttSqW8tE
insights-funnelstepsbarchart--default--light:
- hash: v1.k794b7964.66098c2d3ed65588b0e7330b6208f6753085095634cb8a950d6c7e238d5d9662.HFfxm-L0dPW6MeZfJ4hEZFERzDI2q-s6eVOodbucD1s
+ hash: v1.k794b7964.4ae63d15d402eb29d7945a77bed715217229f0c96b936cf218e2a1b7b9a6b074.4fV12BOguZ9pNJ8xuw4D-lFiO_JEe4axev8c8FXh21o
insights-funnelstepsbarchart--edit-scene--dark:
- hash: v1.k794b7964.c822087b9f3b4dacc14222ae665653fcd28858c9d617f2366b5e1151ec753443.usu6mu7yzy4BrtgtxvphU6P9-LT1p4a7_a-82JdnR2I
+ hash: v1.k794b7964.46236d9adaeeb1a6bbb37ea1c4f4547fe101c3bfb599c6ce3f5604061808b52a.Dll_sk9dSBpLQhPOyLqjTvEvP39c8hlGfgozCEEhung
insights-funnelstepsbarchart--edit-scene--light:
- hash: v1.k794b7964.8370e33ef4683f05f4657864644b06c0b533b5ac2902deb488c47a4c71b721b2.zksMON4HCtbNZcWCxfsZMh7uNh33jj9-4GMI0OD6kpY
+ hash: v1.k794b7964.f1fe4fe0489eae529f52f1b529ade69417e36dc805969661a3395310a9230bdb.v88qRlvvjunu-s9gr5I61Q6pwyST3q9-A1O_zXPvLsQ
insights-funnelstepsbarchart--edit-scene-viewports--medium--dark:
- hash: v1.k794b7964.e91f9266d990e9fd2f060fb6649cb4eb797432f9adab96f53458169e3091595f.F0XkPv-RKknaisTAyCjEATzdMhDQIE-GH3cNPRV1XLY
+ hash: v1.k794b7964.8d2c17655abfa5f4ba15da90f223ecc275b2716c161a7ff4a0cedbc4caaf1e9e.vj9oElsByhn9tJOKh0PUse33A4XPtIclSuUvgLlVphg
insights-funnelstepsbarchart--edit-scene-viewports--medium--light:
- hash: v1.k794b7964.d26ddba0a3371ff575679c4a4c06c40fff62313710d349572c9700b8a151bd05.7UWh3BQW2mDrfS5U0wA7IL0Dx1UJQlVuW1HcYfURmLE
+ hash: v1.k794b7964.3d2f0878d120b3ba06e2666921a4d2c7f555b3610897082faf398b3d7bd41482.MBptraH3oySrfcz_VT0gjc6CTzlzC88vL-t0USwoy5I
insights-funnelstepsbarchart--edit-scene-viewports--superwide--dark:
- hash: v1.k794b7964.7c990d58db8120dedb679a30b769e0390b5733adc026bae3214455978f85e8c4.bdSyJ-fb31e6_W1dg9VhS9JRhXUCo_gMSQPqAwsAid8
+ hash: v1.k794b7964.9dce5b3d29a4b607afacb5faa12f13910aa2fc9ace9bdc16f1b6dbf0fb89344f.xdyLdREsFnhyabCWjwwfHTnoc3Gm9aQ6tac5bmSjzRM
insights-funnelstepsbarchart--edit-scene-viewports--superwide--light:
- hash: v1.k794b7964.b6f6606256932218dc828a9cec3c4181133efb89f5ec6313a5252266dd72dc2c.g14ayTGG86nrHyBuWLT0yvhQvlNqdj7xHAudDyTY1eg
+ hash: v1.k794b7964.ffb14ea0ee0246d50eb68db25b11113593caeb2b5eead99919d85942dc9438ec.Uyj0vuocd9oQdTVQArMRGnCp-Eri6MQ3vi8Z8pPqYCI
insights-funnelstepsbarchart--edit-scene-viewports--wide--dark:
- hash: v1.k794b7964.c822087b9f3b4dacc14222ae665653fcd28858c9d617f2366b5e1151ec753443.dKe5VercaBLrtxWY-idF29tVlyJ3m_QNXZN9BgGIBAI
+ hash: v1.k794b7964.46236d9adaeeb1a6bbb37ea1c4f4547fe101c3bfb599c6ce3f5604061808b52a.bRKGaqTGMD15hm21vLNNMkPMwuJO2fH3ptxdCUXIZwg
insights-funnelstepsbarchart--edit-scene-viewports--wide--light:
- hash: v1.k794b7964.8370e33ef4683f05f4657864644b06c0b533b5ac2902deb488c47a4c71b721b2.we8x9IDWROWKu70gYfKREcpIVipnN8fUYhHXA-2PgIg
+ hash: v1.k794b7964.f1fe4fe0489eae529f52f1b529ade69417e36dc805969661a3395310a9230bdb.3VX77dp5R_vLBzgiXIUB58EqMoYOFsCOV02lqX-vyR8
insights-funnelstepsbarchart--edit-scene-with-inline-events--dark:
- hash: v1.k794b7964.11bad65f540aed90ae9af7f3c15525da620641cf917f4b545c25009def6a3d69.DxTU0avRqfBkjq0FJPOh288pdAn3tYo0cFn3v527CFw
+ hash: v1.k794b7964.d15cb2407a975891d00840ba3b93c26a3d84164a253dfab114468415fdacb381.lNQXvkGaCW_Jreaco_6H0NOxcBAH4k7kxUrTy-HO1NY
insights-funnelstepsbarchart--edit-scene-with-inline-events--light:
- hash: v1.k794b7964.ed9da264e22da9093422bb8145df2539e3b00e2c00afdea7f582859385904ca1.tfge09VBFJ4-Cf7sdyoGmjkOVW6AqoUQF1844_PtiQ4
+ hash: v1.k794b7964.1abd3cdb07926c5bcdcd374fea9a2d410faaa62d07c5d2ddf4e18b9130189746.IOCy51-aovjU7IxbtTEBdUbT5Tc92FbeIBJlQhV9iUY
insights-funneltimetoconverttable--default--dark:
hash: v1.k794b7964.39fad6f5fd14cdf0e6d9e538cdc8eea2d6b0dbfc9f215c6226ae1b014b8b0c61.FEIbcPsm2lRRriC_2UPs1yryWU9SP5QiilC5IxwanY4
insights-funneltimetoconverttable--default--light:
@@ -5399,9 +5399,9 @@ snapshots:
scenes-app-dashboards--access-control-dashboard--light:
hash: v1.k794b7964.d101d57a6d623f754e7c62f7f79c78968822118050421f72c802718fa493a933.6pV1ojpc6ehy_SZd9xEHNQ0b8ZPGi1c-nuFHYebBLI8
scenes-app-dashboards--edit--dark:
- hash: v1.k794b7964.05dc1c7affea2043e96d14c4eeb5bd30dee08177abeb9f436d85257e2b155d29.x_P8HMgsyoPw_cyoV2-WBT2vamh7pvQaHHIXYEHF1Ug
+ hash: v1.k794b7964.b85e622d121e2edfb031fec73921ba7d775a50124f5d68c8c82ad28a51985434.eFMlXYTQdWLdvwn7YobjvgCNrFbx2IMXMt2Lzs0yyo4
scenes-app-dashboards--edit--light:
- hash: v1.k794b7964.8b431102d92c86f1b4f08a7f659eef04c308e6f3f6d8813cb0d46c2c9dc0ccfc.Q-R2cZ-tSHCKW2hjB_ofyaUX49dyiYEOHAHsaitYTMY
+ hash: v1.k794b7964.49c4e9690bd77d8c7a66dea80d23618e98cfbb1092f918bc47d7518de0bd4cad.2kla497MZylrcqwodI1R5fGyLuRQwKmuaXviNn4gVi0
scenes-app-dashboards--erroring--dark:
hash: v1.k794b7964.a356bf2ce40e53018919ebc890579c0ad6e493385f546d26b1f70471bf99f726.UER3Vv5UUZ1POzJv4_TuxrLBcLfLa8WTZ_hyUX9t72s
scenes-app-dashboards--erroring--light:
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index d89b9af8f24d..66a60350eed2 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -80,7 +80,7 @@ Charts fill their container and need a parent with real dimensions — a `0`-hei
- Every multi-series chart (`LineChart`, `BarChart`, `TimeSeriesLineChart`, `TimeSeriesBarChart`, `SlopeChart`) takes a `config.legend: ChartLegendConfig` (`{ show, position, align, gap, interactive, hiddenKeys, onToggleSeries, renderItem }`). With `show: true` the chart renders a built-in legend that, by default (`interactive`), is click-to-toggle: clicking a row hides that series (no draw, no scale contribution, no tooltip — the axes rescale into the freed space) while the row stays listed but dimmed so it can be restored. The chart owns the toggled-off state (uncontrolled); set `interactive: false` for a static legend, or pass `hiddenKeys` + `onToggleSeries` to control it yourself. Hidden by default. `config.legend.renderItem(defaultNode, item)` wraps each rendered row, so consumers can augment it (e.g. attach a right-click context menu) while keeping the default swatch/label/toggle rendering — return `defaultNode` to leave a row untouched. Toggling on time-series charts lists the user's series only (not derived trend lines / CI bands) — and hiding a series also hides everything derived from it (its CI band, moving average, and trend line), so no orphaned overlay floats over the gap.
- `Legend` (and `ChartLegend` for layout) is the lower-level presentational primitive: pass `items`, `onItemClick`, `hiddenKeys` — filtering series is the caller's state. Use it directly when the built-in `config.legend` can't express what you need (custom item order/labels). `useChartLegend(series, theme, config, items?)` is the shared hook the charts use — returns `visibleSeries` (hidden applied as `visibility.excluded`) plus `legendProps` to spread onto `<ChartLegend>`; `applyHiddenSeries` is the underlying helper. `LegendItem.secondaryLabel` shows muted trailing text (e.g. a slope chart's per-series change). Long labels clip with an ellipsis only when they run out of the space actually available — there is no fixed max width. A vertical legend bounds each row to its column and truncates at the column edge; a horizontal legend caps each row at an equal share of the line floored at 180px (flexbox wraps before it shrinks, so without a cap one long label would take a whole line instead of clipping) — many series pack into tidy 180px columns while a few series with room to spare, or a lone series, show unclipped whenever they fit. The full text is always exposed via a native `title` tooltip on hover. The legend slot in `ChartLegendLayout` is bounded and scrolls (a top/bottom legend caps at ~40% of the chart height so the plot keeps the majority; a left/right legend stretches to full chart height and caps at 45% width but never more than 240px), so a many-series legend scrolls instead of squeezing or stretching the chart. A left/right legend uses `align-self: stretch` (resolves against the container's used height, so it works even when no ancestor sets an explicit `height`). The top/bottom `max-height: 40%` cap is a percentage, so it only resolves when the chart container has an **explicit** `height` — a flex-derived used size (e.g. `flex: 1` with only `min-height`/`max-height`) does **not** count and the cap silently no-ops; pin a real `height` on the container.
- `SlopeChart` config: `showSeriesLabels` (name beside each point; steepest line wins label collisions), `showStartLabels`/`showEndLabels` (defaults overridable per series via `meta.showStartLabel`/`showEndLabel`), `legend` (`{ show, position }`, rows carry the formatted change, ordered biggest-to-smallest by end value to match the lines' right-edge order), `valueFormatter`/`deltaFormatter`. The value axis is hidden by default — the start/end labels are the readout. The default tooltip orders its rows biggest-to-smallest by the hovered point's value (so many-breakdown tooltips match the lines' vertical order) and formats values with `valueFormatter` so they match the on-chart labels' units; pass your own `tooltip` to override. (`DefaultTooltip` itself takes an optional `valueFormatter` for the same reason — without it values fall back to `toLocaleString`.) Per-series `meta.incompleteEnd` dashes only the second half of that connector (the last point is the current incomplete period); the renderer splits the final segment at its midpoint via `stroke.partial.fromFraction`, so a two-point line needs no phantom interior point.
-- `FunnelChart` is a thin wrapper over grouped `BarChart` that owns the funnel look (hatched `track`, rounded + shadowed bars, percent value axis). `steps` is a `string[]` of display labels — duplicates are fine, bands are keyed by step index internally. Each `Series.data[stepIndex]` is the conversion from the first step as a percent (0–100); `funnelFromCounts` builds the single-series case from raw `{ label, count }` steps (zero basis yields 0, not NaN). `onStepClick` replaces `onPointClick` and reports `{ stepIndex, converted }` — `converted: false` means the hatched drop-off track above the bar was clicked. `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars (and hides the built-in step labels); use it for step legends richer than an axis label. Config: `hideStepLabels`, `hideValueAxis`, `barCornerRadius`, `bandPadding`, `maxBandRange` (cluster a 2–3 step funnel instead of stretching it), plus the usual `tooltip`/`legend`/`margins`.
+- `FunnelChart` is a thin wrapper over grouped `BarChart` that owns the funnel look (hatched `track`, rounded + shadowed bars, percent value axis). `steps` is a `string[]` of display labels — duplicates are fine, bands are keyed by step index internally. Each `Series.data[stepIndex]` is the conversion from the first step as a percent (0–100); `funnelFromCounts` builds the single-series case from raw `{ label, count }` steps (zero basis yields 0, not NaN). `onStepClick` replaces `onPointClick` and reports `{ stepIndex, converted }` — `converted: false` means the hatched drop-off track above the bar was clicked. `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars (and hides the built-in step labels); use it for step legends richer than an axis label. Config: `hideStepLabels`, `hideValueAxis`, `barCornerRadius`, `bandPadding`, `maxBandRange` (cluster a 2–3 step funnel instead of stretching it), `chartMinHeight` (floor the plot region's px height when `stepFooter` is set, so a tall footer can't starve the `flex-1` canvas to zero height in a height-constrained column), plus the usual `tooltip`/`legend`/`margins`.
- `MetricCard` is a left-aligned tile. Pass `title={null}` to drop the title row — the header band collapses when there is no title and no change pill, and the subtitle row is omitted when there is no subtitle (and no `labels`), so a value-only card renders just the number. `changeSize="md"` renders a larger change pill (default `sm`); `changeInline` puts the pill beside the headline instead of in the header; `sparklineFill` makes the sparkline fill the card's remaining height instead of a fixed `sparklineHeight`; `sparklineDashedFromIndex` dashes the sparkline from that index onward (e.g. an in-progress trailing period). `subtitle` always wins (shown at rest and on hover); `restingSubtitle` (e.g. `'Avg'`) shows only at rest and yields to the hovered point's label on hover — pair it with a `value` that summarizes the series (average/total) so the headline reads as a summary until hovered. `hoverChangeFromPreviousPoint` keeps the supplied resting `change` pill at rest but, while hovering, swaps it for the hovered point's change vs the previous point (hidden at the first point). `changeTooltip` shows a styled hover tooltip (floating-ui, using the host's tooltip surface tokens with chart-surface fallbacks) on the change pill (e.g. to spell out what the resting comparison is).
- The composable form of `MetricCard` lives one layer up as `Metric` in `@posthog/quill-components` (it needs `Card`/`Badge` from primitives, which charts can't depend on). It's built on `Sparkline` plus the headless metric helpers this package exports — `resolveDelta` / `computeFallbackChangePercent` (delta math), `useAnimatedNumber` (count-up headline), `useHoverIntent` (hover dwell) — and the `MetricChange` / `ResolvedDelta` types. Reach for `Metric` when you need a custom layout; use the monolithic `MetricCard` here for the default self-contained tile.
- `TimeSeriesComboChart` wraps `ComboChart` the way `TimeSeriesLineChart`/`TimeSeriesBarChart` wrap their base charts: `config.xAxis`/`config.yAxis` (date tick formatter, y-format, scale, grid), `config.goalLines` (off-scale targets stretch the value axis via `ComboChart`'s `valueDomain`), `config.legend` (click-to-toggle), and `config.valueLabels`. Per-series `type` (`'bar' | 'line' | 'area'`) drives rendering; `barLayout` (`'stacked' | 'grouped' | 'percent'`), `divergingStack` (stacked only — negative bar values stack below the zero baseline instead of being clamped to 0, same semantics as `BarsConfig.divergingStack`), and right-axis series (`yAxisId: 'right'`) carry over from `ComboChart`. `ComboChart` itself now also honors `valueDomain` (primary axis only) and `showAxisLines`.
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
index 1c8ad8d67de6..f4203d4f7090 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
@@ -101,6 +101,23 @@ describe('FunnelChart', () => {
expect(chart.xTicks()).toHaveLength(0)
})
+ it('floors the chart region height with chartMinHeight so a tall footer cannot collapse the canvas', async () => {
+ renderHogChart(
+ <FunnelChart
+ steps={STEPS}
+ series={SERIES}
+ theme={THEME}
+ stepFooter={(stepIndex) => <span>{STEPS[stepIndex]}</span>}
+ config={{ chartMinHeight: 150 }}
+ />
+ )
+ await waitFor(() => {
+ expect(document.querySelectorAll('[data-attr="hog-funnel-step-footer-cell"]')).toHaveLength(STEPS.length)
+ })
+ const region = document.querySelector('[data-attr="hog-funnel-chart-region"]') as HTMLElement
+ expect(region.style.minHeight).toBe('150px')
+ })
+
it.each<[string, { label: string; count: number }[], number[]]>([
[
'zero basis collapses to 0 instead of NaN',
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
index b807748f1f69..001f44d264d3 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
@@ -44,6 +44,9 @@ export interface FunnelChartConfig {
/** Cap (px) on the band-axis range — clusters steps at the start of the plot instead of
* stretching a 2–3 step funnel across the full width. */
maxBandRange?: number
+ /** Min pixel height of the chart region when `stepFooter` is set, so a tall footer can't
+ * collapse the canvas to zero height in a height-constrained parent. */
+ chartMinHeight?: number
}
export interface FunnelStepClickData<Meta = unknown> extends PointClickData<Meta> {
@@ -169,6 +172,7 @@ export function FunnelChart<Meta = unknown>({
maxCategoryLabelWidth,
bandPadding,
maxBandRange,
+ chartMinHeight,
} = config ?? {}
const hasStepFooter = stepFooter != null
@@ -254,7 +258,15 @@ export function FunnelChart<Meta = unknown>({
return (
<div className="flex flex-col flex-1 min-h-0">
- <div className="flex-1 min-h-0">{chart}</div>
+ {/* Flex column so the chart stretches into the min-height floor. */}
+ {/* eslint-disable-next-line react/forbid-dom-props */}
+ <div
+ className="flex flex-col flex-1 min-h-0"
+ style={chartMinHeight != null ? { minHeight: chartMinHeight } : undefined}
+ data-attr="hog-funnel-chart-region"
+ >
+ {chart}
+ </div>
{bands && bands.length > 0 && <StepFooterRow bands={bands} stepFooter={stepFooter} />}
</div>
)
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
index acfa372c5dee..caec84cafb61 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarChart.tsx
@@ -2,10 +2,10 @@ import { useActions, useValues } from 'kea'
import posthog from 'posthog-js'
import { useCallback, useMemo, type ErrorInfo } from 'react'
-import { BarChart, DEFAULT_MARGINS } from '@posthog/quill-charts'
-import type { PointClickData, TooltipContext } from '@posthog/quill-charts'
+import { DEFAULT_MARGINS, FunnelChart } from '@posthog/quill-charts'
+import type { FunnelChartConfig, FunnelStepClickData, TooltipContext } from '@posthog/quill-charts'
-import { useChartConfig, useChartTheme } from 'lib/charts/hooks'
+import { useChartTheme } from 'lib/charts/hooks'
import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
import { StepLegend } from 'scenes/funnels/FunnelBarVertical/StepLegend'
import { funnelDataLogic } from 'scenes/funnels/funnelDataLogic'
@@ -15,24 +15,24 @@ import { insightLogic } from 'scenes/insights/insightLogic'
import { groupsModel } from '~/models/groupsModel'
import { ChartParams } from '~/types'
-import { buildFunnelStepsBarConfig, FUNNEL_STEPS_BAND_PADDING } from '../shared/funnelStepsBarShared'
import { FunnelStepsBarTooltip } from './FunnelStepsBarTooltip'
import {
buildFunnelStepsBarData,
+ FUNNEL_STEPS_BAR_TOOLTIP_CONFIG,
resolveFunnelStepClick,
- withFunnelStepsBarInteraction,
type FunnelStepsBarSeriesMeta,
} from './funnelStepsBarTransforms'
const BASE_STEP_WIDTH_PX = 240
const PER_BAR_WIDTH_PX = 20
-const chartConfig = buildFunnelStepsBarConfig({
- hideXAxis: true,
+const CHART_CONFIG: FunnelChartConfig = {
animateHover: true,
- tooltipPlacement: 'top',
+ // Keep the chart from collapsing under a tall StepLegend footer.
+ chartMinHeight: 150,
margins: { left: DEFAULT_MARGINS.left },
-})
+ tooltip: FUNNEL_STEPS_BAR_TOOLTIP_CONFIG,
+}
const handleChartError = (error: Error, info: ErrorInfo): void => {
posthog.captureException(error, {
@@ -57,7 +57,7 @@ export function FunnelStepsBarChart({
const showPersonsModal = canOpenPersonModal && showPersonsModalProp
const steps = visibleStepsWithConversionMetrics
- const { series, labels } = useMemo(
+ const { series } = useMemo(
() =>
buildFunnelStepsBarData(steps, {
getColor: getFunnelsColor,
@@ -66,20 +66,18 @@ export function FunnelStepsBarChart({
[steps, getFunnelsColor]
)
- const config = useChartConfig(() => withFunnelStepsBarInteraction(chartConfig), [])
+ // Feeds the tooltip header only; the visible labels come from the StepLegend footer.
+ const stepLabels = useMemo(() => steps.map((step) => String(step.custom_name ?? step.name ?? '')), [steps])
const groupTypeLabel = aggregationLabel(querySource?.aggregation_group_type_index).plural
const showTime = steps.some((step) => step.average_conversion_time != null)
const breakdownCount = series.length
const stepWidthPx = Math.max(BASE_STEP_WIDTH_PX, breakdownCount * PER_BAR_WIDTH_PX)
- const barsWidth = steps.length * stepWidthPx
- const chartWidth = DEFAULT_MARGINS.left + barsWidth + DEFAULT_MARGINS.right
-
- const stepBandWidthPx = stepWidthPx * (1 - FUNNEL_STEPS_BAND_PADDING)
+ const chartWidth = DEFAULT_MARGINS.left + steps.length * stepWidthPx + DEFAULT_MARGINS.right
- const onPointClick = useCallback(
- (clickData: PointClickData<FunnelStepsBarSeriesMeta>): void => {
+ const onStepClick = useCallback(
+ (clickData: FunnelStepClickData<FunnelStepsBarSeriesMeta>): void => {
const target = resolveFunnelStepClick(steps, clickData)
if (!target) {
return
@@ -104,54 +102,44 @@ export function FunnelStepsBarChart({
[steps, breakdownFilter, groupTypeLabel, showPersonsModal, insightData?.resolved_date_range, querySource]
)
+ const renderStepFooter = useCallback(
+ (stepIndex: number): JSX.Element | null => {
+ const step = steps[stepIndex]
+ if (!step) {
+ return null
+ }
+ return (
+ <StepLegend
+ step={step}
+ stepIndex={stepIndex}
+ showTime={showTime}
+ showPersonsModal={showPersonsModal}
+ inCardView={inCardView}
+ />
+ )
+ },
+ [steps, showTime, showPersonsModal, inCardView]
+ )
+
if (steps.length === 0) {
return null
}
return (
<ScrollableShadows direction="horizontal" className="flex-1" contentClassName="flex h-full flex-col">
- <div className="flex flex-1 flex-col" data-attr="funnel-steps-bar-chart">
- {/* eslint-disable-next-line react/forbid-dom-props */}
- <div
- className="flex min-h-[150px] flex-1"
- style={{ width: chartWidth }}
- data-attr="funnel-steps-bar-chart-canvas"
- >
- <BarChart<FunnelStepsBarSeriesMeta>
- series={series}
- labels={labels}
- theme={theme}
- config={config}
- tooltip={renderTooltip}
- onPointClick={showPersonsModal ? onPointClick : undefined}
- onError={handleChartError}
- />
- </div>
- {/* eslint-disable-next-line react/forbid-dom-props */}
- <div
- className="flex shrink-0"
- style={{ paddingLeft: DEFAULT_MARGINS.left, paddingRight: DEFAULT_MARGINS.right }}
- >
- <div className="flex shrink-0" style={{ width: barsWidth }}>
- {steps.map((step, stepIndex) => (
- <div
- key={stepIndex}
- className={`flex min-w-0 flex-1 ${stepIndex === 0 ? 'justify-start' : 'justify-center'}`}
- >
- {/* eslint-disable-next-line react/forbid-dom-props */}
- <div className="min-w-0 overflow-hidden" style={{ width: stepBandWidthPx }}>
- <StepLegend
- step={step}
- stepIndex={stepIndex}
- showTime={showTime}
- showPersonsModal={showPersonsModal}
- inCardView={inCardView}
- />
- </div>
- </div>
- ))}
- </div>
- </div>
+ {/* eslint-disable-next-line react/forbid-dom-props */}
+ <div className="flex flex-1 flex-col" style={{ width: chartWidth }} data-attr="funnel-steps-bar-chart">
+ <FunnelChart<FunnelStepsBarSeriesMeta>
+ steps={stepLabels}
+ series={series}
+ theme={theme}
+ config={CHART_CONFIG}
+ tooltip={renderTooltip}
+ onStepClick={showPersonsModal ? onStepClick : undefined}
+ stepFooter={renderStepFooter}
+ dataAttr="funnel-steps-bar-chart-canvas"
+ onError={handleChartError}
+ />
</div>
</ScrollableShadows>
)
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.test.ts b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.test.ts
index 865948bc4ef9..d0b415a8df29 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.test.ts
@@ -1,4 +1,4 @@
-import type { BarChartConfig, PointClickData, Series } from '@posthog/quill-charts'
+import type { PointClickData, Series } from '@posthog/quill-charts'
import { EntityTypes, type FunnelStepWithConversionMetrics } from '~/types'
@@ -6,7 +6,6 @@ import {
buildFunnelStepsBarData,
FUNNEL_STEPS_SERIES_KEY_PREFIX,
resolveFunnelStepClick,
- withFunnelStepsBarInteraction,
type FunnelStepsBarSeriesMeta,
} from './funnelStepsBarTransforms'
@@ -246,16 +245,3 @@ describe('resolveFunnelStepClick', () => {
expect(resolveFunnelStepClick(noBreakdownSteps, makeClick({ dataIndex: 99 }))).toBeNull()
})
})
-
-describe('withFunnelStepsBarInteraction', () => {
- const baseConfig: BarChartConfig = { barLayout: 'grouped', tooltip: { placement: 'top' } }
-
- it('enables a pinnable tooltip that resolves clicks to the nearest series', () => {
- // A breakdown puts one series per breakdown value at each step, so a pinnable tooltip
- // here always covers multiple series — resolveClickToNearestSeries must stay set or a
- // click pins the tooltip instead of opening the persons modal (the bug this guards).
- const config = withFunnelStepsBarInteraction(baseConfig)
-
- expect(config.tooltip).toEqual({ pinnable: true, resolveClickToNearestSeries: true, placement: 'cursor' })
- })
-})
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
index 3518e045d44c..951dfb6cfec0 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/funnelStepsBarTransforms.ts
@@ -1,4 +1,4 @@
-import type { BarChartConfig, PointClickData } from '@posthog/quill-charts'
+import type { PointClickData, TooltipConfig } from '@posthog/quill-charts'
import { getVisibilityKey } from 'scenes/funnels/funnelUtils'
@@ -114,15 +114,16 @@ function orderCompareSeriesPreviousFirst(
)
}
-/** Adds the pinnable tooltip to the base config. A breakdown always puts one series per breakdown
+/** Tooltip behaviour for the grouped funnel bars. A breakdown always puts one series per breakdown
* value at each step, so a pinnable tooltip here always covers multiple series —
* `resolveClickToNearestSeries` resolves the click to the nearest one and opens its persons modal
* directly instead of pinning first. */
-export function withFunnelStepsBarInteraction(baseConfig: BarChartConfig): BarChartConfig {
- return {
- ...baseConfig,
- tooltip: { ...INSIGHT_TOOLTIP_CONFIG, resolveClickToNearestSeries: true },
- }
+/** Pinnable, cursor-anchored tooltip for the grouped funnel bars. A breakdown puts one series per
+ * breakdown value at each step, so the tooltip always covers multiple series — `resolveClickToNearestSeries`
+ * makes a click open the nearest series' persons modal directly instead of pinning first. */
+export const FUNNEL_STEPS_BAR_TOOLTIP_CONFIG: TooltipConfig = {
+ ...INSIGHT_TOOLTIP_CONFIG,
+ resolveClickToNearestSeries: true,
}
export interface FunnelStepClickTarget {
diff --git a/products/product_analytics/frontend/insights/funnels/shared/funnelStepsBarShared.ts b/products/product_analytics/frontend/insights/funnels/shared/funnelStepsBarShared.ts
index e56f14db379a..d33635cd1db8 100644
--- a/products/product_analytics/frontend/insights/funnels/shared/funnelStepsBarShared.ts
+++ b/products/product_analytics/frontend/insights/funnels/shared/funnelStepsBarShared.ts
@@ -9,8 +9,7 @@ import { funnelConversionRate, RATE_TO_PERCENT } from './funnelBarHorizontalShar
export const FUNNEL_STEPS_BAR_SERIES_KEY = 'funnel-steps-bar-series'
-/** Inner gap between bars as a fraction of the band slot. Exported because the web container also
- * needs it for its per-step legend width math. */
+/** Inner gap between bars as a fraction of the band slot. */
export const FUNNEL_STEPS_BAND_PADDING = 0.1
export interface FunnelStepsBarConfigOptions {