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.

fix(insights): make near-zero funnel bars hoverable and clickable (#93948)

Sam Penningtone7d4cd4f3cdd
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 6346720273f4..9f038308c950 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -50,7 +50,7 @@ const series: Series[] = [
- `labels` entries must be **unique** — the x-scale keys positions off the strings, so a duplicate collapses onto the first occurrence's position and draws the series backwards. On time-series charts pass ISO date strings (never formatted display labels like "1–7 Jun", which repeat across years) and format ticks via `xAxis.timezone`/`interval` or `tickFormatter`.
- Line-only options: `points`, `stroke.pattern` (dashes/projections), `fill.opacity` / `fill.gradient` (area), `fill.lowerData` (ribbon).
- Bar-only options: `bars` (per-bar `color`/`label`/`meta` overrides, plus `hatch: true` to fill that bar with a diagonal-hatch pattern in its resolved color — flags individual not-final bars, e.g. buckets still being ingested, at arbitrary indices; for a contiguous trailing range `stroke.partial.fromIndex` does the same); `trackData` caps each bar's interactive extent at a per-bar ceiling in value units — the region beyond `trackData[i]` is a fully inert gap: no hover, tooltip, pointer cursor, highlight, or click (the chart vetoes the hover there via `resolveHoverIndex`). On grouped charts with `bars.track` the hatched "share of a whole" track also fills only to the ceiling; on stacked charts no track is drawn — the ceiling only bounds interactivity. Funnel compare uses it to draw a shorter period's volume gap as empty space rather than drop-off, in both its grouped (left-to-right) and stacked (top-to-bottom) charts.
-- `BarChartConfig.bars.minBarSize` (px) floors each non-zero bar's thickness along the value axis so a single-occurrence bucket stays visible beside a spike three orders of magnitude taller (the old chart.js `minBarLength`) — zero-valued bars are never floored, so empty buckets stay empty. On a stacked chart only the outermost segment is floored — flooring an interior one would oversize a rect the segment above overpaints while still capturing its hover and clicks — so a breakdown stack floors only its top segment, and the option is aimed at single-series volume charts and grouped bars; `Sparkline` doesn't expose the prop. `TimeSeriesBarChart` takes `minBarSize`, `bandPadding`, `margins`, and `maxCategoryLabelWidth` as top-level config keys (alongside `barCornerRadius`/`fillStyle`) rather than under `bars`.
+- `BarChartConfig.bars.minBarSize` (px) floors each non-zero bar's thickness along the value axis so a single-occurrence bucket stays visible beside a spike three orders of magnitude taller (the old chart.js `minBarLength`) — zero-valued bars are never floored, so empty buckets stay empty. On a stacked chart only the outermost segment is floored — flooring an interior one would oversize a rect the segment above overpaints while still capturing its hover and clicks — so a breakdown stack floors only its top segment, and the option is aimed at single-series volume charts and grouped bars; `Sparkline` doesn't expose the prop. `bars.minBarSizeScope: 'hover'` restricts the floor to the hover highlight and hit-testing — the static layer draws true sizes and a tiny bar "grows" to a clickable nub under the cursor (while its track is hovered, the floored bar is also revealed in its plain color); the default `'always'` floors the static layer too. `TimeSeriesBarChart` takes `minBarSize`, `bandPadding`, `margins`, and `maxCategoryLabelWidth` as top-level config keys (alongside `barCornerRadius`/`fillStyle`) rather than under `bars`.
- `ChartConfig.margins` overrides only the sides it sets — a side left `undefined` keeps the chart's computed margin, so an object built conditionally (`{ top: reserveOrUndefined }`) is safe. `SlopeChart` merges consumer margins over its computed label gutters with the same rule (`applyMarginOverride`), so an `undefined` side keeps the gutter its value/name labels reserved.
- `yAxisId` scales a series against a second axis; `meta` carries arbitrary data into tooltips.
@@ -87,7 +87,7 @@ Safari is the exception: it never fires `contextrestored`, so a context lost the
- `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. Rows share one grid (swatch, label, value), so the value column is as wide as the widest value and every row's label ends at the same x — a `labelRenderer` that pushes part of its label right (e.g. a date) lines up as a column down the tooltip. 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.
+- 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. Grouped layouts also set `TooltipContext.inTrackArea` — `true` when the cursor is in the hovered bar's band slot but beyond its filled extent, measured on the same laid-out rects as click routing (`minBarSize` flooring included), so a tooltip's converted/drop-off framing always matches what a click at that position resolves to.
- To tune the built-in tooltip **without writing a render prop**, put those same fields on `config.tooltip` (`{ enabled, pinnable, resolveClickToNearestSeries, placement, hitArea, 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). `hitArea` applies to bar charts and sets what the cursor must be over: `bar` (the default) needs the painted bar, so the empty space above a short bar shows nothing, while `band` accepts anywhere in the hovered band. `Sparkline` uses `band` for its bars, because a sparkline bar can be a pixel tall and a zero bucket has no bar to aim at. `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).
- `ReferenceLine` variants: `goal` (dashed grey), `alert` (dashed red), `marker` (solid thin). A numeric line reveals its value on hover of the line itself (via a wider invisible hit area) or its label — appended as `label: value` when it has a label, shown alone when it doesn't — matching the legacy chart.js goal-line behavior.
- `TrendLineOverlay` renders linear/exponential regression lines as SVG polylines on vertical bar and combo charts. Use via `trendLines?: TrendLineConfig[]` in `TimeSeriesBarChartConfig` or `TimeSeriesComboChartConfig` — the chart computes the derived series via `buildTrendLineSeries` and passes them to the overlay as a child. Only works for `axisOrientation: 'vertical'`; returns null on horizontal charts. Legend-toggled-off series are filtered automatically.
@@ -95,7 +95,7 @@ Safari is the exception: it never fires `contextrestored`, so a context lost the
- Every multi-series chart (`LineChart`, `BarChart`, `TimeSeriesLineChart`, `TimeSeriesBarChart`, `SlopeChart`, `PieChart`) takes a `config.legend: ChartLegendConfig` (`{ show, position, align, gap, interactive, hiddenKeys, onToggleSeries, onSetHiddenSeries, visibilityGroupKey, renderItem }`). With `show: true` the chart renders a built-in legend that, by default (`interactive`), follows Grafana's click model: **a plain click isolates that series** — every other row is hidden (no draw, no scale contribution, no tooltip, so the axes rescale into the freed space) while staying listed but dimmed — and clicking the isolated row again restores all. **⌘/Ctrl-click (or Shift-click) toggles one series** in or out of the visible set, so a selection is built up a row at a time. Picking one series out of twenty is the common case, and it costs one click rather than nineteen. A legend with one visibility group has nothing to isolate, so a plain click toggles instead. On a coarse pointer (touch screen) there is no ⌘/Ctrl/Shift, so a plain tap toggles instead of isolating, letting taps build any subset the way the checkbox legend table does (isolate stays reachable through the row menu). `visibilityGroupKey(rowKey)` maps a row onto the identity its visibility is actually stored against: rows sharing a group share one visibility bit, so isolating keeps the whole group visible, "only this one is visible" is judged per group, and the group count — not the row count — is what decides `canIsolate`. It defaults to the row's own key, so a legend whose rows are independent needs nothing. Trends needs it because comparing to the previous period puts a series' current and previous rows on one `resultCustomizations` key: without the hint the library would isolate a row, correctly leave its twin visible, and then never recognise the result as isolated — so the second click could not restore. The chart owns the toggled-off state (uncontrolled); set `interactive: false` for a static legend, or pass `hiddenKeys` + `onToggleSeries` to control it yourself. A controlled legend must also pass `onSetHiddenSeries(nextHiddenKeys)` for isolating and hide-all to work — they replace the whole hidden set at once, which the per-key `onToggleSeries` can't express in one update; without it a controlled legend degrades to plain toggling, and an uncontrolled one needs nothing extra. Hidden by default. `config.legend.renderItem(defaultNode, item, controls)` wraps each rendered row, so consumers can augment it (e.g. attach a right-click context menu) while keeping the default swatch/label/toggle rendering — return `defaultNode` to leave a row untouched. `controls` is that row's `LegendItemControls`: state (`isHidden`, `isOnlyVisible`, `areAllVisible`, `canIsolate`) plus the actions (`toggle`, `isolate`, `toggleAll`) running the same paths as the clicks, so a row menu never re-derives visibility or duplicates the isolate logic. "All" and "the others" mean the legend's _rows_, not `series` — derived overlays (CI bands, trend lines) have no row and are never isolated against. Toggling on time-series charts lists the user's series only (not derived trend lines / CI bands) — and hiding a series also hides everything derived from it (its CI band, moving average, and trend line), so no orphaned overlay floats over the gap.
- `Legend` (and `ChartLegend` for layout) is the lower-level presentational primitive: pass `items`, `onItemClick`, `hiddenKeys` — filtering series is the caller's state. `onItemClick(key, { additive })` reports whether the click carried ⌘/Ctrl/Shift; deciding what each gesture means is the caller's job (`useChartLegend` is what turns it into isolate vs toggle). Use it directly when the built-in `config.legend` can't express what you need (custom item order/labels). `useChartLegend(series, theme, config, items?)` is the shared hook the charts use — returns `visibleSeries` (hidden applied as `visibility.excluded`) plus `legendProps` to spread onto `<ChartLegend>`; `applyHiddenSeries` is the underlying helper. `LegendItem.secondaryLabel` shows muted trailing text (e.g. a slope chart's per-series change). Long labels clip with an ellipsis only when they run out of the space actually available — there is no fixed max width. A vertical legend bounds each row to its column and truncates at the column edge; a horizontal legend caps each row at an equal share of the line floored at 180px (flexbox wraps before it shrinks, so without a cap one long label would take a whole line instead of clipping) — many series pack into tidy 180px columns while a few series with room to spare, or a lone series, show unclipped whenever they fit. The full text is always exposed via a native `title` tooltip on hover. The legend slot in `ChartLegendLayout` is bounded and scrolls (a top/bottom legend caps at ~40% of the chart height so the plot keeps the majority; a left/right legend stretches to full chart height and caps at 45% width but never more than 240px), so a many-series legend scrolls instead of squeezing or stretching the chart. A left/right legend uses `align-self: stretch` (resolves against the container's used height, so it works even when no ancestor sets an explicit `height`). The top/bottom `max-height: 40%` cap is a percentage, so it only resolves when the chart container has an **explicit** `height` — a flex-derived used size (e.g. `flex: 1` with only `min-height`/`max-height`) does **not** count and the cap silently no-ops; pin a real `height` on the container.
- `SlopeChart` config: `showSeriesLabels` (name beside each point; steepest line wins label collisions), `showStartLabels`/`showEndLabels` (defaults overridable per series via `meta.showStartLabel`/`showEndLabel`), `legend` (`{ show, position }`, rows carry the formatted change, ordered biggest-to-smallest by end value to match the lines' right-edge order), `valueFormatter`/`deltaFormatter`. The value axis is hidden by default — the start/end labels are the readout. The default tooltip orders its rows biggest-to-smallest by the hovered point's value (so many-breakdown tooltips match the lines' vertical order) and formats values with `valueFormatter` so they match the on-chart labels' units; pass your own `tooltip` to override. (`DefaultTooltip` itself takes an optional `valueFormatter` for the same reason — without it values fall back to `toLocaleString`.) Per-series `meta.incompleteEnd` dashes only the second half of that connector (the last point is the current incomplete period); the renderer splits the final segment at its midpoint via `stroke.partial.fromFraction`, so a two-point line needs no phantom interior point.
-- `FunnelChart` is a thin wrapper over grouped `BarChart` that owns the funnel look (hatched `track`, rounded + shadowed bars, percent value axis). `steps` is a `string[]` of display labels — duplicates are fine, bands are keyed by step index internally. Each `Series.data[stepIndex]` is the conversion from the first step as a percent (0–100); `funnelFromCounts` builds the single-series case from raw `{ label, count }` steps (zero basis yields 0, not NaN). `onStepClick` replaces `onPointClick` and reports `{ stepIndex, converted }` — `converted: false` means the hatched drop-off track above the bar was clicked. `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars (and hides the built-in step labels); use it for step legends richer than an axis label. Config: `hideStepLabels`, `hideValueAxis`, `barCornerRadius`, `bandPadding`, `maxBandRange` (cluster a 2–3 step funnel instead of stretching it), `chartMinHeight` (floor the plot region's px height when `stepFooter` is set, so a tall footer can't starve the `flex-1` canvas to zero height in a height-constrained column), plus the usual `tooltip`/`legend`/`margins`.
+- `FunnelChart` is a thin wrapper over grouped `BarChart` that owns the funnel look (hatched `track`, rounded + shadowed bars, percent value axis). `steps` is a `string[]` of display labels — duplicates are fine, bands are keyed by step index internally. Each `Series.data[stepIndex]` is the conversion from the first step as a percent (0–100); `funnelFromCounts` builds the single-series case from raw `{ label, count }` steps (zero basis yields 0, not NaN). `onStepClick` replaces `onPointClick` and reports `{ stepIndex, converted }` — `converted: false` means the hatched drop-off track above the bar was clicked. `stepFooter(stepIndex)` renders per-step content in a row below the plot, pixel-aligned under each step's bars (and hides the built-in step labels); use it for step legends richer than an axis label. Config: `hideStepLabels`, `hideValueAxis`, `barCornerRadius`, `bandPadding`, `minBarSize` (hover/click floor for near-zero bars, default `FUNNEL_MIN_BAR_SIZE` = 4px — the resting bar keeps its true size and grows to a clickable nub under the cursor via `minBarSizeScope: 'hover'`; pass 0 to disable), `maxBandRange` (cluster a 2–3 step funnel instead of stretching it), `chartMinHeight` (floor the plot region's px height when `stepFooter` is set, so a tall footer can't starve the `flex-1` canvas to zero height in a height-constrained column), plus the usual `tooltip`/`legend`/`margins`.
- `MetricCard` is a left-aligned tile. Pass `title={null}` to drop the title row — the header band collapses when there is no title and no change pill, and the subtitle row is omitted when there is no subtitle (and no `labels`), so a value-only card renders just the number. `changeSize="md"` renders a larger change pill (default `sm`); `changeInline` puts the pill beside the headline instead of in the header; `sparklineFill` makes the sparkline fill the card's remaining height instead of a fixed `sparklineHeight`; `sparklineDashedFromIndex` dashes the sparkline from that index onward (e.g. an in-progress trailing period). `subtitle` always wins (shown at rest and on hover); `restingSubtitle` (e.g. `'Avg'`) shows only at rest and yields to the hovered point's label on hover — pair it with a `value` that summarizes the series (average/total) so the headline reads as a summary until hovered. `hoverChangeFromPreviousPoint` keeps the supplied resting `change` pill at rest but, while hovering, swaps it for the hovered point's change vs the previous point (hidden at the first point). `changeTooltip` shows a styled hover tooltip (floating-ui, using the host's tooltip surface tokens with chart-surface fallbacks) on the change pill (e.g. to spell out what the resting comparison is).
- The composable form of `MetricCard` lives one layer up as `Metric` in `@posthog/quill-components` (it needs `Card`/`Badge` from primitives, which charts can't depend on). It's built on `Sparkline` plus the headless metric helpers this package exports — `resolveDelta` / `computeFallbackChangePercent` (delta math), `useAnimatedNumber` (count-up headline), `useHoverIntent` (hover dwell) — and the `MetricChange` / `ResolvedDelta` types. Reach for `Metric` when you need a custom layout; use the monolithic `MetricCard` here for the default self-contained tile.
- `TimeSeriesComboChart` wraps `ComboChart` the way `TimeSeriesLineChart`/`TimeSeriesBarChart` wrap their base charts: `config.xAxis`/`config.yAxis` (date tick formatter, y-format, scale, grid), `config.goalLines` (off-scale targets stretch the value axis via `ComboChart`'s `valueDomain`), `config.legend` (click-to-toggle), and `config.valueLabels`. Per-series `type` (`'bar' | 'line' | 'area'`) drives rendering; `barLayout` (`'stacked' | 'grouped' | 'percent'`), `divergingStack` (stacked only — negative bar values stack below the zero baseline instead of being clamped to 0, same semantics as `BarsConfig.divergingStack`), and right-axis series (`yAxisId: 'right'`) carry over from `ComboChart`. `ComboChart` itself now also honors `valueDomain` (primary axis only) and `showAxisLines`.
diff --git a/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx b/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx
index d111cebe764d..f1ca998c660c 100644
--- a/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx
+++ b/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx
@@ -100,6 +100,7 @@ function BarChartInner<Meta = unknown>({
bandPadding,
minBandSize,
minBarSize,
+ minBarSizeScope = 'always',
fitToHeight = false,
valueDomain,
valuePadding,
@@ -289,6 +290,7 @@ function BarChartInner<Meta = unknown>({
barTrack,
barShadow,
barFillStyle,
+ minBarSizeScope,
}),
[
showGrid,
@@ -303,6 +305,7 @@ function BarChartInner<Meta = unknown>({
xTickFormatter,
barShadow,
barFillStyle,
+ minBarSizeScope,
]
)
diff --git a/packages/quill/packages/charts/src/charts/BarChart/BarTooltip.tsx b/packages/quill/packages/charts/src/charts/BarChart/BarTooltip.tsx
index 099b4cf13302..9d5ec5fa5ff0 100644
--- a/packages/quill/packages/charts/src/charts/BarChart/BarTooltip.tsx
+++ b/packages/quill/packages/charts/src/charts/BarChart/BarTooltip.tsx
@@ -76,7 +76,7 @@ function narrowSeriesByCursor<Meta>(
return ctx
}
const seriesList = ctx.seriesData.map((entry) => entry.series)
- const { hits } = resolveBarsAtCursor({
+ const { hits, strictHit } = resolveBarsAtCursor({
series: seriesList,
label: ctx.label,
dataIndex: ctx.dataIndex,
@@ -90,6 +90,8 @@ function narrowSeriesByCursor<Meta>(
if (hits.size === 0) {
return null
}
+ // Same rects as click routing, so the tooltip and a click classify a position identically.
+ const inTrackArea = layout === 'grouped' ? strictHit == null : undefined
let visibleKey: string | null = null
let visibleDataIndex: number | null = null
if (isStackedLayout(layout)) {
@@ -129,7 +131,7 @@ function narrowSeriesByCursor<Meta>(
const value = typeof raw === 'number' && Number.isFinite(raw) ? raw : entry.value
return { ...entry, value }
})
- return { ...ctx, seriesData: revalued, dataIndex: di, hoveredSeriesKey }
+ return { ...ctx, seriesData: revalued, dataIndex: di, hoveredSeriesKey, inTrackArea }
}
- return { ...ctx, seriesData: filtered, hoveredSeriesKey }
+ return { ...ctx, seriesData: filtered, hoveredSeriesKey, inTrackArea }
}
diff --git a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts
index d26c836ec5e9..c0275d2edf32 100644
--- a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts
+++ b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts
@@ -90,6 +90,7 @@ export interface DrawBarChartStaticArgs {
barTrack: boolean
barShadow: BarsConfig['shadow']
barFillStyle: BarFillStyle
+ minBarSizeScope?: BarsConfig['minBarSizeScope']
}
/** The full static pass: grid, bars, optional tracks, optional drop shadow and rounded stack
@@ -110,12 +111,15 @@ export function drawBarChartStatic(
barTrack,
barShadow,
barFillStyle,
+ minBarSizeScope,
}: DrawBarChartStaticArgs
): void {
- const d3Scales = (scales._private as BarChartPrivate | undefined)?.__barChart
- if (!d3Scales) {
+ const rawScales = (scales._private as BarChartPrivate | undefined)?.__barChart
+ if (!rawScales) {
return
}
+ // With 'hover' scope the static layer draws true sizes; hover and hit-testing keep the floor.
+ const d3Scales = minBarSizeScope === 'hover' ? { ...rawScales, minBarSize: undefined } : rawScales
const baseDrawCtx: DrawContext = {
ctx,
@@ -238,8 +242,10 @@ export function drawBarHoverItems(
if (hoveredBandPills.length > 0) {
clipToRoundedRects(ctx, hoveredBandPills, barCornerRadius)
}
- for (const { series: s, bar, isTrackHighlight } of items) {
- if (isTrackHighlight) {
+ for (const { series: s, bar, isTrackHighlight, isBarReveal } of items) {
+ if (isBarReveal) {
+ drawBarHighlight(ctx, bar, barColorAt(s, bar.dataIndex), highlightRadius)
+ } else if (isTrackHighlight) {
const parsed = d3Color(barColorAt(s, bar.dataIndex))
// Always translucent — the bar color direct would paint an opaque full-height
// block if d3 can't parse the color.
diff --git a/packages/quill/packages/charts/src/charts/BarChart/utils/resolve-bar-hover.ts b/packages/quill/packages/charts/src/charts/BarChart/utils/resolve-bar-hover.ts
index 1dd8e57f90ec..577f158df0d6 100644
--- a/packages/quill/packages/charts/src/charts/BarChart/utils/resolve-bar-hover.ts
+++ b/packages/quill/packages/charts/src/charts/BarChart/utils/resolve-bar-hover.ts
@@ -16,6 +16,8 @@ export interface BarHoverItem {
series: ResolvedSeries
bar: BarRect
isTrackHighlight: boolean
+ /** Draw in the plain series color, to reveal a floored bar that is invisible at rest. */
+ isBarReveal?: boolean
}
export interface ResolvedBarHover {
@@ -98,6 +100,11 @@ export function resolveBarHoverItems(
!cursorBeyondTrackCeiling(s, bar, d3Scales, hoverPosition, isHorizontal)
items.push({ series: s, bar, isTrackHighlight })
composition += isTrackHighlight ? 't' : 'b'
+ // Reveal a floored bar that is invisible at rest; a no-op repaint for taller bars.
+ const extent = isHorizontal ? bar.width : bar.height
+ if (isTrackHighlight && d3Scales.minBarSize != null && extent <= d3Scales.minBarSize) {
+ items.push({ series: s, bar, isTrackHighlight: false, isBarReveal: true })
+ }
}
}
if (items.length === 0) {
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
index f4203d4f7090..0431b0ef5f1e 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
@@ -84,6 +84,35 @@ describe('FunnelChart', () => {
expect(click.converted).toBe(converted)
})
+ it('floors a near-zero bar for interaction: track above, converted tooltip and click near the baseline', async () => {
+ // Without the floor a 0.1% bar is sub-pixel and the whole column classifies as drop-off.
+ const onStepClick = jest.fn()
+ const { chart } = renderHogChart(
+ <FunnelChart
+ steps={STEPS}
+ series={[{ key: 'all', label: 'All', data: [100, 0.1] }]}
+ theme={THEME}
+ onStepClick={onStepClick}
+ />
+ )
+ const step = dimensions.plotWidth / STEPS.length
+ const clientX = dimensions.plotLeft + step * 1.5
+ const baselineY = dimensions.plotTop + dimensions.plotHeight
+
+ await waitFor(async () => {
+ fireEvent.mouseMove(chart.element, { clientX, clientY: dimensions.plotTop + 2 })
+ expect((await chart.waitForTooltip(100)).inTrackArea).toBe(true)
+ })
+ await waitFor(async () => {
+ fireEvent.mouseMove(chart.element, { clientX, clientY: baselineY - 2 })
+ expect((await chart.waitForTooltip(100)).inTrackArea).toBe(false)
+ })
+ fireEvent.click(chart.element)
+ const click: FunnelStepClickData = onStepClick.mock.calls[0][0]
+ expect(click.stepIndex).toBe(1)
+ expect(click.converted).toBe(true)
+ })
+
it('renders one step-footer cell per step and hides the axis step labels', async () => {
const { chart } = renderHogChart(
<FunnelChart
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
index b58e6f6164b7..c811c7b15d37 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.tsx
@@ -17,6 +17,9 @@ import { BarChart } from '../BarChart/BarChart'
/** Inner gap between variant bars as a fraction of a step's band slot. */
export const FUNNEL_BAND_PADDING = 0.1
+/** Default min px hover/click extent of a non-zero bar; the resting bar keeps its true size. */
+export const FUNNEL_MIN_BAR_SIZE = 4
+
const FUNNEL_BAR_SHADOW: BarsConfig['shadow'] = { color: 'rgba(0,0,0,0.15)', blur: 6, offsetY: -2 }
const DEFAULT_CORNER_RADIUS = 10
@@ -41,6 +44,8 @@ export interface FunnelChartConfig {
maxCategoryLabelWidth?: number
/** Inner gap between variant bars as a fraction of the band slot. Defaults to {@link FUNNEL_BAND_PADDING}. */
bandPadding?: number
+ /** Min px hover/click extent of a non-zero bar. Defaults to {@link FUNNEL_MIN_BAR_SIZE}; 0 disables. */
+ minBarSize?: number
/** Cap (px) on the band-axis range — clusters steps at the start of the plot instead of
* stretching a 2–3 step funnel across the full width. */
maxBandRange?: number
@@ -174,6 +179,7 @@ export function FunnelChart<Meta = unknown>({
hideValueAxis,
maxCategoryLabelWidth,
bandPadding,
+ minBarSize,
maxBandRange,
chartMinHeight,
} = config ?? {}
@@ -207,6 +213,8 @@ export function FunnelChart<Meta = unknown>({
track: true,
shadow: FUNNEL_BAR_SHADOW,
bandPadding: bandPadding ?? FUNNEL_BAND_PADDING,
+ minBarSize: minBarSize ?? FUNNEL_MIN_BAR_SIZE,
+ minBarSizeScope: 'hover',
maxBandRange,
},
}),
diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.ts
index 43e57e8fe4f5..b7abe1fb4d37 100644
--- a/packages/quill/packages/charts/src/core/types.ts
+++ b/packages/quill/packages/charts/src/core/types.ts
@@ -186,6 +186,9 @@ export interface TooltipContext<Meta = unknown> {
* false` (e.g. a drop-off filler segment), so callers must not assume a matching
* `seriesData` entry exists. */
hoveredSeriesKey?: string
+ /** Grouped layouts only: cursor is past the bar's filled extent, measured on the same rects
+ * as click routing. `undefined` for other layouts and pinned rebuilds with no cursor. */
+ inTrackArea?: boolean
/** Pixel position (relative to the chart container) for anchoring the tooltip.
* `width` (optional) is the horizontal data-extent centered on `x` — bar charts
* populate it with the band width so {@link Tooltip} can anchor at the band edge
@@ -457,6 +460,9 @@ export interface BarsConfig {
* that segment. So a multi-series (breakdown) stack floors only its top segment — this is aimed
* at single-series volume charts and grouped bars. Defaults to 0 (exact heights). */
minBarSize?: number
+ /** `hover` floors only the hover highlight and hit-testing, so the resting bar keeps its true
+ * size (funnel charts). `always` (default) floors the static layer too. */
+ minBarSizeScope?: 'always' | 'hover'
/** Horizontal bar charts only — minimum px per row. When many rows would otherwise crush into
* an unreadable strip, the chart expands its container height so each row has at least this
* much vertical space (label height + breathing room). Defaults to `24`. Pass `0` to opt out. */
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx
index 06bc92f4468c..20569e6063f9 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx
@@ -41,9 +41,8 @@ export function FunnelStepsBarTooltip({
? funnelComparePeriodDateRange(series.compare_label, resolvedDateRange, compareTo)
: null
- // Vertical bar chart: cursor above the bar's top pixel is in the track (drop-off) region.
- const isDropOffHover =
- stepIndex > 0 && context.hoverPosition != null && entry.yPixel != null && context.hoverPosition.y < entry.yPixel
+ // Shares the chart's hit-test rects, so the drop-off framing matches what a click opens.
+ const isDropOffHover = stepIndex > 0 && context.inTrackArea === true
const sharedProps = {
showPersonsModal,