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.

feat(funnels): show top-to-bottom funnels as a bar list behind a flag (#115007)

Sam Pennington144a3aaaaa32
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2166a3092185..48e65a85ddce 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3840,6 +3840,26 @@ snapshots:
hash: v1.k794b7964.2355c82ed442c788a592b52eb843bdce6f46a0271bc536a15b7bf55302cf2334.UE5P0FwOP8iHexSKvoYWRTNpgz0TzaZjOnWRaq-_Kmw
insights-boxplot--default--light:
hash: v1.k794b7964.386541e90a9caed4d5865519bbad75b61fc18096753958a99f50c3014a87d045.6ReLt-7ysRwo_ihjIAbS6r3gwjTpx3wlFeIgDzS8joQ
+ insights-funnelbarhorizontalchart--bar-list--dark:
+ hash: v1.k794b7964.f9f63faa0d3024bca090be9fd04732331c07dbdc43c663f4d12922f25952c24d.r6Zb69m5ENx0gkA2DUa71GN-qJh3cxYIsVV-nqocztw
+ insights-funnelbarhorizontalchart--bar-list--light:
+ hash: v1.k794b7964.b7f58cf6706059d2f9023ae48db92ae757ccbfb5934d06955cf2ba113418295b.rohzzIruhOZIXuogpANnb7DTsJfpikSb25chEGgS04o
+ insights-funnelbarhorizontalchart--bar-list-breakdown--dark:
+ hash: v1.k794b7964.db1cc8e8172a223933d0f45203fe098b51c10711e824ca2677c2df4b13879bc6.hZi6F78KpGKtcVG0SwUCvQ8wqgncufJX_Kqi2ogQILE
+ insights-funnelbarhorizontalchart--bar-list-breakdown--light:
+ hash: v1.k794b7964.bae7121e42020cd023044816a906a9616e6b2ff02ce924dd4323e86086a0fce3.awk4_KQeQOTADYUYM1UsvYPx_7329cQWA3IaNejKzck
+ insights-funnelbarhorizontalchart--bar-list-breakdown-compare--dark:
+ hash: v1.k794b7964.ea7d6748d945815af1a9801dea36142ce99748fbcc979ad9f5849bd87d84ee81.-8ig393meoKWWZSJPLgrO0HqYsH4ox_95fH7dPvcdFs
+ insights-funnelbarhorizontalchart--bar-list-breakdown-compare--light:
+ hash: v1.k794b7964.f780057f2fad99b74e48e4ee93a0844d50f2528d6dbcf719d99c45b601a1dbb1.zZahIt8lOR3cq2zTO-GhHqqOEaH7Qga_RQ5uqil_dj4
+ insights-funnelbarhorizontalchart--bar-list-compare--dark:
+ hash: v1.k794b7964.85f2a75e4149a204fcf29a4db82cc6a30970db2c2fdc4a8cec66c978f48d116d.cTfjTTiYv5VezDVQyP5eYgB7i_FnKhCuitx_SHCmZAc
+ insights-funnelbarhorizontalchart--bar-list-compare--light:
+ hash: v1.k794b7964.d220ec857610c896f9eded24222b2f7f5a44ee56a2f4543b2466082a27f6d575.aCkgFeLe6wFU-t8nylRl7SaqF6NgSXsKfBjmsRi49fs
+ insights-funnelbarhorizontalchart--bar-list-narrow--dark:
+ hash: v1.k794b7964.b2f0a52b522dead78c0245d8c4a6b34ea1dab30b9a8116fb8c9d7e96b8fd09c6.nZWtPXnQZcZKUyZMBjPP0Aa9H8fQDUjiz-UBIjSzIM8
+ insights-funnelbarhorizontalchart--bar-list-narrow--light:
+ hash: v1.k794b7964.e5f5ace706f6f7f5274ed38125e182d110d4f743de031f34670195a0b5f8d54a.YnNy_a3IGsd321UaDsjAJvzUo4tpdAu1AVBp_T8DOao
insights-funnelbarhorizontalchart--breakdown--dark:
hash: v1.k794b7964.ac5a15d1e2bb0e43d045a7927294882e733e23559dcaeb06d8ac6c1ebeb48755.SKkzdF8SPOh_RniQ11S8oDGsTTtKXko93TINN3LV4gw
insights-funnelbarhorizontalchart--breakdown--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 090265ce8cd7..ba12ca6e111d 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -185,6 +185,7 @@ export const FEATURE_FLAGS = {
CUSTOM_CSS_THEMES: 'custom-css-themes', // owner: #team-growth, used to enable custom CSS for teams who want to have fun
EXPERIMENT_ACTIVATION_EVENT: 'experiment-activation-event', // owner: #team-experiments, offers an activation event on top of the default exposure instead of legacy custom exposure events
EXPERIMENT_EXPOSURE_EVENT: 'experiment-exposure-event', // owner: #team-experiments, switches new experiments to the dedicated exposure event
+ FUNNEL_BAR_LIST: 'funnel-bar-list', // owner: @sampennington #team-product-analytics, top-to-bottom funnel as a bar list
FUNNEL_STEPS_BAR_LABELS: 'funnel-steps-bar-labels', // owner: @sampennington #team-product-analytics, left-to-right funnel with value labels on the bars, a name-only step legend and steps that shrink to fit
GAME_CENTER: 'game-center', // owner: everybody, this is just internal for now
HEDGEHOG_SKIN_SPIDERHOG: 'hedgehog-skin-spiderhog', // owner: #team-web-analytics, used to reward beta users for web analytics
diff --git a/products/product_analytics/frontend/insights/funnels/Funnel.tsx b/products/product_analytics/frontend/insights/funnels/Funnel.tsx
index eae7460741b9..8fc62bab206b 100644
--- a/products/product_analytics/frontend/insights/funnels/Funnel.tsx
+++ b/products/product_analytics/frontend/insights/funnels/Funnel.tsx
@@ -3,11 +3,13 @@ import './Funnel.scss'
import { useValues } from 'kea'
import { FunnelLayout } from 'lib/constants'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { insightLogic } from 'scenes/insights/insightLogic'
import { ChartParams, FunnelVizType } from '~/types'
import { FunnelBarHorizontalChart } from './FunnelBarHorizontalChart/FunnelBarHorizontalChart'
+import { FunnelBarListChart } from './FunnelBarListChart/FunnelBarListChart'
import { funnelDataLogic } from './funnelDataLogic'
import { FunnelFlowGraph } from './FunnelFlowGraph/FunnelFlowGraph'
import { FunnelHistogramChart } from './FunnelHistogramChart/FunnelHistogramChart'
@@ -18,6 +20,7 @@ export function Funnel(props: ChartParams): JSX.Element {
const { insightProps } = useValues(insightLogic)
const { funnelsFilter, funnelVizType } = useValues(funnelDataLogic(insightProps))
const { layout } = funnelsFilter || {}
+ const showBarList = useFeatureFlag('FUNNEL_BAR_LIST')
let viz: JSX.Element | null = null
if (funnelVizType == FunnelVizType.Trends) {
@@ -29,7 +32,7 @@ export function Funnel(props: ChartParams): JSX.Element {
} else if ((layout || FunnelLayout.vertical) === FunnelLayout.vertical) {
viz = <FunnelStepsBarChart {...props} />
} else {
- viz = <FunnelBarHorizontalChart {...props} />
+ viz = showBarList ? <FunnelBarListChart {...props} /> : <FunnelBarHorizontalChart {...props} />
}
return (
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.stories.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.stories.tsx
index 9f05f159eabd..aa012d487728 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.stories.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.stories.tsx
@@ -14,6 +14,7 @@ import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'
import { getCachedResults } from '~/queries/nodes/InsightViz/utils'
import { InsightLogicProps, InsightShortId } from '~/types'
+import { FunnelBarListChart } from '../FunnelBarListChart/FunnelBarListChart'
import { FunnelBarHorizontalChart } from './FunnelBarHorizontalChart'
type Story = StoryObj<{}>
@@ -36,7 +37,15 @@ function Stage({ children, width }: { children: React.ReactNode; width: number }
return <div style={{ width }}>{children}</div>
}
-function StoryRender({ insightFixture, width }: { insightFixture: any; width: number }): JSX.Element {
+function StoryRender({
+ insightFixture,
+ width,
+ Chart = FunnelBarHorizontalChart,
+}: {
+ insightFixture: any
+ width: number
+ Chart?: typeof FunnelBarHorizontalChart
+}): JSX.Element {
const [dashboardItemId] = useState(() => `FunnelBarHorizontalChartStory.${uniqueNode++}` as InsightShortId)
const source = insightFixture.query.source
const cachedInsight = { ...insightFixture, short_id: dashboardItemId }
@@ -53,7 +62,7 @@ function StoryRender({ insightFixture, width }: { insightFixture: any; width: nu
<BindLogic logic={insightLogic} props={insightProps}>
<BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>
<Stage width={width}>
- <FunnelBarHorizontalChart />
+ <Chart />
</Stage>
</BindLogic>
</BindLogic>
@@ -89,3 +98,30 @@ export const DefaultNarrow: Story = {
export const BreakdownNarrow: Story = {
render: () => <StoryRender insightFixture={funnelTopToBottomBreakdownFixture} width={320} />,
}
+
+// Funnel.tsx shows this layout behind the `funnel-bar-list` flag, so these stories render it directly.
+export const BarList: Story = {
+ render: () => <StoryRender insightFixture={funnelTopToBottomFixture} width={720} Chart={FunnelBarListChart} />,
+}
+
+export const BarListBreakdown: Story = {
+ render: () => (
+ <StoryRender insightFixture={funnelTopToBottomBreakdownFixture} width={720} Chart={FunnelBarListChart} />
+ ),
+}
+
+export const BarListCompare: Story = {
+ render: () => (
+ <StoryRender insightFixture={funnelTopToBottomCompareFixture} width={720} Chart={FunnelBarListChart} />
+ ),
+}
+
+export const BarListBreakdownCompare: Story = {
+ render: () => (
+ <StoryRender insightFixture={funnelTopToBottomBreakdownCompareFixture} width={720} Chart={FunnelBarListChart} />
+ ),
+}
+
+export const BarListNarrow: Story = {
+ render: () => <StoryRender insightFixture={funnelTopToBottomFixture} width={320} Chart={FunnelBarListChart} />,
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.tsx
index dfe1c9c52d17..7dbe2f5780cb 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalChart.tsx
@@ -20,6 +20,7 @@ import {
type FunnelBarHorizontalSegmentMeta,
} from './funnelBarHorizontalTransforms'
import { GlyphColumn } from './GlyphColumn'
+import { openFunnelSegmentPersons } from './openFunnelSegmentPersons'
import { SingleStepBar } from './SingleStepBar'
import { StepFooter } from './StepFooter'
import { StepHeader } from './StepHeader'
@@ -100,55 +101,11 @@ export function FunnelBarHorizontalChart({
{steps.map((step, stepIndex) => {
const isOptional = isStepOptional(stepIndex + 1)
- const onSegmentClick = (meta: FunnelBarHorizontalSegmentMeta): void => {
- // Stacked breakdown + compare: the drop-off band aggregates every value for the
- // period, so open the period's whole-step drop-off — compare-scoped, but with no
- // breakdown filter. Pure compare tags each drop-off with its period's
- // breakdownIndex instead, so it routes through the series branch below.
- if (isComparedFunnel && meta.isDropOff && meta.breakdownIndex == null) {
- if (meta.compareLabel) {
- openPersonsModalForSeries({
- step,
- series: {
- ...step,
- breakdown: undefined,
- breakdown_value: undefined,
- compare_label: meta.compareLabel,
- },
- converted: false,
- })
- }
- return
- }
- // Compare: both the bar and its drop-off filler carry a period breakdownIndex, so
- // route the matching period series (converted vs. dropped-off) — handled before the
- // generic drop-off branch, which would otherwise open the aggregate step.
- if (
- isComparedFunnel &&
- meta.breakdownIndex != null &&
- step.nested_breakdown?.[meta.breakdownIndex]
- ) {
- openPersonsModalForSeries({
- step,
- series: step.nested_breakdown[meta.breakdownIndex],
- converted: !meta.isDropOff,
- })
- return
- }
- if (meta.isDropOff) {
- openPersonsModalForStep({ step, converted: false })
- return
- }
- if (meta.breakdownIndex != null && step.nested_breakdown?.[meta.breakdownIndex]) {
- openPersonsModalForSeries({
- step,
- series: step.nested_breakdown[meta.breakdownIndex],
- converted: true,
- })
- return
- }
- openPersonsModalForStep({ step, converted: true })
- }
+ const onSegmentClick = (meta: FunnelBarHorizontalSegmentMeta): void =>
+ openFunnelSegmentPersons(step, meta, isComparedFunnel, {
+ openPersonsModalForStep,
+ openPersonsModalForSeries,
+ })
const renderTooltip = (ctx: TooltipContext<FunnelBarHorizontalSegmentMeta>): JSX.Element | null => (
<FunnelBarHorizontalTooltip
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.test.ts b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.test.ts
index 18936f5d294a..474681ccbbd3 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.test.ts
@@ -7,6 +7,7 @@ import {
type FunnelBarHorizontalStepData,
FUNNEL_BAR_HORIZONTAL_FILLER_KEY,
FUNNEL_BAR_HORIZONTAL_SEGMENT_KEY_PREFIX,
+ mergeFunnelBarHorizontalRows,
resolveFunnelBarHorizontalHover,
} from './funnelBarHorizontalTransforms'
@@ -771,4 +772,46 @@ describe('buildFunnelBarHorizontalData', () => {
])
})
})
+
+ describe('mergeFunnelBarHorizontalRows', () => {
+ it('stacks each row in one chart, with the drop-off last and the row meta per bar', () => {
+ const segment = (breakdownIndex: number, value: number): FunnelBarHorizontalStepData['series'][number] => ({
+ key: `${FUNNEL_BAR_HORIZONTAL_SEGMENT_KEY_PREFIX}${breakdownIndex}`,
+ label: `value ${breakdownIndex}`,
+ data: [value],
+ meta: { isDropOff: false, breakdownIndex },
+ })
+ const dropOff = (
+ value: number,
+ entry: number,
+ compareLabel: 'current' | 'previous'
+ ): FunnelBarHorizontalStepData['series'][number] => ({
+ key: FUNNEL_BAR_HORIZONTAL_FILLER_KEY,
+ label: 'Drop-off',
+ data: [value],
+ trackData: [entry],
+ meta: { isDropOff: true, breakdownIndex: null, compareLabel },
+ })
+ // The previous period's segment key first appears after the current period's drop-off.
+ const rows: FunnelBarHorizontalStepData[] = [
+ { label: '0', series: [segment(0, 60), dropOff(40, 100, 'current')] },
+ { label: '0', series: [segment(1, 50), dropOff(30, 80, 'previous')] },
+ ]
+
+ const merged = mergeFunnelBarHorizontalRows(rows)
+
+ expect(merged.map((s) => s.key)).toEqual([
+ `${FUNNEL_BAR_HORIZONTAL_SEGMENT_KEY_PREFIX}0`,
+ `${FUNNEL_BAR_HORIZONTAL_SEGMENT_KEY_PREFIX}1`,
+ FUNNEL_BAR_HORIZONTAL_FILLER_KEY,
+ ])
+ expect(merged.map((s) => s.data)).toEqual([
+ [60, 0],
+ [0, 50],
+ [40, 30],
+ ])
+ expect(merged[2].trackData).toEqual([100, 80])
+ expect(merged[2].bars?.map((bar) => bar.meta?.compareLabel)).toEqual(['current', 'previous'])
+ })
+ })
})
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.ts b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.ts
index 27793d1fabb5..fc536680ba3b 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/funnelBarHorizontalTransforms.ts
@@ -144,6 +144,32 @@ export function buildFunnelBarHorizontalCompareData(
})
}
+// Drop-off stacks last in every row, so a key first seen in a later row still stacks before it.
+export function mergeFunnelBarHorizontalRows(
+ bars: FunnelBarHorizontalStepData[]
+): Series<FunnelBarHorizontalSegmentMeta>[] {
+ const keys = [...new Set(bars.flatMap((bar) => bar.series.map((s) => s.key)))]
+ const ordered = [
+ ...keys.filter((key) => key !== FUNNEL_BAR_HORIZONTAL_FILLER_KEY),
+ ...keys.filter((key) => key === FUNNEL_BAR_HORIZONTAL_FILLER_KEY),
+ ]
+ return ordered.map((key) => {
+ const perRow = bars.map((bar) => bar.series.find((s) => s.key === key))
+ const first = perRow.find((s) => s != null)
+ const ceilings = perRow.map((s) => s?.trackData?.[0])
+ return {
+ key,
+ label: first?.label ?? key,
+ color: first?.color,
+ visibility: first?.visibility,
+ meta: first?.meta,
+ data: perRow.map((s) => s?.data[0] ?? 0),
+ bars: perRow.map((s) => ({ color: s?.color, label: s?.label, meta: s?.meta })),
+ trackData: ceilings.every((ceiling): ceiling is number => ceiling != null) ? ceilings : undefined,
+ }
+ })
+}
+
export interface FunnelBarHorizontalHoverTarget {
/** The breakdown variant (or the whole step) the tooltip should describe. */
series: FunnelStepWithConversionMetrics
@@ -318,7 +344,7 @@ function buildBreakdownCompareStacks(
}
/** Sums a period's first-step counts split by compare label — the basis for the shared stack scale. */
-function periodTotals(step: FunnelStepWithConversionMetrics | undefined): { current: number; previous: number } {
+export function periodTotals(step: FunnelStepWithConversionMetrics | undefined): { current: number; previous: number } {
let current = 0
let previous = 0
for (const variant of step?.nested_breakdown ?? []) {
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/openFunnelSegmentPersons.ts b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/openFunnelSegmentPersons.ts
new file mode 100644
index 000000000000..83111ac9eed1
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/openFunnelSegmentPersons.ts
@@ -0,0 +1,58 @@
+import { type FunnelStep, type FunnelStepWithConversionMetrics } from '~/types'
+
+import { type FunnelBarHorizontalSegmentMeta } from './funnelBarHorizontalTransforms'
+
+interface FunnelPersonsModalActions {
+ openPersonsModalForStep: (payload: { step: FunnelStep; converted: boolean }) => void
+ openPersonsModalForSeries: (payload: {
+ step: FunnelStep
+ series: Omit<FunnelStepWithConversionMetrics, 'nested_breakdown'>
+ converted: boolean
+ }) => void
+}
+
+export function openFunnelSegmentPersons(
+ step: FunnelStepWithConversionMetrics,
+ meta: FunnelBarHorizontalSegmentMeta,
+ isComparedFunnel: boolean,
+ { openPersonsModalForStep, openPersonsModalForSeries }: FunnelPersonsModalActions
+): void {
+ // Breakdown + compare: the drop-off spans every breakdown value, so open the period's whole-step drop-off.
+ if (isComparedFunnel && meta.isDropOff && meta.breakdownIndex == null) {
+ if (meta.compareLabel) {
+ openPersonsModalForSeries({
+ step,
+ series: {
+ ...step,
+ breakdown: undefined,
+ breakdown_value: undefined,
+ compare_label: meta.compareLabel,
+ },
+ converted: false,
+ })
+ }
+ return
+ }
+ // Compare: open the period's series here, before the generic drop-off branch opens the whole step.
+ if (isComparedFunnel && meta.breakdownIndex != null && step.nested_breakdown?.[meta.breakdownIndex]) {
+ openPersonsModalForSeries({
+ step,
+ series: step.nested_breakdown[meta.breakdownIndex],
+ converted: !meta.isDropOff,
+ })
+ return
+ }
+ if (meta.isDropOff) {
+ openPersonsModalForStep({ step, converted: false })
+ return
+ }
+ if (meta.breakdownIndex != null && step.nested_breakdown?.[meta.breakdownIndex]) {
+ openPersonsModalForSeries({
+ step,
+ series: step.nested_breakdown[meta.breakdownIndex],
+ converted: true,
+ })
+ return
+ }
+ openPersonsModalForStep({ step, converted: true })
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListChart.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListChart.tsx
new file mode 100644
index 000000000000..3e8f457c5a5f
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListChart.tsx
@@ -0,0 +1,218 @@
+import clsx from 'clsx'
+import { useActions, useValues } from 'kea'
+import posthog from 'posthog-js'
+import { type ErrorInfo, useMemo } from 'react'
+
+import { type PointClickData, StackedBarList, type TooltipContext } from '@posthog/quill-charts'
+
+import { useChartTheme } from 'lib/charts/hooks'
+import { insightLogic } from 'scenes/insights/insightLogic'
+import { userLogic } from 'scenes/userLogic'
+
+import { groupsModel } from '~/models/groupsModel'
+import { AvailableFeature, type ChartParams, type FunnelStepWithConversionMetrics, StepOrderValue } from '~/types'
+
+import { FunnelBarHorizontalTooltip } from '../FunnelBarHorizontalChart/FunnelBarHorizontalTooltip'
+import {
+ buildFunnelBarHorizontalCompareData,
+ buildFunnelBarHorizontalData,
+ FUNNEL_BAR_HORIZONTAL_VALUE_DOMAIN,
+ type FunnelBarHorizontalSegmentMeta,
+ type FunnelBarHorizontalStepData,
+ mergeFunnelBarHorizontalRows,
+} from '../FunnelBarHorizontalChart/funnelBarHorizontalTransforms'
+import { GlyphColumn } from '../FunnelBarHorizontalChart/GlyphColumn'
+import { openFunnelSegmentPersons } from '../FunnelBarHorizontalChart/openFunnelSegmentPersons'
+import { funnelDataLogic } from '../funnelDataLogic'
+import { funnelPersonsModalLogic } from '../funnelPersonsModalLogic'
+import { FunnelBarListDropOff } from './FunnelBarListDropOff'
+import { FunnelBarListLabel } from './FunnelBarListLabel'
+import { FunnelBarListValue } from './FunnelBarListValue'
+
+interface FunnelBarListRow {
+ stepIndex: number
+ bar: FunnelBarHorizontalStepData
+ /** Set only in compare mode. */
+ period?: 'current' | 'previous'
+}
+
+const BAR_HEIGHT = 24
+// Leaves more space above each label than below it, so the label reads as part of its own bar.
+const ROW_HEIGHT = 56
+// Transparent so the track shows through, but kept for hover, tooltip and click routing.
+const DROP_OFF_COLOR = 'transparent'
+
+const handleChartError = (error: Error, info: ErrorInfo): void => {
+ posthog.captureException(error, {
+ feature: 'funnels-bar-list-chart',
+ componentStack: info.componentStack ?? undefined,
+ })
+}
+
+export function FunnelBarListChart({ showPersonsModal: showPersonsModalProp = true }: ChartParams): JSX.Element | null {
+ const theme = useChartTheme()
+ const { insightProps } = useValues(insightLogic)
+ const {
+ visibleStepsWithConversionMetrics: steps,
+ funnelsFilter,
+ breakdownFilter,
+ isStepOptional,
+ getFunnelsColor,
+ querySource,
+ isComparedFunnel,
+ insightData,
+ hasPartialBreakdownSelection,
+ aggregationTargetLabel,
+ } = useValues(funnelDataLogic(insightProps))
+ const { canOpenPersonModal } = useValues(funnelPersonsModalLogic(insightProps))
+ const { openPersonsModalForStep, openPersonsModalForSeries } = useActions(funnelPersonsModalLogic(insightProps))
+ const { aggregationLabel } = useValues(groupsModel)
+ const { hasAvailableFeature } = useValues(userLogic)
+
+ const showPersonsModal = canOpenPersonModal && showPersonsModalProp
+ const isUnordered = funnelsFilter?.funnelOrderType === StepOrderValue.UNORDERED
+ const groupTypeLabel = aggregationLabel(querySource?.aggregation_group_type_index).plural
+ // Paths are user-based, so there is nothing to link to when aggregating by groups.
+ const showStepPaths =
+ hasAvailableFeature(AvailableFeature.PATHS_ADVANCED) && querySource?.aggregation_group_type_index == null
+
+ const rows = useMemo<FunnelBarListRow[]>(() => {
+ const options = {
+ breakdownFilter,
+ getColor: getFunnelsColor,
+ getLabel: (variant: FunnelStepWithConversionMetrics) =>
+ String(variant.breakdown_value ?? variant.name ?? ''),
+ fillerColor: DROP_OFF_COLOR,
+ }
+ if (!isComparedFunnel) {
+ return buildFunnelBarHorizontalData(steps, options).map((bar, stepIndex) => ({ stepIndex, bar }))
+ }
+ return buildFunnelBarHorizontalCompareData(steps, options).flatMap((step, stepIndex) =>
+ step.bars.map((bar, barIndex) => ({ stepIndex, bar, period: barIndex === 0 ? 'current' : 'previous' }))
+ )
+ }, [steps, breakdownFilter, getFunnelsColor, isComparedFunnel])
+ const labels = useMemo(() => rows.map((row) => `${row.stepIndex}:${row.period ?? 'all'}`), [rows])
+ const series = useMemo(() => mergeFunnelBarHorizontalRows(rows.map((row) => row.bar)), [rows])
+ const rowKeys = useMemo(() => rows.map((row) => new Set(row.bar.series.map((s) => s.key))), [rows])
+
+ if (steps.length === 0) {
+ return null
+ }
+
+ // The merged chart holds every row's segments, so narrow the tooltip to this row's.
+ const renderTooltip = (ctx: TooltipContext<FunnelBarHorizontalSegmentMeta>): JSX.Element | null => {
+ const row = rows[ctx.dataIndex]
+ if (!row) {
+ return null
+ }
+ const rowContext = {
+ ...ctx,
+ seriesData: ctx.seriesData
+ .filter((entry) => rowKeys[ctx.dataIndex].has(entry.series.key))
+ .map((entry) => {
+ const bar = entry.series.bars?.[ctx.dataIndex]
+ return {
+ ...entry,
+ color: bar?.color ?? entry.color,
+ series: { ...entry.series, meta: bar?.meta ?? entry.series.meta },
+ }
+ }),
+ }
+ return (
+ <FunnelBarHorizontalTooltip
+ context={rowContext}
+ step={steps[row.stepIndex]}
+ stepIndex={row.stepIndex}
+ firstStep={steps[0]}
+ breakdownFilter={breakdownFilter}
+ isPartialBreakdownSelection={hasPartialBreakdownSelection}
+ groupTypeLabel={groupTypeLabel}
+ showPersonsModal={showPersonsModal}
+ resolvedDateRange={insightData?.resolved_date_range}
+ compareTo={querySource?.compareFilter?.compare_to}
+ />
+ )
+ }
+
+ const onPointClick = showPersonsModal
+ ? ({ series: clicked, dataIndex }: PointClickData<FunnelBarHorizontalSegmentMeta>): void => {
+ const row = rows[dataIndex]
+ const meta = clicked.bars?.[dataIndex]?.meta ?? clicked.meta
+ if (row && meta) {
+ openFunnelSegmentPersons(steps[row.stepIndex], meta, isComparedFunnel, {
+ openPersonsModalForStep,
+ openPersonsModalForSeries,
+ })
+ }
+ }
+ : undefined
+
+ return (
+ <div data-attr="funnel-bar-list" className="flex w-full gap-2 p-4">
+ {/* Each step's first label line starts at the top of its rows, so the ring sits beside the label and bar. */}
+ <div className="shrink-0 pt-2.5">
+ {steps.map((step, stepIndex) => (
+ <div
+ key={step.order}
+ className={clsx('flex', isStepOptional(stepIndex + 1) && 'opacity-60')}
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ height: rows.filter((row) => row.stepIndex === stepIndex).length * ROW_HEIGHT }}
+ >
+ <GlyphColumn
+ index={stepIndex}
+ stepCount={steps.length}
+ glyphNumber={step.order + 1}
+ isUnordered={isUnordered}
+ isOptional={false}
+ hasOptionalSteps={false}
+ />
+ </div>
+ ))}
+ </div>
+ <div className="@container min-w-0 flex-1">
+ <StackedBarList
+ labels={labels}
+ series={series}
+ theme={theme}
+ config={{
+ labelPosition: 'top',
+ rowHeight: ROW_HEIGHT,
+ barHeight: BAR_HEIGHT,
+ valueDomain: FUNNEL_BAR_HORIZONTAL_VALUE_DOMAIN,
+ }}
+ renderLabel={(rowIndex) => (
+ <>
+ <FunnelBarListLabel
+ step={steps[rows[rowIndex].stepIndex]}
+ stepIndex={rows[rowIndex].stepIndex}
+ period={rows[rowIndex].period}
+ isUnordered={isUnordered}
+ isOptional={isStepOptional(rows[rowIndex].stepIndex + 1)}
+ showStepPaths={showStepPaths}
+ />
+ <span className="ml-1 shrink-0 whitespace-nowrap text-sm leading-4">
+ <FunnelBarListValue
+ step={steps[rows[rowIndex].stepIndex]}
+ firstStep={steps[0]}
+ period={rows[rowIndex].period}
+ aggregationTargetLabel={aggregationTargetLabel}
+ />
+ </span>
+ </>
+ )}
+ renderValue={(rowIndex) => (
+ <FunnelBarListDropOff
+ step={steps[rows[rowIndex].stepIndex]}
+ stepIndex={rows[rowIndex].stepIndex}
+ period={rows[rowIndex].period}
+ aggregationTargetLabel={aggregationTargetLabel}
+ />
+ )}
+ tooltip={renderTooltip}
+ onPointClick={onPointClick}
+ onError={handleChartError}
+ />
+ </div>
+ </div>
+ )
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListDropOff.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListDropOff.tsx
new file mode 100644
index 000000000000..f1fff1cffa25
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListDropOff.tsx
@@ -0,0 +1,34 @@
+import { IconTrendingFlatDown } from 'lib/lemon-ui/icons'
+import { humanFriendlyNumber, percentage } from 'lib/utils/numbers'
+import { pluralize } from 'lib/utils/strings'
+
+import { type Noun } from '~/models/groupsModel'
+import { type FunnelStepWithConversionMetrics } from '~/types'
+
+export interface FunnelBarListDropOffProps {
+ step: FunnelStepWithConversionMetrics
+ stepIndex: number
+ period?: 'current' | 'previous'
+ aggregationTargetLabel: Noun
+}
+
+export function FunnelBarListDropOff({
+ step,
+ stepIndex,
+ period,
+ aggregationTargetLabel,
+}: FunnelBarListDropOffProps): JSX.Element | null {
+ if (stepIndex === 0 || period) {
+ return null
+ }
+ return (
+ <span className="flex items-center gap-0.5 text-sm leading-4 text-secondary @max-sm:hidden">
+ <IconTrendingFlatDown className="text-danger" />
+ <span>
+ {percentage(1 - step.conversionRates.fromPrevious, 1)}
+ <span className="@max-xl:hidden">{` (${humanFriendlyNumber(step.droppedOffFromPrevious)} ${pluralize(step.droppedOffFromPrevious, aggregationTargetLabel.singular, aggregationTargetLabel.plural, false)})`}</span>
+ {' dropped off'}
+ </span>
+ </span>
+ )
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListLabel.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListLabel.tsx
new file mode 100644
index 000000000000..58a3792e384a
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListLabel.tsx
@@ -0,0 +1,66 @@
+import clsx from 'clsx'
+
+import { EntityFilterInfo } from 'lib/components/EntityFilterInfo'
+import { LemonDropdown } from 'lib/lemon-ui/LemonDropdown'
+
+import { type FunnelStepWithConversionMetrics } from '~/types'
+
+import { FunnelStepPathLinks } from '../shared/FunnelStepPathLinks'
+import { getActionFilterFromFunnelStep } from '../shared/funnelStepTableUtils'
+
+export interface FunnelBarListLabelProps {
+ step: FunnelStepWithConversionMetrics
+ stepIndex: number
+ period?: 'current' | 'previous'
+ isUnordered: boolean
+ isOptional: boolean
+ showStepPaths: boolean
+}
+
+export function FunnelBarListLabel({
+ step,
+ stepIndex,
+ period,
+ isUnordered,
+ isOptional,
+ showStepPaths,
+}: FunnelBarListLabelProps): JSX.Element {
+ if (period === 'previous') {
+ return <span className="truncate text-secondary">Previous period</span>
+ }
+ const name = isUnordered ? (
+ `Completed ${step.order + 1} steps`
+ ) : (
+ <EntityFilterInfo filter={getActionFilterFromFunnelStep(step)} />
+ )
+ const nameClassName = clsx(
+ '-ml-1 min-w-0 truncate px-1 text-sm leading-4 font-semibold',
+ isOptional && 'opacity-60'
+ )
+ return (
+ <>
+ {showStepPaths ? (
+ <LemonDropdown
+ overlay={<FunnelStepPathLinks stepIndex={stepIndex} />}
+ placement="bottom-start"
+ actionable
+ >
+ <button
+ type="button"
+ className={clsx(
+ nameClassName,
+ 'cursor-pointer rounded text-left hover:bg-fill-button-tertiary-hover'
+ )}
+ aria-haspopup="menu"
+ data-attr="funnel-step-paths-menu"
+ >
+ {name}
+ </button>
+ </LemonDropdown>
+ ) : (
+ <span className={nameClassName}>{name}</span>
+ )}
+ {isOptional ? <span className="shrink-0 text-secondary @max-sm:hidden">(optional)</span> : null}
+ </>
+ )
+}
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListValue.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListValue.tsx
new file mode 100644
index 000000000000..1e07ade9400d
--- /dev/null
+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarListChart/FunnelBarListValue.tsx
@@ -0,0 +1,35 @@
+import { humanFriendlyNumber, percentage } from 'lib/utils/numbers'
+import { pluralize } from 'lib/utils/strings'
+
+import { type Noun } from '~/models/groupsModel'
+import { type FunnelStepWithConversionMetrics } from '~/types'
+
+import { periodTotals } from '../FunnelBarHorizontalChart/funnelBarHorizontalTransforms'
+import { funnelConversionRate } from '../shared/funnelBarHorizontalShared'
+
+export interface FunnelBarListValueProps {
+ step: FunnelStepWithConversionMetrics
+ firstStep: FunnelStepWithConversionMetrics
+ period?: 'current' | 'previous'
+ aggregationTargetLabel: Noun
+}
+
+export function FunnelBarListValue({
+ step,
+ firstStep,
+ period,
+ aggregationTargetLabel,
+}: FunnelBarListValueProps): JSX.Element {
+ const count = period ? periodTotals(step)[period] : step.count
+ // Compare bars are scaled to the larger period, so show this period's own conversion.
+ const rate = period
+ ? funnelConversionRate(count, periodTotals(firstStep)[period])
+ : step.conversionRates.fromBasisStep
+ return (
+ <span className="text-secondary" translate="no">
+ <span className="font-semibold text-primary">{percentage(rate, 1)}</span>
+ <span className="@max-xl:hidden">{` (${humanFriendlyNumber(count)} ${pluralize(count, aggregationTargetLabel.singular, aggregationTargetLabel.plural, false)})`}</span>
+ <span className="@max-sm:hidden"> converted</span>
+ </span>
+ )
+}