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(experiments): render funnel metric results with quill funnel chart (#70991)

Sam Penningtonca20eff945fc
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index eee1b46d89ee..6e38d8908292 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5987,9 +5987,9 @@ snapshots:
scenes-app-experiments--experiment-frequentist-two-variants--light:
hash: v1.k794b7964.f92ae3b1acfa8fc4f98babb18e7c944e30b5749400dd382d43fa702b1bc0727b.v7qRnZU8furIdj048Ap7rBb0QbVoNS88_de-FqorlF8
scenes-app-experiments--experiment-with-funnel-metric--dark:
- hash: v1.k794b7964.96b1395012157c8db6f8b7c202fde3bc61fe5eac1ffc69e94e6aa7555d7aa761.Li7ufJd8K-fsREg0jONxzGhDJuDnuWcatmvY5cvdJRI
+ hash: v1.k794b7964.f33abe58d4dc3c42ee0aa09fb9cec2a8d0b4e17a0642164ed913c6b4b87691a4.iDS3IMV59UC7uXmUOJUd8j-NXLUiLeN8j4D6YndOszg
scenes-app-experiments--experiment-with-funnel-metric--light:
- hash: v1.k794b7964.251dc04d7466461679393d7cad275a9afb66b3d3b562c86078e25db37349150e.laYWvinsU-fNhfqh4ZAewzsgi6u563HDsMVraFRbXMw
+ hash: v1.k794b7964.2879d4616c2be606f1ecd3fa9725dab0afa286eb1c2c3fa5641f2d80312acb12.Pq3YUGkLgF7JQpGYIx2ESbALZux5B7X_IfH764vLVK8
scenes-app-experiments--experiment-with-legacy-funnels-query--dark:
hash: v1.k794b7964.6503cdfd33ae5f9d525d14dc8d43b047e8469beca7e5e489534347904efe1dec.2CtGz-wQvIwr_SQDthwlGJI5bVcJ7bFpetJricY-Lps
scenes-app-experiments--experiment-with-legacy-funnels-query--light:
@@ -6002,6 +6002,10 @@ snapshots:
hash: v1.k794b7964.3e78a41658e9e1b76cb2428cbb32582077b1b43f820744966285c0862ff7f556.0t5TdyC6dx2nKUFHy-DqEyw4L-07MqrloiHmOD5bo4Y
scenes-app-experiments--experiment-with-mean-metric--light:
hash: v1.k794b7964.2bd044c1fb951cc5280c8befc03b7534774e703e92aa268f228ab20bd2522411.AFij815dd9946fOpsJgW7T2G_FjYM3Njr7LJ87amVrQ
+ scenes-app-experiments--experiment-with-multi-step-funnel-metric--dark:
+ hash: v1.k794b7964.feb19120fcb35db2a44666c4e20b7728f8b9bb5d0c1bc38d41b7698f5722c181.Hw40iUldn70Z33rYE-zitkjrvytX-vhUGY03V3ycXNk
+ scenes-app-experiments--experiment-with-multi-step-funnel-metric--light:
+ hash: v1.k794b7964.9d7dfffb7317f37caea4ad6a4492ab88a74944025164c8985ae09d4598998dce.LTVbWdIGOWozyPbgjbbSanV3cqEaLuHls5Da2LEvzRw
scenes-app-experiments--experiment-with-multiple-metrics--dark:
hash: v1.k794b7964.c2b2dfac0dcf77fefa7bfcd55ad0022ee6a8f461f3c03d74448bab270ba7dd7b.DgmRBGi8wUsgVlPWENMllouOKXKtCawcdVWsU6Srd5U
scenes-app-experiments--experiment-with-multiple-metrics--light:
diff --git a/frontend/src/mocks/fixtures/api/experiments/experiment_with_multi_step_funnel_metric.json b/frontend/src/mocks/fixtures/api/experiments/experiment_with_multi_step_funnel_metric.json
new file mode 100644
index 000000000000..173bb27f0c6b
--- /dev/null
+++ b/frontend/src/mocks/fixtures/api/experiments/experiment_with_multi_step_funnel_metric.json
@@ -0,0 +1,118 @@
+{
+ "id": 16,
+ "name": "experiment-multi-step-funnel-metric",
+ "description": null,
+ "start_date": "2025-05-20T14:39:00Z",
+ "end_date": null,
+ "feature_flag_key": "experiment-multi-step-funnel-metric",
+ "feature_flag": {
+ "id": 141,
+ "team_id": 1,
+ "name": "Feature Flag for Experiment experiment-multi-step-funnel-metric",
+ "key": "experiment-multi-step-funnel-metric",
+ "filters": {
+ "groups": [
+ {
+ "properties": [],
+ "rollout_percentage": 100
+ }
+ ],
+ "multivariate": {
+ "variants": [
+ {
+ "key": "control",
+ "rollout_percentage": 34
+ },
+ {
+ "key": "test-1",
+ "rollout_percentage": 33
+ },
+ {
+ "key": "test-2",
+ "rollout_percentage": 33
+ }
+ ]
+ },
+ "holdout_groups": null,
+ "aggregation_group_type_index": null
+ },
+ "deleted": false,
+ "active": true,
+ "ensure_experience_continuity": false,
+ "has_encrypted_payloads": false,
+ "version": 1
+ },
+ "holdout": null,
+ "holdout_id": null,
+ "exposure_cohort": null,
+ "parameters": {
+ "feature_flag_variants": [
+ {
+ "key": "control",
+ "rollout_percentage": 34
+ },
+ {
+ "key": "test-1",
+ "rollout_percentage": 33
+ },
+ {
+ "key": "test-2",
+ "rollout_percentage": 33
+ }
+ ]
+ },
+ "running_time_calculation": {
+ "minimum_detectable_effect": 30,
+ "recommended_running_time": 0,
+ "recommended_sample_size": 0
+ },
+ "secondary_metrics": [],
+ "saved_metrics": [],
+ "saved_metrics_ids": null,
+ "filters": {},
+ "archived": false,
+ "deleted": false,
+ "created_by": {
+ "id": 1,
+ "uuid": "0196a5e4-1c5d-0000-8b8c-31ae10f6d7d7",
+ "distinct_id": "TM2Vy3T9MqY0HHAxgKBj95zZEaZ45MYSpuSxu6MaVNj",
+ "first_name": "Juraj",
+ "last_name": "",
+ "email": "[email protected]",
+ "is_email_verified": false,
+ "hedgehog_config": null,
+ "role_at_organization": "engineering"
+ },
+ "created_at": "2025-06-03T14:35:54.872677Z",
+ "updated_at": "2025-06-03T14:39:45.072683Z",
+ "type": "product",
+ "exposure_criteria": {
+ "filterTestAccounts": true
+ },
+ "metrics": [
+ {
+ "kind": "ExperimentMetric",
+ "series": [
+ {
+ "kind": "EventsNode",
+ "event": "signup completed"
+ },
+ {
+ "kind": "EventsNode",
+ "event": "onboarding started"
+ },
+ {
+ "kind": "EventsNode",
+ "event": "first insight created"
+ }
+ ],
+ "metric_type": "funnel",
+ "uuid": "3340a599-f56c-4e91-a31f-3e3f01528032"
+ }
+ ],
+ "metrics_secondary": [],
+ "primary_metrics_ordered_uuids": ["3340a599-f56c-4e91-a31f-3e3f01528032"],
+ "secondary_metrics_ordered_uuids": [],
+ "conclusion": null,
+ "conclusion_comment": null
+}
diff --git a/frontend/src/mocks/fixtures/api/experiments/funnel_metric_result_multi_step.json b/frontend/src/mocks/fixtures/api/experiments/funnel_metric_result_multi_step.json
new file mode 100644
index 000000000000..68c7aaf3989c
--- /dev/null
+++ b/frontend/src/mocks/fixtures/api/experiments/funnel_metric_result_multi_step.json
@@ -0,0 +1,67 @@
+{
+ "baseline": {
+ "denominator_sum": null,
+ "denominator_sum_squares": null,
+ "key": "control",
+ "number_of_samples": 989,
+ "numerator_denominator_sum_product": null,
+ "sum": 246.0,
+ "sum_squares": 246.0,
+ "step_counts": [812, 517, 246],
+ "validation_failures": []
+ },
+ "cache_key": "cache_08a7b94252174a9400b06680a11683be",
+ "cache_target_age": "2025-09-05T16:14:05.250745Z",
+ "calculation_trigger": null,
+ "credible_intervals": null,
+ "insight": null,
+ "is_cached": true,
+ "kind": "ExperimentQuery",
+ "last_refresh": "2025-09-04T16:14:05.250745Z",
+ "metric": null,
+ "next_allowed_client_refresh": "2025-09-04T16:15:05.250745Z",
+ "p_value": null,
+ "probability": null,
+ "query_metadata": {
+ "events": [],
+ "updated_at": "2025-09-04T16:14:11.089132Z"
+ },
+ "query_status": null,
+ "significance_code": null,
+ "significant": null,
+ "stats_version": null,
+ "timezone": "UTC",
+ "variant_results": [
+ {
+ "chance_to_win": 0.00010223913233654233,
+ "credible_interval": [-0.10891502266388127, -0.03366202531112027],
+ "denominator_sum": null,
+ "denominator_sum_squares": null,
+ "key": "test-1",
+ "method": "bayesian",
+ "number_of_samples": 874,
+ "numerator_denominator_sum_product": null,
+ "significant": true,
+ "sum": 301.0,
+ "sum_squares": 301.0,
+ "step_counts": [732, 498, 301],
+ "validation_failures": []
+ },
+ {
+ "chance_to_win": 0.9831535028773773,
+ "credible_interval": [0.002690288824904803, 0.06708670125273555],
+ "denominator_sum": null,
+ "denominator_sum_squares": null,
+ "key": "test-2",
+ "method": "bayesian",
+ "number_of_samples": 1137,
+ "numerator_denominator_sum_product": null,
+ "significant": true,
+ "sum": 452.0,
+ "sum_squares": 452.0,
+ "step_counts": [961, 690, 452],
+ "validation_failures": []
+ }
+ ],
+ "variants": null
+}
diff --git a/frontend/src/scenes/experiments/MetricsView/new/ResultDetails.tsx b/frontend/src/scenes/experiments/MetricsView/new/ResultDetails.tsx
index 8ee49b06776c..9a0bdfe7aa02 100644
--- a/frontend/src/scenes/experiments/MetricsView/new/ResultDetails.tsx
+++ b/frontend/src/scenes/experiments/MetricsView/new/ResultDetails.tsx
@@ -8,7 +8,7 @@ import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
import ViewRecordingsPlaylistButton from 'lib/components/ViewRecordingButton/ViewRecordingsPlaylistButton'
import { FEATURE_FLAGS } from 'lib/constants'
import { humanFriendlyNumber } from 'lib/utils/numbers'
-import { FunnelChart } from 'scenes/experiments/charts/funnel/FunnelChart'
+import { ExperimentFunnelChart } from 'scenes/experiments/charts/funnel/ExperimentFunnelChart'
import { experimentLogic } from 'scenes/experiments/experimentLogic'
import { VariantTag } from 'scenes/experiments/ExperimentView/VariantTag'
import { applySessionLinkability, getExposureFallbackFilter, getViewRecordingFilters } from 'scenes/experiments/utils'
@@ -26,14 +26,7 @@ import {
isExperimentMeanMetric,
isExperimentRatioMetric,
} from '~/queries/schema/schema-general'
-import {
- EntityType,
- Experiment,
- FilterLogicalOperator,
- FunnelStep,
- FunnelStepWithNestedBreakdown,
- RecordingUniversalFilters,
-} from '~/types'
+import { Experiment, FilterLogicalOperator, RecordingUniversalFilters } from '~/types'
import {
ExperimentVariantResult,
@@ -46,70 +39,6 @@ import {
isFrequentistResult,
} from '../shared/utils'
-/**
- * Convert new experiment results directly to DataDrivenFunnel format
- */
-function convertExperimentResultToFunnelSteps(
- result: CachedNewExperimentQueryResponse,
- metric: ExperimentMetric
-): FunnelStepWithNestedBreakdown[] {
- const allResults = [result.baseline, ...(result.variant_results || [])]
- // Use step_counts from any variant that has data, not just baseline (which might have 0 users)
- const stepCountsSource = allResults.find((r) => r.step_counts && r.step_counts.length > 0) || result.baseline
- const numSteps = (stepCountsSource.step_counts?.length || 0) + 1
- const funnelSteps: FunnelStepWithNestedBreakdown[] = []
-
- for (let stepIndex = 0; stepIndex < numSteps; stepIndex++) {
- const variantSteps: FunnelStep[] = allResults.map((variantResult, variantIndex) => {
- let count: number
- if (stepIndex === 0) {
- count = variantResult.number_of_samples
- } else {
- count = variantResult.step_counts?.[stepIndex - 1] || 0
- }
-
- let stepName: string
- if (stepIndex === 0) {
- stepName = 'Experiment exposure'
- } else if (isExperimentFunnelMetric(metric) && metric.series?.[stepIndex - 1]) {
- const series = metric.series[stepIndex - 1]
- if (series.kind === NodeKind.EventsNode) {
- stepName = series.custom_name || series.name || series.event || `Step ${stepIndex}`
- } else if (series.kind === NodeKind.ActionsNode) {
- stepName = series.custom_name || series.name || `Action ${series.id}`
- } else if (series.kind === NodeKind.ExperimentDataWarehouseNode) {
- stepName = series.custom_name || series.name || series.table_name || `Step ${stepIndex}`
- } else {
- stepName = `Step ${stepIndex}`
- }
- } else {
- stepName = `Step ${stepIndex}`
- }
-
- return {
- name: stepName,
- custom_name: null,
- order: stepIndex,
- count: count,
- type: 'events' as EntityType,
- breakdown_value: variantResult.key,
- breakdown_index: variantIndex,
- } as FunnelStep & { breakdown_index: number }
- })
-
- const baseStep = variantSteps[0]
- const totalCount = variantSteps.reduce((sum, step) => sum + step.count, 0)
-
- funnelSteps.push({
- ...baseStep,
- count: totalCount,
- nested_breakdown: variantSteps,
- })
- }
-
- return funnelSteps
-}
-
function SqlCollapsible({
hogql,
clickhouseSql,
@@ -341,12 +270,8 @@ export function ResultDetails({
<div className="space-y-4">
<LemonTable columns={columns} dataSource={dataSource} loading={false} />
{isExperimentFunnelMetric(metric) && (
- <FunnelChart
- steps={convertExperimentResultToFunnelSteps(result, metric)}
- showPersonsModal={false}
- disableBaseline={true}
- inCardView={true}
- experimentResult={result}
+ <ExperimentFunnelChart
+ result={result}
experiment={experiment}
metric={metric}
experimentQuery={experimentQuery}
diff --git a/frontend/src/scenes/experiments/charts/funnel/ExperimentFunnelChart.tsx b/frontend/src/scenes/experiments/charts/funnel/ExperimentFunnelChart.tsx
new file mode 100644
index 000000000000..1c1aaa98560e
--- /dev/null
+++ b/frontend/src/scenes/experiments/charts/funnel/ExperimentFunnelChart.tsx
@@ -0,0 +1,153 @@
+import { useMemo } from 'react'
+
+import {
+ FunnelChart,
+ type FunnelStepClickData,
+ RATE_TO_PERCENT,
+ type Series,
+ funnelConversionRate,
+} from '@posthog/quill-charts'
+
+import { useChartTheme } from 'lib/charts/hooks'
+import { LemonCard } from 'lib/lemon-ui/LemonCard'
+
+import {
+ ExperimentFunnelMetric,
+ ExperimentFunnelMetricStep,
+ ExperimentQuery,
+ NewExperimentQueryResponse,
+ NodeKind,
+} from '~/queries/schema/schema-general'
+import { getExperimentVariants, getVariantColor } from '~/scenes/experiments/utils'
+import { Experiment, StepOrderValue } from '~/types'
+
+import { openExperimentPersonsModal } from './experimentPersonsModal'
+import { FunnelTooltip } from './FunnelTooltip'
+import { StepFooterCell } from './StepFooterCell'
+import type { VariantFunnelMeta } from './types'
+
+/** Step label at index 0 — the frontend-only step that precedes the backend's step numbering. */
+const EXPOSURE_STEP_LABEL = 'Experiment exposure'
+
+/** Floor for the plot region so a tall step footer can't squeeze the bars out of the chart. */
+const MIN_PLOT_HEIGHT = 200
+
+/** Target width of one step's bars. Steps cluster at this width instead of stretching to fill the
+ * container, and shrink below it once the funnel is too wide to fit. */
+const STEP_BAND_WIDTH = 192
+
+export interface ExperimentFunnelChartProps {
+ result: NewExperimentQueryResponse
+ experiment: Experiment
+ metric: ExperimentFunnelMetric
+ /** Enables click-to-inspect actors on the funnel bars. */
+ experimentQuery?: ExperimentQuery
+}
+
+function getStepName(step: ExperimentFunnelMetricStep | undefined, stepNumber: number): string {
+ if (step?.kind === NodeKind.EventsNode) {
+ return step.custom_name || step.name || step.event || `Step ${stepNumber}`
+ }
+ if (step?.kind === NodeKind.ActionsNode) {
+ return step.custom_name || step.name || `Action ${step.id}`
+ }
+ if (step?.kind === NodeKind.ExperimentDataWarehouseNode) {
+ return step.custom_name || step.name || step.table_name || `Step ${stepNumber}`
+ }
+ return `Step ${stepNumber}`
+}
+
+/** Experiment funnel metric results as a quill-charts funnel — one band per step, one bar per variant. */
+export function ExperimentFunnelChart({
+ result,
+ experiment,
+ metric,
+ experimentQuery,
+}: ExperimentFunnelChartProps): JSX.Element {
+ const theme = useChartTheme()
+
+ const variants = useMemo(
+ () => [result.baseline, ...(result.variant_results ?? [])].filter(Boolean),
+ [result.baseline, result.variant_results]
+ )
+
+ const numMetricSteps = Math.max(metric.series.length, ...variants.map((v) => v.step_counts?.length ?? 0))
+
+ const steps = useMemo(() => {
+ const isUnordered = metric.funnel_order_type === StepOrderValue.UNORDERED
+ return [
+ EXPOSURE_STEP_LABEL,
+ ...Array.from({ length: numMetricSteps }, (_, i) =>
+ isUnordered ? `Completed ${i + 1} ${i === 0 ? 'step' : 'steps'}` : getStepName(metric.series[i], i + 1)
+ ),
+ ]
+ }, [metric.funnel_order_type, metric.series, numMetricSteps])
+
+ const series = useMemo<Series<VariantFunnelMeta>[]>(() => {
+ const flagVariants = getExperimentVariants(experiment)
+ return variants.map((variant) => {
+ const counts = [
+ variant.number_of_samples,
+ ...Array.from({ length: numMetricSteps }, (_, i) => variant.step_counts?.[i] ?? 0),
+ ]
+ return {
+ key: variant.key,
+ label: variant.key,
+ color: getVariantColor(variant.key, flagVariants),
+ data: counts.map((count) => funnelConversionRate(count, counts[0]) * RATE_TO_PERCENT),
+ meta: { variantKey: variant.key, counts },
+ }
+ })
+ }, [variants, experiment, numMetricSteps])
+
+ const stepTotals = useMemo(
+ () => steps.map((_, stepIndex) => series.reduce((sum, s) => sum + (s.meta?.counts[stepIndex] ?? 0), 0)),
+ [steps, series]
+ )
+
+ const config = useMemo(
+ () => ({
+ chartMinHeight: MIN_PLOT_HEIGHT,
+ maxBandRange: steps.length * STEP_BAND_WIDTH,
+ // Cursor-anchored like the insights funnel, instead of the funnel default pinned to the band top.
+ tooltip: { placement: 'cursor' as const },
+ }),
+ [steps.length]
+ )
+
+ const handleStepClick = ({
+ stepIndex,
+ converted,
+ series: clicked,
+ }: FunnelStepClickData<VariantFunnelMeta>): void => {
+ if (!experimentQuery || !clicked.meta) {
+ return
+ }
+ openExperimentPersonsModal({
+ stepIndex,
+ stepName: steps[stepIndex],
+ converted,
+ variantKey: clicked.meta.variantKey,
+ orderType: metric.funnel_order_type,
+ experimentQuery,
+ experiment,
+ })
+ }
+
+ return (
+ <LemonCard hoverEffect={false} className="h-96 flex flex-col p-2">
+ <FunnelChart<VariantFunnelMeta>
+ steps={steps}
+ series={series}
+ theme={theme}
+ config={config}
+ tooltip={(ctx) => <FunnelTooltip ctx={ctx} steps={steps} showClickHint={!!experimentQuery} />}
+ onStepClick={experimentQuery ? handleStepClick : undefined}
+ stepFooter={(stepIndex) => (
+ <StepFooterCell stepIndex={stepIndex} steps={steps} stepTotals={stepTotals} />
+ )}
+ dataAttr="experiment-funnel-chart"
+ />
+ </LemonCard>
+ )
+}
diff --git a/frontend/src/scenes/experiments/charts/funnel/FunnelBarVertical.tsx b/frontend/src/scenes/experiments/charts/funnel/FunnelBarVertical.tsx
deleted file mode 100644
index 04c9674ac878..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/FunnelBarVertical.tsx
+++ /dev/null
@@ -1,135 +0,0 @@
-import '../../../funnels/FunnelBarVertical/FunnelBarVertical.scss'
-
-import { createContext, useContext, useLayoutEffect, useRef, useState } from 'react'
-
-import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
-import { useResizeObserver } from 'lib/hooks/useResizeObserver'
-
-import { StepBarLabels } from '~/scenes/funnels/FunnelBarVertical/StepBarLabels'
-import { ChartParams } from '~/types'
-
-import { useFunnelChartData } from './FunnelChart'
-import { useFunnelTooltip } from './FunnelTooltip'
-import { StepBars } from './StepBars'
-import { StepLegend } from './StepLegend'
-
-interface TooltipContext {
- showTooltip: (rect: [number, number, number], stepIndex: number, series: any) => void
- hideTooltip: () => void
-}
-
-export const TooltipContext = createContext<TooltipContext | null>(null)
-
-export function useTooltip(): TooltipContext {
- const context = useContext(TooltipContext)
- if (!context) {
- throw new Error('useDataDrivenTooltip must be used within DataDrivenTooltipContext')
- }
- return context
-}
-
-interface FunnelBarVerticalCSSProperties extends React.CSSProperties {
- '--bar-width': string
- '--bar-row-height': string
-}
-
-export function FunnelBarVertical({ inCardView = false }: ChartParams): JSX.Element {
- const { stepsWithConversionMetrics } = useFunnelChartData()
- const { vizRef, showTooltip, hideTooltip } = useFunnelTooltip()
-
- const { height: availableHeight } = useResizeObserver({ ref: vizRef })
- const [scrollbarHeightPx, setScrollbarHeightPx] = useState(0)
- const [stepLegendRowHeightPx, setStepLegendRowHeightPx] = useState(0)
-
- const seriesCount = Math.max(...stepsWithConversionMetrics.map((step) => step.nested_breakdown?.length || 1), 1)
- // Calculate base bar width based on series count
- const widthLimits = [
- { min: 60, width: 4 },
- { min: 20, width: 8 },
- { min: 12, width: 16 },
- { min: 10, width: 20 },
- { min: 8, width: 24 },
- { min: 6, width: 32 },
- { min: 5, width: 40 },
- { min: 4, width: 48 },
- { min: 3, width: 64 },
- { min: 2, width: 96 },
- { min: 0, width: 192 },
- ]
-
- const baseBarWidthPx = widthLimits.find(({ min }) => seriesCount >= min)?.width ?? 192
-
- // In card view, CSS will apply calc(var(--bar-width) / 2), so we need to compensate
- // by doubling the width we set so the final rendered width is appropriate
- const barWidthPx = inCardView ? baseBarWidthPx * 2 : baseBarWidthPx
-
- const scrollRef = useRef<HTMLDivElement | null>(null)
- const stepLegendRowRef = useRef<HTMLTableRowElement | null>(null)
-
- useLayoutEffect(() => {
- if (scrollRef.current) {
- setScrollbarHeightPx(scrollRef.current.offsetHeight - scrollRef.current.clientHeight)
- }
- }, [availableHeight])
- useLayoutEffect(() => {
- if (stepLegendRowRef.current) {
- setStepLegendRowHeightPx(stepLegendRowRef.current.clientHeight)
- }
- }, [availableHeight])
-
- /** Average conversion time is only shown if it's known for at least one step. */
- // != is intentional to catch undefined too
- const showTime = stepsWithConversionMetrics.some((step) => step.average_conversion_time != null)
-
- const minimumBarHeightPx = 150
- const borderHeightPx = 1
-
- // available height - border - legend - (maybe) scrollbar
- const barRowHeight = `max(${minimumBarHeightPx}px, calc(${availableHeight}px - ${borderHeightPx}px - ${stepLegendRowHeightPx}px - ${scrollbarHeightPx}px))`
-
- return (
- <TooltipContext.Provider value={{ showTooltip, hideTooltip }}>
- <div className="FunnelBarVertical" ref={vizRef} data-attr="funnel-bar-vertical">
- <ScrollableShadows scrollRef={scrollRef} direction="horizontal">
- <table
- /* eslint-disable-next-line react/forbid-dom-props */
- style={
- {
- '--bar-width': `${barWidthPx}px`,
- '--bar-row-height': barRowHeight,
- } as FunnelBarVerticalCSSProperties
- }
- >
- <colgroup>
- {stepsWithConversionMetrics.map((_, i) => (
- <col key={i} width={0} />
- ))}
- <col width="100%" />
- {/* The last column is meant to fill up leftover space. */}
- </colgroup>
- <tbody>
- <tr>
- <td>
- <StepBarLabels />
- </td>
- {stepsWithConversionMetrics.map((step, stepIndex) => (
- <td key={stepIndex}>
- <StepBars step={step} stepIndex={stepIndex} />
- </td>
- ))}
- </tr>
- <tr ref={stepLegendRowRef}>
- <td />
- {stepsWithConversionMetrics.map((step, stepIndex) => (
- <td key={stepIndex}>
- <StepLegend step={step} stepIndex={stepIndex} showTime={showTime} />
- </td>
- ))}
- </tr>
- </tbody>
- </table>
- </ScrollableShadows>
- </div>
- </TooltipContext.Provider>
- )
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/FunnelChart.tsx b/frontend/src/scenes/experiments/charts/funnel/FunnelChart.tsx
deleted file mode 100644
index 084f69f1e0dd..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/FunnelChart.tsx
+++ /dev/null
@@ -1,101 +0,0 @@
-import '../../../funnels/Funnel.scss'
-
-import { createContext, useContext, useMemo } from 'react'
-
-import { ExperimentMetric, ExperimentQuery, NewExperimentQueryResponse } from '~/queries/schema/schema-general'
-import {
- ChartParams,
- Experiment,
- FunnelStepReference,
- FunnelStepWithConversionMetrics,
- FunnelStepWithNestedBreakdown,
-} from '~/types'
-
-import { FunnelBarVertical } from './FunnelBarVertical'
-import { FunnelDataProcessingOptions, processFunnelData } from './funnelUtils'
-
-export interface FunnelChartProps extends ChartParams {
- /** Raw funnel step data */
- steps: FunnelStepWithNestedBreakdown[]
- /** Step reference for conversion calculations - defaults to total */
- stepReference?: FunnelStepReference
- /** Breakdowns to hide from legend */
- hiddenLegendBreakdowns?: string[]
- /** Disable baseline for experiments */
- disableBaseline?: boolean
- /** Experiment result data */
- experimentResult: NewExperimentQueryResponse
- experiment?: Experiment
- /** Experiment metric configuration */
- metric?: ExperimentMetric
- /** Experiment query for actors query (optional) */
- experimentQuery?: ExperimentQuery
-}
-
-export interface FunnelChartDataContext {
- stepsWithConversionMetrics: FunnelStepWithConversionMetrics[]
- steps: FunnelStepWithNestedBreakdown[]
- hasFunnelResults: boolean
- experimentResult: NewExperimentQueryResponse
- experiment?: Experiment
- metric?: ExperimentMetric
- experimentQuery?: ExperimentQuery
-}
-
-const FunnelChartDataContext = createContext<FunnelChartDataContext | null>(null)
-
-export function useFunnelChartData(): FunnelChartDataContext {
- const context = useContext(FunnelChartDataContext)
- if (!context) {
- throw new Error('useFunnelChartData must be used within a experiment Funnel')
- }
- return context
-}
-
-/**
- * A data-driven funnel visualization component that accepts direct data instead of requiring a query.
- * This allows reusing the funnel visualization logic in where we have the data but not a query.
- * That is the case for experiments.
- */
-export function FunnelChart({
- steps,
- stepReference = FunnelStepReference.total,
- hiddenLegendBreakdowns = [],
- disableBaseline = false,
- inCardView = false,
- experimentResult,
- experiment,
- metric,
- experimentQuery,
- ...chartParams
-}: FunnelChartProps): JSX.Element {
- const processedData = useMemo(() => {
- const options: FunnelDataProcessingOptions = {
- stepReference,
- disableBaseline,
- hiddenLegendBreakdowns,
- }
- return processFunnelData(steps, options)
- }, [steps, stepReference, disableBaseline, hiddenLegendBreakdowns])
-
- const contextValue: FunnelChartDataContext = useMemo(
- () => ({
- stepsWithConversionMetrics: processedData.stepsWithConversionMetrics,
- steps: processedData.steps,
- hasFunnelResults: processedData.hasFunnelResults,
- experimentResult,
- experiment,
- metric,
- experimentQuery,
- }),
- [processedData, experimentResult, experiment, metric, experimentQuery]
- )
-
- return (
- <FunnelChartDataContext.Provider value={contextValue}>
- <div className={`pt-4 FunnelInsight FunnelInsight--type-steps-vertical${inCardView ? ' InsightCard' : ''}`}>
- <FunnelBarVertical {...chartParams} inCardView={inCardView} />
- </div>
- </FunnelChartDataContext.Provider>
- )
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/FunnelTooltip.tsx b/frontend/src/scenes/experiments/charts/funnel/FunnelTooltip.tsx
index 1f148147c62c..36dd68af91c1 100644
--- a/frontend/src/scenes/experiments/charts/funnel/FunnelTooltip.tsx
+++ b/frontend/src/scenes/experiments/charts/funnel/FunnelTooltip.tsx
@@ -1,157 +1,65 @@
-import clsx from 'clsx'
-import { useEffect, useRef, useState } from 'react'
+import {
+ type TooltipContext,
+ TooltipFooter,
+ TooltipSurface,
+ TooltipSwatch,
+ funnelConversionRate,
+} from '@posthog/quill-charts'
-import { EntityFilterInfo } from 'lib/components/EntityFilterInfo'
-import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
-import { LemonRow } from 'lib/lemon-ui/LemonRow'
-import { Lettermark, LettermarkColor } from 'lib/lemon-ui/Lettermark'
-import { humanFriendlyDuration } from 'lib/utils/durations'
import { humanFriendlyNumber, percentage } from 'lib/utils/numbers'
-import { ClickToInspectActors } from 'scenes/insights/InsightTooltip/InsightTooltip'
-import { useInsightTooltip } from 'scenes/insights/useInsightTooltip'
-import { formatBreakdownLabel } from 'scenes/insights/utils'
-import { getActionFilterFromFunnelStep } from 'scenes/insights/views/Funnels/funnelStepTableUtils'
-import { FunnelStepWithConversionMetrics } from '~/types'
+import type { VariantFunnelMeta } from './types'
-const FUNNEL_TOOLTIP_OFFSET_PX = 4
-
-export interface FunnelTooltipData {
- stepIndex: number
- series: FunnelStepWithConversionMetrics
-}
-
-interface FunnelTooltipProps {
- stepIndex: number
- series: FunnelStepWithConversionMetrics
- embedded?: boolean
-}
-
-function FunnelTooltipContent({ stepIndex, series, embedded = false }: FunnelTooltipProps): JSX.Element {
+function TooltipRow({ label, value }: { label: string; value: React.ReactNode }): JSX.Element {
return (
- <div
- className={clsx('FunnelTooltip InsightTooltip', {
- 'p-2': !embedded,
- 'border-none': embedded,
- 'shadow-none': embedded,
- })}
- >
- <LemonRow icon={<Lettermark name={stepIndex + 1} color={LettermarkColor.Gray} />} fullWidth>
- <strong>
- <EntityFilterInfo filter={getActionFilterFromFunnelStep(series)} allowWrap />
- {series.breakdown_value && (
- <>
- <span className="mx-1">•</span>
- {formatBreakdownLabel(series.breakdown_value, null, [], (value) => value?.toString() || '')}
- </>
- )}
- </strong>
- </LemonRow>
- <LemonDivider className="my-2" />
- <table>
- <tbody>
- <tr>
- <td>{stepIndex === 0 ? 'Entered' : 'Converted'}</td>
- <td>{humanFriendlyNumber(series.count)}</td>
- </tr>
- {stepIndex > 0 && (
- <>
- <tr>
- <td>Dropped off</td>
- <td>{humanFriendlyNumber(series.droppedOffFromPrevious || 0)}</td>
- </tr>
-
- <tr>
- <td>Conversion so far</td>
- <td>{percentage(series.conversionRates.total || 0, 2, true)}</td>
- </tr>
- </>
- )}
- {stepIndex > 0 && (
- <tr>
- <td>Conversion from previous</td>
- <td>{percentage(series.conversionRates.fromPrevious || 0, 2, true)}</td>
- </tr>
- )}
- {stepIndex > 0 && series.median_conversion_time != null && (
- <tr>
- <td>Median time from previous</td>
- <td>{humanFriendlyDuration(series.median_conversion_time, { maxUnits: 3 })}</td>
- </tr>
- )}
- {stepIndex > 0 && series.average_conversion_time != null && (
- <tr>
- <td>Average time from previous</td>
- <td>{humanFriendlyDuration(series.average_conversion_time, { maxUnits: 3 })}</td>
- </tr>
- )}
- </tbody>
- </table>
-
- <LemonDivider className="my-2" />
- <ClickToInspectActors groupTypeLabel="persons" />
+ <div className="flex items-center justify-between gap-4">
+ <span className="opacity-60">{label}</span>
+ <strong className="tabular-nums">{value}</strong>
</div>
)
}
-export function useFunnelTooltip(): {
- vizRef: React.RefObject<HTMLDivElement>
- showTooltip: (rect: [number, number, number], stepIndex: number, series: FunnelStepWithConversionMetrics) => void
- hideTooltip: () => void
-} {
- const vizRef = useRef<HTMLDivElement>(null)
- const { getTooltip } = useInsightTooltip()
-
- const [isTooltipShown, setIsTooltipShown] = useState(false)
- const [currentTooltip, setCurrentTooltip] = useState<FunnelTooltipData | null>(null)
- const [tooltipOrigin, setTooltipOrigin] = useState<[number, number, number] | null>(null)
-
- const showTooltip = (
- rect: [number, number, number],
- stepIndex: number,
- series: FunnelStepWithConversionMetrics
- ): void => {
- setIsTooltipShown(true)
- setCurrentTooltip({ stepIndex, series })
- setTooltipOrigin(rect)
+/** Tooltip for the hovered variant's bar: its counts at this step and how it converted into it. */
+export function FunnelTooltip({
+ ctx,
+ steps,
+ showClickHint,
+}: {
+ ctx: TooltipContext<VariantFunnelMeta>
+ steps: string[]
+ showClickHint: boolean
+}): JSX.Element | null {
+ const entry = ctx.seriesData.find((e) => e.series.key === ctx.hoveredSeriesKey) ?? ctx.seriesData[0]
+ const meta = entry?.series.meta
+ if (!entry || !meta) {
+ return null
}
-
- const hideTooltip = (): void => {
- setIsTooltipShown(false)
- setCurrentTooltip(null)
- setTooltipOrigin(null)
- }
-
- useEffect(() => {
- const svgRect = vizRef.current?.getBoundingClientRect()
- const [tooltipRoot, tooltipEl] = getTooltip()
- tooltipEl.style.opacity = isTooltipShown ? '1' : '0'
- const tooltipRect = tooltipEl.getBoundingClientRect()
-
- if (tooltipOrigin && currentTooltip) {
- tooltipRoot.render(
- <FunnelTooltipContent stepIndex={currentTooltip.stepIndex} series={currentTooltip.series} />
- )
-
- // Put the tooltip to the bottom right of the cursor, but flip to left if tooltip doesn't fit
- let xOffset: number
- if (
- svgRect &&
- tooltipRect &&
- tooltipOrigin[0] + tooltipOrigin[2] + tooltipRect.width + FUNNEL_TOOLTIP_OFFSET_PX >
- svgRect.x + svgRect.width
- ) {
- xOffset = -tooltipRect.width - FUNNEL_TOOLTIP_OFFSET_PX
- } else {
- xOffset = tooltipOrigin[2] + FUNNEL_TOOLTIP_OFFSET_PX
- }
- tooltipEl.style.left = `${window.pageXOffset + tooltipOrigin[0] + xOffset}px`
- tooltipEl.style.top = `${window.pageYOffset + tooltipOrigin[1]}px`
- } else {
- tooltipEl.style.left = 'revert'
- tooltipEl.style.top = 'revert'
- }
- }, [isTooltipShown, tooltipOrigin, currentTooltip]) // eslint-disable-line react-hooks/exhaustive-deps
-
- return { vizRef, showTooltip, hideTooltip }
+ const stepIndex = ctx.dataIndex
+ const count = meta.counts[stepIndex] ?? 0
+ const previousCount = stepIndex > 0 ? (meta.counts[stepIndex - 1] ?? 0) : null
+ return (
+ <TooltipSurface>
+ <div className="flex items-center gap-2 font-semibold mb-1">
+ <TooltipSwatch color={entry.color} />
+ <span className="truncate">
+ {steps[stepIndex]} · {meta.variantKey}
+ </span>
+ </div>
+ <TooltipRow label={stepIndex === 0 ? 'Entered' : 'Converted'} value={humanFriendlyNumber(count)} />
+ {previousCount != null && (
+ <>
+ <TooltipRow label="Dropped off" value={humanFriendlyNumber(Math.max(previousCount - count, 0))} />
+ <TooltipRow
+ label="Conversion so far"
+ value={percentage(funnelConversionRate(count, meta.counts[0] ?? 0), 2, true)}
+ />
+ <TooltipRow
+ label="Conversion from previous"
+ value={percentage(funnelConversionRate(count, previousCount), 2, true)}
+ />
+ </>
+ )}
+ {showClickHint && <TooltipFooter>Click to view users</TooltipFooter>}
+ </TooltipSurface>
+ )
}
diff --git a/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx b/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx
deleted file mode 100644
index 183172f1bbad..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/StepBar.tsx
+++ /dev/null
@@ -1,192 +0,0 @@
-import clsx from 'clsx'
-import { useRef } from 'react'
-
-import { percentage } from 'lib/utils/numbers'
-
-import {
- ExperimentActorsQuery,
- ExperimentQuery,
- isExperimentFunnelMetric,
- NodeKind,
-} from '~/queries/schema/schema-general'
-import { EXPOSURE_DEFAULT_EVENT } from '~/scenes/experiments/exposureContract'
-import { getExperimentVariants, getVariantColor } from '~/scenes/experiments/utils'
-import { funnelTitle } from '~/scenes/trends/persons-modal/persons-modal-utils'
-import { openPersonsModal } from '~/scenes/trends/persons-modal/PersonsModal'
-import type { Experiment } from '~/types'
-import { FunnelStepWithConversionMetrics } from '~/types'
-
-import { useTooltip } from './FunnelBarVertical'
-import { useFunnelChartData } from './FunnelChart'
-
-export interface StepBarProps {
- step: FunnelStepWithConversionMetrics
- stepIndex: number
-}
-
-interface StepBarCSSProperties extends React.CSSProperties {
- '--series-color': string
- '--conversion-rate': string
-}
-
-/**
- * Opens the persons modal for a specific funnel step in an experiment.
- * Handles the step number mapping between frontend (with "Experiment exposure" step)
- * and backend (without exposure step).
- */
-function openExperimentPersonsModalForSeries({
- step,
- stepIndex,
- converted,
- experimentQuery,
- experiment,
-}: {
- step: FunnelStepWithConversionMetrics
- stepIndex: number
- converted: boolean
- experimentQuery: ExperimentQuery
- experiment: Experiment
-}): void {
- const stepNo = stepIndex + 1
- const variantKey = step.breakdown_value as string
-
- // This should only be called for funnel metrics
- if (!isExperimentFunnelMetric(experimentQuery.metric)) {
- return
- }
-
- // Build title exactly like regular funnels (using frontend step numbering)
- const title = funnelTitle({
- converted,
- step: stepNo,
- breakdown_value: variantKey,
- label: step.name,
- order_type: experimentQuery.metric.funnel_order_type,
- })
-
- // IMPORTANT: For experiment funnels, the frontend adds an "Experiment exposure" step at index 0.
- // The backend actors query treats exposure as step 0 (returning all exposed actors) and the
- // actual metric events as steps 1..N, so frontend step indices map directly to backend steps.
- // Frontend: Step 0=Exposure, Step 1=$pageview, Step 2=click
- // Backend: Step 0=Exposure, Step 1=$pageview, Step 2=click
- const backendStepNo = stepIndex
-
- // The exposure step (step 0) only supports conversions ("all exposed actors").
- // A drop-off "before exposure" is not a meaningful query.
- if (backendStepNo === 0 && !converted) {
- return
- }
-
- // For drop-offs, the mapping is straightforward (funnelStep = -stepIndex):
- // Step 1 drop-off = "exposed but did not reach the first metric event" = backend -1
- // Step 2 drop-off = "completed step 1 but not step 2 (click)" = backend -2
- const funnelStep = converted ? backendStepNo : -backendStepNo
-
- // Create ExperimentActorsQuery with exposure configuration
- const query: ExperimentActorsQuery = {
- kind: NodeKind.ExperimentActorsQuery,
- source: experimentQuery,
- funnelStep,
- funnelStepBreakdown: variantKey, // Filter by variant
- includeRecordings: true,
- // Add exposure configuration from experiment
- exposureConfig: experiment?.exposure_criteria?.exposure_config || {
- kind: NodeKind.ExperimentEventExposureConfig,
- event: EXPOSURE_DEFAULT_EVENT,
- properties: [],
- },
- multipleVariantHandling: experiment?.exposure_criteria?.multiple_variant_handling || 'exclude',
- featureFlagKey: experiment?.feature_flag?.key || '',
- }
-
- // Open standard PersonsModal (same as regular funnels!)
- openPersonsModal({
- title,
- query,
- additionalSelect: { matched_recordings: 'matched_recordings' },
- })
-}
-
-export function StepBar({ step, stepIndex }: StepBarProps): JSX.Element | null {
- const ref = useRef<HTMLDivElement | null>(null)
- const { showTooltip, hideTooltip } = useTooltip()
- const { experiment, experimentQuery } = useFunnelChartData()
-
- /**
- * bail if the experiment is not loaded. also, this serves as type guard for the experiment.
- */
- if (!experiment) {
- return null
- }
-
- const variantKey = Array.isArray(step.breakdown_value)
- ? step.breakdown_value[0]?.toString() || ''
- : step.breakdown_value?.toString() || ''
-
- // Source variants from the feature flag (the source of truth used by VariantTag and the rest
- // of the experiment UI). A saved experiment always has a linked flag; if it somehow lacks
- // variants, the bars fall back to the muted color.
- const seriesColor = variantKey ? getVariantColor(variantKey, getExperimentVariants(experiment)) : 'var(--muted)'
-
- const handleDropoffClick = (): void => {
- if (experimentQuery) {
- openExperimentPersonsModalForSeries({
- step: step,
- stepIndex: stepIndex,
- converted: false, // Dropoffs
- experimentQuery,
- experiment,
- })
- }
- }
-
- const handleConversionClick = (): void => {
- if (experimentQuery) {
- openExperimentPersonsModalForSeries({
- step: step,
- stepIndex: stepIndex,
- converted: true, // Conversions
- experimentQuery,
- experiment,
- })
- }
- }
-
- return (
- <>
- <div
- className={clsx('StepBar')}
- /* eslint-disable-next-line react/forbid-dom-props */
- style={
- {
- '--series-color': seriesColor,
- '--conversion-rate': percentage(step.conversionRates.fromBasisStep, 1, true),
- } as StepBarCSSProperties
- }
- ref={ref}
- onMouseEnter={() => {
- if (ref.current) {
- const rect = ref.current.getBoundingClientRect()
- showTooltip([rect.x, rect.y, rect.width], stepIndex, step)
- }
- }}
- onMouseLeave={() => hideTooltip()}
- >
- <div
- className="StepBar__backdrop"
- onClick={handleDropoffClick}
- style={{
- cursor: stepIndex > 0 ? 'pointer' : 'default',
- }}
- />
- <div
- className="StepBar__fill"
- onClick={handleConversionClick}
- style={{
- cursor: 'pointer',
- }}
- />
- </div>
- </>
- )
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/StepBars.tsx b/frontend/src/scenes/experiments/charts/funnel/StepBars.tsx
deleted file mode 100644
index 0eeafce5225b..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/StepBars.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import clsx from 'clsx'
-
-import { FunnelStepWithConversionMetrics } from '~/types'
-
-import { StepBar } from './StepBar'
-
-interface StepBarsProps {
- step: FunnelStepWithConversionMetrics
- stepIndex: number
-}
-
-export function StepBars({ step, stepIndex }: StepBarsProps): JSX.Element {
- return (
- <div className={clsx('StepBars', stepIndex === 0 && 'StepBars--first')}>
- <div className="StepBars__grid">
- {Array.from({ length: 5 }, (_, i) => (
- <div
- key={`gridline-${stepIndex}-${i}`}
- className="StepBars__gridline StepBars__gridline--horizontal"
- />
- ))}
- </div>
- {step.nested_breakdown?.map((series, i) => (
- <StepBar key={`bar-${stepIndex}-${i}`} step={series} stepIndex={stepIndex} />
- )) || <StepBar step={step} stepIndex={stepIndex} />}
- </div>
- )
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/StepFooterCell.tsx b/frontend/src/scenes/experiments/charts/funnel/StepFooterCell.tsx
new file mode 100644
index 000000000000..ba5946931547
--- /dev/null
+++ b/frontend/src/scenes/experiments/charts/funnel/StepFooterCell.tsx
@@ -0,0 +1,56 @@
+import { funnelConversionRate } from '@posthog/quill-charts'
+
+import { IconTrendingFlat, IconTrendingFlatDown } from 'lib/lemon-ui/icons'
+import { Lettermark, LettermarkColor } from 'lib/lemon-ui/Lettermark'
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
+import { percentage } from 'lib/utils/numbers'
+import { pluralize } from 'lib/utils/strings'
+
+/** One cell of the per-step legend below the plot, pixel-aligned under that step's bars. */
+export function StepFooterCell({
+ stepIndex,
+ steps,
+ stepTotals,
+}: {
+ stepIndex: number
+ steps: string[]
+ stepTotals: number[]
+}): JSX.Element {
+ const label = steps[stepIndex]
+ const count = stepTotals[stepIndex]
+ const previousCount = stepIndex > 0 ? stepTotals[stepIndex - 1] : null
+ const droppedOff = previousCount != null ? Math.max(previousCount - count, 0) : 0
+ const droppedOffRate = previousCount ? 1 - funnelConversionRate(count, previousCount) : 0
+ return (
+ <div className="flex flex-col gap-1 px-1 py-2 text-xs">
+ <div className="flex items-center gap-1.5 font-medium">
+ <Lettermark name={stepIndex + 1} color={LettermarkColor.Gray} />
+ <span className="truncate" title={label}>
+ {label}
+ </span>
+ </div>
+ <Tooltip title="Users who completed this step, with conversion rate relative to the first step">
+ <div className="flex items-center gap-1.5">
+ <IconTrendingFlat className="text-success shrink-0" />
+ <span>
+ {pluralize(count, 'user')}{' '}
+ <span className="text-secondary">
+ ({percentage(funnelConversionRate(count, stepTotals[0]), 2)})
+ </span>
+ </span>
+ </div>
+ </Tooltip>
+ {previousCount != null && (
+ <Tooltip title="Users who didn't complete this step, with drop-off rate relative to the previous step">
+ <div className="flex items-center gap-1.5">
+ <IconTrendingFlatDown className="text-danger shrink-0" />
+ <span>
+ {pluralize(droppedOff, 'user')}{' '}
+ <span className="text-secondary">({percentage(droppedOffRate, 2)})</span>
+ </span>
+ </div>
+ </Tooltip>
+ )}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/experiments/charts/funnel/StepLegend.tsx b/frontend/src/scenes/experiments/charts/funnel/StepLegend.tsx
deleted file mode 100644
index 1b6c212d145a..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/StepLegend.tsx
+++ /dev/null
@@ -1,105 +0,0 @@
-import { IconClock } from '@posthog/icons'
-
-import { EntityFilterInfo } from 'lib/components/EntityFilterInfo'
-import { IconTrendingFlat, IconTrendingFlatDown } from 'lib/lemon-ui/icons'
-import { LemonRow } from 'lib/lemon-ui/LemonRow'
-import { Lettermark, LettermarkColor } from 'lib/lemon-ui/Lettermark'
-import { Tooltip } from 'lib/lemon-ui/Tooltip'
-import { humanFriendlyDuration } from 'lib/utils/durations'
-import { percentage } from 'lib/utils/numbers'
-import { capitalizeFirstLetter, pluralize } from 'lib/utils/strings'
-import { getActionFilterFromFunnelStep } from 'scenes/insights/views/Funnels/funnelStepTableUtils'
-
-import { isExperimentFunnelMetric } from '~/queries/schema/schema-general'
-import { FunnelStepWithConversionMetrics, StepOrderValue } from '~/types'
-
-import { useFunnelChartData } from './FunnelChart'
-
-interface StepLegendProps {
- step: FunnelStepWithConversionMetrics
- stepIndex: number
- showTime: boolean
-}
-
-export function StepLegend({ step, stepIndex, showTime }: StepLegendProps): JSX.Element {
- const { metric } = useFunnelChartData()
- const aggregationTargetLabel = { singular: 'user', plural: 'users' }
-
- const isUnorderedFunnel =
- !!metric && isExperimentFunnelMetric(metric) && metric.funnel_order_type === StepOrderValue.UNORDERED
- const unorderedStepLabel = `Completed ${stepIndex + 1} ${stepIndex === 0 ? 'step' : 'steps'}`
-
- const convertedCountPresentation = pluralize(
- step.count ?? 0,
- aggregationTargetLabel.singular,
- aggregationTargetLabel.plural
- )
- const droppedOffCountPresentation = pluralize(
- step.droppedOffFromPrevious ?? 0,
- aggregationTargetLabel.singular,
- aggregationTargetLabel.plural
- )
-
- const convertedCountPresentationWithPercentage = (
- <>
- {convertedCountPresentation}{' '}
- <span className="text-secondary">({percentage(step.conversionRates.fromBasisStep, 2)})</span>
- </>
- )
- const droppedOffCountPresentationWithPercentage = (
- <>
- {droppedOffCountPresentation}{' '}
- <span className="text-secondary">({percentage(1 - step.conversionRates.fromPrevious, 2)})</span>
- </>
- )
-
- return (
- <div className="StepLegend">
- <LemonRow icon={<Lettermark name={stepIndex + 1} color={LettermarkColor.Gray} />}>
- {isUnorderedFunnel ? (
- <span title={unorderedStepLabel}>{unorderedStepLabel}</span>
- ) : (
- <EntityFilterInfo filter={getActionFilterFromFunnelStep(step)} allowWrap />
- )}
- </LemonRow>
- <LemonRow icon={<IconTrendingFlat />} status="success" style={{ color: 'unset' }}>
- <Tooltip
- title={
- <>
- {capitalizeFirstLetter(aggregationTargetLabel.plural)} who completed this step,
- <br />
- with conversion rate relative to the first step
- </>
- }
- placement="right"
- >
- <span>{convertedCountPresentationWithPercentage}</span>
- </Tooltip>
- </LemonRow>
- {stepIndex > 0 && (
- <>
- <LemonRow icon={<IconTrendingFlatDown />} status="danger" style={{ color: 'unset' }}>
- <Tooltip
- title={
- <>
- {capitalizeFirstLetter(aggregationTargetLabel.plural)} who didn't complete this
- step,
- <br />
- with drop-off rate relative to the previous step
- </>
- }
- placement="right"
- >
- <span>{droppedOffCountPresentationWithPercentage}</span>
- </Tooltip>
- </LemonRow>
- {showTime && (
- <LemonRow icon={<IconClock />} title="Median time of conversion from previous step">
- {humanFriendlyDuration(step.median_conversion_time, { maxUnits: 3 }) || '–'}
- </LemonRow>
- )}
- </>
- )}
- </div>
- )
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.test.ts b/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.test.ts
new file mode 100644
index 000000000000..7233f3117d1c
--- /dev/null
+++ b/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.test.ts
@@ -0,0 +1,14 @@
+import { experimentActorsFunnelStep } from './experimentPersonsModal'
+
+describe('experimentActorsFunnelStep', () => {
+ it.each([
+ ['exposure step conversions map to step 0', 0, true, 0],
+ ['exposure step drop-offs are not queryable', 0, false, null],
+ ['first metric step conversions map to step 1', 1, true, 1],
+ ['first metric step drop-offs map to step -1', 1, false, -1],
+ ['second metric step conversions map to step 2', 2, true, 2],
+ ['second metric step drop-offs map to step -2', 2, false, -2],
+ ])('%s', (_name, stepIndex, converted, expected) => {
+ expect(experimentActorsFunnelStep(stepIndex as number, converted as boolean)).toBe(expected)
+ })
+})
diff --git a/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.ts b/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.ts
new file mode 100644
index 000000000000..6e9389cd3f15
--- /dev/null
+++ b/frontend/src/scenes/experiments/charts/funnel/experimentPersonsModal.ts
@@ -0,0 +1,69 @@
+import { funnelTitle } from 'scenes/trends/persons-modal/persons-modal-utils'
+import { openPersonsModal } from 'scenes/trends/persons-modal/PersonsModal'
+
+import { ExperimentActorsQuery, ExperimentQuery, NodeKind } from '~/queries/schema/schema-general'
+import { EXPOSURE_DEFAULT_EVENT } from '~/scenes/experiments/exposureContract'
+import { Experiment, StepOrderValue } from '~/types'
+
+/**
+ * `funnelStep` for the actors query behind a click on frontend step `stepIndex`, or null when the
+ * click isn't queryable. The backend actors funnel treats exposure as step 0 and the metric events
+ * as steps 1..N, matching the frontend's step indices, negated for drop-offs. Only a drop-off at
+ * the exposure step is meaningless — there's nothing to drop off from before exposure.
+ */
+export function experimentActorsFunnelStep(stepIndex: number, converted: boolean): number | null {
+ if (stepIndex === 0 && !converted) {
+ return null
+ }
+ return converted ? stepIndex : -stepIndex
+}
+
+export function openExperimentPersonsModal({
+ stepIndex,
+ stepName,
+ converted,
+ variantKey,
+ orderType,
+ experimentQuery,
+ experiment,
+}: {
+ stepIndex: number
+ stepName: string
+ converted: boolean
+ variantKey: string
+ orderType?: StepOrderValue
+ experimentQuery: ExperimentQuery
+ experiment: Experiment
+}): void {
+ const funnelStep = experimentActorsFunnelStep(stepIndex, converted)
+ if (funnelStep == null) {
+ return
+ }
+
+ const query: ExperimentActorsQuery = {
+ kind: NodeKind.ExperimentActorsQuery,
+ source: experimentQuery,
+ funnelStep,
+ funnelStepBreakdown: variantKey,
+ includeRecordings: true,
+ exposureConfig: experiment.exposure_criteria?.exposure_config || {
+ kind: NodeKind.ExperimentEventExposureConfig,
+ event: EXPOSURE_DEFAULT_EVENT,
+ properties: [],
+ },
+ multipleVariantHandling: experiment.exposure_criteria?.multiple_variant_handling || 'exclude',
+ featureFlagKey: experiment.feature_flag?.key || '',
+ }
+
+ openPersonsModal({
+ title: funnelTitle({
+ converted,
+ step: stepIndex + 1,
+ breakdown_value: variantKey,
+ label: stepName,
+ order_type: orderType,
+ }),
+ query,
+ additionalSelect: { matched_recordings: 'matched_recordings' },
+ })
+}
diff --git a/frontend/src/scenes/experiments/charts/funnel/funnelUtils.ts b/frontend/src/scenes/experiments/charts/funnel/funnelUtils.ts
deleted file mode 100644
index 5c30b6fd9e4f..000000000000
--- a/frontend/src/scenes/experiments/charts/funnel/funnelUtils.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { FunnelLayout } from 'lib/constants'
-import { flattenedStepsByBreakdown, stepsWithConversionMetrics } from 'scenes/funnels/funnelUtils'
-
-import {
- FlattenedFunnelStepByBreakdown,
- FunnelStepReference,
- FunnelStepWithConversionMetrics,
- FunnelStepWithNestedBreakdown,
-} from '~/types'
-
-export interface FunnelDataProcessingOptions {
- stepReference?: FunnelStepReference
- disableBaseline?: boolean
- hiddenLegendBreakdowns?: string[]
-}
-
-export interface ProcessedFunnelData {
- steps: FunnelStepWithNestedBreakdown[]
- stepsWithConversionMetrics: FunnelStepWithConversionMetrics[]
- flattenedBreakdowns: FlattenedFunnelStepByBreakdown[]
- hasFunnelResults: boolean
-}
-
-/**
- * Processes raw funnel step data into the format needed for visualization components.
- * This extracts the core data processing logic from funnelDataLogic.
- */
-export function processFunnelData(
- steps: FunnelStepWithNestedBreakdown[],
- options: FunnelDataProcessingOptions = {}
-): ProcessedFunnelData {
- const { stepReference = FunnelStepReference.total } = options
-
- // Sort steps by order (same as funnelDataLogic)
- const sortedSteps = steps.sort((a, b) => a.order - b.order)
-
- // Calculate conversion metrics
- const stepsWithMetrics = stepsWithConversionMetrics(sortedSteps, stepReference)
-
- // Flatten breakdowns for legend display (always use vertical layout)
- const flattenedBreakdowns = flattenedStepsByBreakdown(stepsWithMetrics, FunnelLayout.vertical, true)
-
- // Check if we have valid funnel results
- const hasFunnelResults = !!(sortedSteps && sortedSteps[0] && sortedSteps[0].count > -1)
-
- return {
- steps: sortedSteps,
- stepsWithConversionMetrics: stepsWithMetrics,
- flattenedBreakdowns,
- hasFunnelResults,
- }
-}
diff --git a/frontend/src/scenes/experiments/charts/funnel/types.ts b/frontend/src/scenes/experiments/charts/funnel/types.ts
new file mode 100644
index 000000000000..beb3b891a55f
--- /dev/null
+++ b/frontend/src/scenes/experiments/charts/funnel/types.ts
@@ -0,0 +1,6 @@
+/** Raw counts carried on each variant's chart series, for the tooltip and the actors query. */
+export interface VariantFunnelMeta {
+ variantKey: string
+ /** Absolute converted count per step; index 0 is the exposure count. */
+ counts: number[]
+}
diff --git a/frontend/src/scenes/experiments/stories/ExperimentWithMultiStepFunnelMetric.stories.tsx b/frontend/src/scenes/experiments/stories/ExperimentWithMultiStepFunnelMetric.stories.tsx
new file mode 100644
index 000000000000..8242e35f66d7
--- /dev/null
+++ b/frontend/src/scenes/experiments/stories/ExperimentWithMultiStepFunnelMetric.stories.tsx
@@ -0,0 +1,54 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { makeDelay } from 'lib/utils/async'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+import EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC from '~/mocks/fixtures/api/experiments/experiment_with_multi_step_funnel_metric.json'
+import EXPOSURE_QUERY_RESULT from '~/mocks/fixtures/api/experiments/exposure_query_result.json'
+import FUNNELS_METRIC_RESULT from '~/mocks/fixtures/api/experiments/funnel_metric_result_multi_step.json'
+import { NodeKind } from '~/queries/schema/schema-general'
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/Experiments',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ mockDate: '2025-01-27',
+ pageUrl: urls.experiment(EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC.id),
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ [`/api/projects/:team_id/experiments/${EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC.id}/`]:
+ EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC,
+ [`/api/projects/:team_id/experiment_holdouts`]: [],
+ [`/api/projects/:team_id/experiment_saved_metrics/`]: [],
+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC.feature_flag.id}/`]:
+ {},
+ [`/api/projects/:team_id/feature_flags/${EXPERIMENT_WITH_MULTI_STEP_FUNNEL_METRIC.feature_flag.id}/status/`]:
+ {},
+ [`/api/environments/:team_id/default_release_conditions/`]: [],
+ },
+ post: {
+ '/api/environments/:team_id/query/:kind': async ({ request }) => {
+ const body = (await request.json()) as Record<string, any>
+
+ if (body.query.kind === NodeKind.ExperimentExposureQuery) {
+ return [200, EXPOSURE_QUERY_RESULT]
+ }
+
+ return [200, FUNNELS_METRIC_RESULT]
+ },
+ },
+ }),
+ ],
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+// Small delay to ensure charts render completely
+export const ExperimentWithMultiStepFunnelMetric: Story = { play: makeDelay(500) }
diff --git a/frontend/src/styles/base.scss b/frontend/src/styles/base.scss
index 110cf78eff63..43992b8a5e88 100644
--- a/frontend/src/styles/base.scss
+++ b/frontend/src/styles/base.scss
@@ -642,7 +642,11 @@
--z-definition-popover: 1250;
--z-popover: 1200;
--z-graph-tooltip: 1150;
- --z-chart-tooltip: calc(var(--z-modal) - 50);
+
+ // Matches --z-graph-tooltip: charts render inside modals too, so their hover tooltips must
+ // sit above --z-modal. Pinned tooltips dismiss on outside pointer-down, so they can't linger
+ // over a modal opened after pinning.
+ --z-chart-tooltip: var(--z-graph-tooltip);
// 1161 and 1162 are reserved to be set from code
// 1166 through 1169 are reserved to be set from code
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 5c7012a21ddc..c3ce313336ce 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -83,6 +83,7 @@ Safari is the exception: it never fires `contextrestored`, so a context lost the
- Overlays (`ReferenceLine`/`ReferenceLines`, `ValueLabels`, `AxisTitles`, `TrendLineOverlay`, `HighlightedRange`) compose as children.
- `HighlightedRange` draws a translucent box spanning an x-axis range — pass `start`/`end` as data indices or labels (e.g. straight from `onDateRangeZoom`'s `startIndex`/`endIndex`). Use it to mirror an external selection (the rows visible in a paired virtualized list, a picked time window) onto the chart. On band (bar) charts the box covers the endpoints' full bands; on point (line) charts it runs point to point. `color`, `fillOpacity`, and `borderOpacity` tune the look (`borderOpacity: 0` drops the edge border); it clamps to the plot area and renders null when an endpoint doesn't resolve.
- `DefaultTooltip` (the built-in tooltip, also usable from a custom `tooltip` render prop) takes optional `valueFormatter`, `labelFormatter`, `labelRenderer`, `showHeader`, `showTotal`, `totalLabel`, `totalFormatter`, `sortedByValue`, `hideZeroRows`, `onRowClick`, and `footer`. `valueFormatter` gets `(value, entry)` — the row's `seriesData` entry as a second arg — so each row can format with its own `series.meta` (e.g. per-column currency/duration); it may return a node, not just a string (e.g. a property-formatted value). `labelFormatter` transforms the raw x-axis label shown in the tooltip header (e.g. convert an ISO datetime string to "Jun 24, 10:00"); on time-series charts with `xAxis.timezone` + `interval` set it defaults to an interval-aware date formatter that includes the weekday for single-day buckets ("Sat, Jun 6, 2026", "Sat, Jun 6, 14:00"; week/month buckets span days, so "Jun 1, 2026", "Jun 2026"), so the header matches the auto-formatted axis ticks — an explicit `labelFormatter` still wins. `labelRenderer` overrides how each row's label renders (defaults to the series label) — use for richer labels than a plain string, e.g. breakdown-value pills. `showHeader` (default true) toggles the header label row — pass false for charts without a meaningful header (pie slices, aggregated single-column bars). `showTotal` appends a footer row summing the visible series; it excludes `overlay` series (goal lines) and series with `visibility.total: false` (values that don't sum meaningfully with the rest, e.g. a percentage column alongside counts — the row itself still renders) from the sum, and is suppressed when fewer than two summable series remain. `totalFormatter` formats the total (defaults to `valueFormatter` applied with the first summable row's entry); `totalLabel` defaults to `'Total'`. `sortedByValue` sorts rows by value descending so the highest value appears first. `hideZeroRows` drops rows whose value is exactly `0` (e.g. lifecycle statuses absent for a period), so the tooltip lists only series with data at the hovered point. `onRowClick` makes each series row clickable (firing with the row's `seriesData` entry) — the tooltip must be pinned for clicks to land, since an unpinned tooltip is `pointer-events: none`; use it to open a per-series drill-down (e.g. the persons modal). `footer` renders arbitrary content below all rows (with a divider) — useful for "click to inspect" hints. A formatter taking only `value` stays compatible — the extra arg is ignored. Pinned tooltips are copy-friendly: outside-dismissal keys off where the press _started_ (pointer-down outside the tooltip/chart, or Escape), so a text-selection drag that releases outside the tooltip doesn't dismiss it, and a click that completes a text selection inside a row doesn't fire `onRowClick`.
+- A custom `tooltip` render prop builds its panel from the exported tooltip pieces: `TooltipSurface` (the floating panel), `TooltipSwatch` (series-color dot), and `TooltipFooter` (divider + muted row for a "click to inspect" hint — the same slot `DefaultTooltip`'s `footer` renders into, so a bespoke tooltip's hint stays styled like the built-in one).
- Touch devices are tap-driven (cartesian charts): a tap on a data point reveals its tooltip — pinned when `config.tooltip.pinnable`, so its rows are tappable for `onRowClick` drill-downs — a tap on a different point moves it there, and a tap on the point whose tooltip is already showing runs the click action (dismiss a pinned tooltip; fire `onPointClick` on non-pinnable charts). Tapping outside the chart, scrolling, or Escape dismisses. Mouse hover/click behavior is unchanged; the split lives in `useChartInteraction`, keyed off the pointerdown's `pointerType`.
- BarChart sets `TooltipContext.hoveredSeriesKey` — the key of the bar/segment under the cursor (stacked: the visible segment; grouped: the band-slot hit). Stacked `seriesData` keeps every segment in declaration order, so a custom tooltip that describes a single segment (e.g. a funnel breakdown) must select by `hoveredSeriesKey`, not `seriesData[0]`. It may reference a series hidden from `seriesData` via `visibility.tooltip: false` (e.g. a drop-off filler), and is `undefined` on other chart types and pinned rebuilds without a cursor.
- To tune the built-in tooltip **without writing a render prop**, put those same fields on `config.tooltip` (`{ enabled, pinnable, resolveClickToNearestSeries, placement, valueFormatter, labelFormatter, showTotal, totalLabel, totalFormatter, sortedByValue }`). When no `tooltip` render prop is supplied, the chart renders `DefaultTooltip` with them applied; a render prop, if given, owns content entirely and these are ignored. Prefer config for "format each row / add a total" cases (e.g. SQL insights pass per-column formatters this way) and reach for the render prop only for genuinely custom tooltip markup (e.g. adding a `footer` hint). `resolveClickToNearestSeries` (default false) changes what a click on a `pinnable` multi-series chart does: instead of always pinning first (letting the user then click a specific row), it resolves the series nearest the cursor and fires `onPointClick` for it directly — skip pinning only where a click's target series is visually unambiguous by position (e.g. funnel breakdown areas, one per breakdown value); leave it off where series overlap closely and a wrong guess is costly (e.g. trend lines).
diff --git a/packages/quill/packages/charts/src/core/hooks/useChartCanvas.ts b/packages/quill/packages/charts/src/core/hooks/useChartCanvas.ts
index 34b174070889..5701020303e6 100644
--- a/packages/quill/packages/charts/src/core/hooks/useChartCanvas.ts
+++ b/packages/quill/packages/charts/src/core/hooks/useChartCanvas.ts
@@ -46,7 +46,10 @@ export function useChartCanvas(options: UseChartCanvasOptions): UseChartCanvasRe
// `forceRepaint` publishes fresh state even when nothing moved — for a restored context,
// whose bitmap came back blank while every value stayed identical.
- const updateSize = (forceRepaint = false): void => {
+ // `layoutRect` overrides the measurement — getBoundingClientRect is scaled by ancestor
+ // transforms (e.g. a modal's open animation), so observer-driven updates pass the entry's
+ // transform-immune layout size instead.
+ const updateSize = (forceRepaint = false, layoutRect?: SizeRect): void => {
const canvas = canvasRef.current
const overlayCanvas = overlayCanvasRef.current
if (!canvas || !overlayCanvas) {
@@ -61,7 +64,7 @@ export function useChartCanvas(options: UseChartCanvasOptions): UseChartCanvasRe
return
}
- const rect = wrapper.getBoundingClientRect()
+ const rect = layoutRect ?? wrapper.getBoundingClientRect()
rectRef.current = rect
const dpr = window.devicePixelRatio || 1
@@ -87,10 +90,14 @@ export function useChartCanvas(options: UseChartCanvasOptions): UseChartCanvasRe
)
}
+ // The synchronous measure can be transform-scaled (a chart mounting inside a modal's
+ // open animation reads the mid-animation size, and no resize ever fires because the
+ // layout size never changed). The observer's guaranteed initial delivery corrects it.
updateSize()
- const observer = new ResizeObserver(() => {
- updateSize()
+ const observer = new ResizeObserver((entries) => {
+ const box = entries[entries.length - 1]?.borderBoxSize?.[0]
+ updateSize(false, box ? { width: box.inlineSize, height: box.blockSize } : undefined)
})
observer.observe(wrapper)
diff --git a/packages/quill/packages/charts/src/index.ts b/packages/quill/packages/charts/src/index.ts
index a56f669114b9..40897463d4d8 100644
--- a/packages/quill/packages/charts/src/index.ts
+++ b/packages/quill/packages/charts/src/index.ts
@@ -142,7 +142,7 @@ export type { ThemeFromCssOptions } from './core/theme'
// Built-in tooltip (for reference or extension)
export { DefaultTooltip, type DefaultTooltipProps } from './overlays/DefaultTooltip'
// Shared tooltip surface — reuse to build custom tooltips with the quill look
-export { TooltipSurface, TooltipSwatch } from './overlays/TooltipSurface'
+export { TooltipFooter, TooltipSurface, TooltipSwatch } from './overlays/TooltipSurface'
// Optional overlays
export { ReferenceLine, ReferenceLines } from './overlays/ReferenceLine'
diff --git a/packages/quill/packages/charts/src/overlays/DefaultTooltip.tsx b/packages/quill/packages/charts/src/overlays/DefaultTooltip.tsx
index 503ed808117d..657a8abccf0b 100644
--- a/packages/quill/packages/charts/src/overlays/DefaultTooltip.tsx
+++ b/packages/quill/packages/charts/src/overlays/DefaultTooltip.tsx
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef, useState } from 'react'
import type { TooltipContext } from '../core/types'
-import { TooltipSurface, TooltipSwatch } from './TooltipSurface'
+import { TooltipFooter, TooltipSurface, TooltipSwatch } from './TooltipSurface'
import { findClosestSeriesKey } from './tooltipUtils'
type SeriesDatum<Meta> = TooltipContext<Meta>['seriesData'][number]
@@ -200,9 +200,7 @@ export function DefaultTooltip<Meta = unknown>({
<strong data-attr="hog-chart-tooltip-value">{formatTotal(total)}</strong>
</div>
)}
- {footer && (
- <div className="mt-1 pt-1 border-t border-current/25 text-xs opacity-60 text-center">{footer}</div>
- )}
+ {footer && <TooltipFooter>{footer}</TooltipFooter>}
</TooltipSurface>
)
}
diff --git a/packages/quill/packages/charts/src/overlays/TooltipSurface.tsx b/packages/quill/packages/charts/src/overlays/TooltipSurface.tsx
index c1435ccc0fe0..1aa9ec187842 100644
--- a/packages/quill/packages/charts/src/overlays/TooltipSurface.tsx
+++ b/packages/quill/packages/charts/src/overlays/TooltipSurface.tsx
@@ -46,6 +46,11 @@ export function TooltipSurface({
)
}
+/** Divider plus muted row below a tooltip's content — e.g. a "click to inspect" hint. */
+export function TooltipFooter({ children }: { children: React.ReactNode }): React.ReactElement {
+ return <div className="mt-1 pt-1 border-t border-current/25 text-xs opacity-60 text-center">{children}</div>
+}
+
/** Round series-color swatch used in tooltip rows. */
export function TooltipSwatch({ color }: { color: string }): React.ReactElement {
return (