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(insights): show the weekday in quill chart tooltip headers (#68896)

Sam Pennington42b30f49d7d3
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 373dafda6c0a..47a39c1af1da 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -69,7 +69,7 @@ Charts fill their container and need a parent with real dimensions — a `0`-hei
```
- Overlays (`ReferenceLine`/`ReferenceLines`, `ValueLabels`, `AxisTitles`, `TrendLineOverlay`) compose as children.
-- `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 ("Jun 6, 2026", "Jun 6, 14:00"), 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) 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.
+- `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) 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.
- 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).
- `ReferenceLine` variants: `goal` (dashed grey), `alert` (dashed red), `marker` (solid thin).
diff --git a/packages/quill/packages/charts/src/utils/dates.test.ts b/packages/quill/packages/charts/src/utils/dates.test.ts
index 2011efba0151..52b10719cccf 100644
--- a/packages/quill/packages/charts/src/utils/dates.test.ts
+++ b/packages/quill/packages/charts/src/utils/dates.test.ts
@@ -1,4 +1,4 @@
-import { createXAxisTickCallback } from './dates'
+import { createTooltipDateFormatter, createXAxisTickCallback } from './dates'
function weeklyDates(start: string, count: number): string[] {
const dates: string[] = []
@@ -282,3 +282,29 @@ describe('createXAxisTickCallback', () => {
})
})
})
+
+describe('createTooltipDateFormatter', () => {
+ it.each([
+ { interval: 'second' as const, label: '2026-06-06 14:30:05', expected: 'Sat, Jun 6, 14:30:05' },
+ { interval: 'minute' as const, label: '2026-06-06 14:30:00', expected: 'Sat, Jun 6, 14:30' },
+ { interval: 'hour' as const, label: '2026-06-06 14:00:00', expected: 'Sat, Jun 6, 14:00' },
+ { interval: 'day' as const, label: '2026-06-06', expected: 'Sat, Jun 6, 2026' },
+ // Week/month buckets span multiple days, so a weekday would mislead
+ { interval: 'week' as const, label: '2026-06-01', expected: 'Jun 1, 2026' },
+ { interval: 'month' as const, label: '2026-06-01', expected: 'Jun 2026' },
+ ])('formats a $interval bucket header', ({ interval, label, expected }) => {
+ const format = createTooltipDateFormatter({ interval, timezone: 'UTC' })
+ expect(format(label)).toBe(expected)
+ })
+
+ it('resolves the weekday in the given timezone, not the browser one', () => {
+ // 2026-06-07T02:00 UTC is still Saturday June 6 in US/Pacific
+ const format = createTooltipDateFormatter({ interval: 'hour', timezone: 'US/Pacific' })
+ expect(format('2026-06-07T02:00:00Z')).toBe('Sat, Jun 6, 19:00')
+ })
+
+ it('passes non-date labels through unchanged', () => {
+ const format = createTooltipDateFormatter({ interval: 'day', timezone: 'UTC' })
+ expect(format('not-a-date')).toBe('not-a-date')
+ })
+})
diff --git a/packages/quill/packages/charts/src/utils/dates.ts b/packages/quill/packages/charts/src/utils/dates.ts
index 0684c4f84d40..57fd1e51e129 100644
--- a/packages/quill/packages/charts/src/utils/dates.ts
+++ b/packages/quill/packages/charts/src/utils/dates.ts
@@ -54,8 +54,9 @@ export function createXAxisTickCallback({
export const parseDateForAxis = parseDateInTimezone
/** Full date label for a tooltip header. Unlike the sparse, abbreviated axis ticks, every point
- * gets a complete, unambiguous label ("Jun 6, 2026", "Jun 6, 14:00"). Non-date labels pass
- * through unchanged. */
+ * gets a complete, unambiguous label, with the weekday when the bucket names a single day
+ * ("Sat, Jun 6, 2026", "Sat, Jun 6, 14:00" — but week/month buckets span days, so no weekday).
+ * Non-date labels pass through unchanged. */
export function createTooltipDateFormatter({
interval,
timezone,
@@ -70,14 +71,17 @@ export function createTooltipDateFormatter({
}
switch (interval) {
case 'second':
- return date.format('MMM D, HH:mm:ss')
+ return date.format('ddd, MMM D, HH:mm:ss')
case 'minute':
case 'hour':
- return date.format('MMM D, HH:mm')
+ return date.format('ddd, MMM D, HH:mm')
case 'month':
return date.format('MMM YYYY')
- default:
+ case 'week':
return date.format('MMM D, YYYY')
+ case 'day':
+ default:
+ return date.format('ddd, MMM D, YYYY')
}
}
}
diff --git a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
index 1c673d217c3d..4e2957a3e432 100644
--- a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
+++ b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
@@ -3,6 +3,7 @@ import { useCallback, useMemo } from 'react'
import { DefaultTooltip, type TooltipContext } from '@posthog/quill-charts'
+import { parseDateInTimezone } from 'lib/utils/datetime'
import { percentage } from 'lib/utils/numbers'
import { formatAggregationAxisValue } from 'scenes/insights/aggregationAxisFormat'
import {
@@ -254,7 +255,14 @@ export function InsightSeriesTooltip<Meta extends InsightSeriesMetaBase>({
const labelFormatter = useCallback((): React.ReactNode => {
const firstKey = context.seriesData[0]?.series.key
const date = firstKey ? datumByKey.get(firstKey)?.date_label : undefined
- const formattedDate = getFormattedDate(date, { interval, dateRange, timezone, weekStartDay })
+ let formattedDate = getFormattedDate(date, { interval, dateRange, timezone, weekStartDay })
+ // Match the classic insight tooltip, which spells out the weekday on daily buckets
+ if (interval === 'day' && typeof date === 'string') {
+ const parsed = parseDateInTimezone(date, timezone)
+ if (parsed.isValid()) {
+ formattedDate = `${parsed.format('dddd')}, ${formattedDate}`
+ }
+ }
if (altTitle) {
return getTooltipTitle([...datumByKey.values()], altTitle, formattedDate) ?? formattedDate
}
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
index 0168a57fdbb0..2c6ddb4573e6 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
@@ -40,6 +40,8 @@ afterEach(() => {
cleanupRaf()
cleanupJsdom()
cleanup()
+ // featureFlagLogic persists flags to localStorage, so per-test flags leak into later tests otherwise
+ localStorage.clear()
})
describe('TrendsLineChart', () => {
@@ -288,6 +290,18 @@ describe('TrendsLineChart', () => {
expect(tooltip.title()).toMatch(/Wednesday/i)
expect(tooltip.title()).toMatch(/12.+Jun/)
})
+
+ it('keeps the weekday in the quill tooltip (PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS on)', async () => {
+ renderInsight({
+ query: buildTrendsQuery({ interval: 'day' }),
+ featureFlags: { [FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]: true },
+ })
+
+ const tooltip = await chart.hoverTooltip(2)
+
+ expect(tooltip.title()).toMatch(/Wednesday/i)
+ expect(tooltip.title()).toMatch(/12.+Jun/)
+ })
})
describe('alert overlays', () => {