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(mcp-analytics): adopt the insights refreshed chart config (#68403)

Sam Pennington627a121d4e10
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index aa425709864c..e302630fd7a0 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6173,13 +6173,13 @@ snapshots:
scenes-app-marketing-analytics-cell-actions--source-cell-action-unmapped--light:
hash: v1.k794b7964.c15b997111d34fb17ad2dd192b97c01d0a7ab3a320c5edf9a3e20b0b63a4ff9b.UHxcXJdZkFGXRnzIMFWO99QMD_gZm0V47g8f1j4OFS0
scenes-app-mcp-analytics--dashboard--dark:
- hash: v1.k794b7964.5c68a5b1960c19bde11204b144353e5a655322d258d05273505c35cbb7e255dc.PcnSu5cRQDDanvMnxMUOUsJkBSDHUjgPIGW_f-rOPYU
+ hash: v1.k794b7964.2bc3b8604eace680bbd8e1fa657a8439e1804259a14e4355388f199a6bfa4a16.eLY6IqLrMHWmwR0wamegLkJJqdRPoMUKCxFcUu0V4N4
scenes-app-mcp-analytics--dashboard--light:
- hash: v1.k794b7964.f4acf23317352214813d98ee488b9d1eaaaf86321fa81e4b999b0df10d528e55.4F7cFSFc-wE2ns4rWSaEQY_aiUJn877CTJe7LiGlX40
+ hash: v1.k794b7964.1fb4c7301efba42a966bf89e68e2ad85bbd433944272285552f22566e626b13b.cPkh_QqqLBg3MCavtqoMogCSumls7GI1SxwmjoeLQMg
scenes-app-mcp-analytics--dashboard-with-menu-bar--dark:
- hash: v1.k794b7964.20d53706369819a7b2c0362e19d0b2294f97b5eed1028fea44df50ae9872fc54.yNsqojVK97Tn9tBxdYCT3JlcjkDB4xkrJhY7EOfG4xc
+ hash: v1.k794b7964.e2c33e0d83a374dcb482a4f87ab282b6970f07b6a2f02d3b401c949d809655a2.pxgapCvTjPi-25Dyd4Jy72NRuWPIjPO_-8Gi6Mxp_zY
scenes-app-mcp-analytics--dashboard-with-menu-bar--light:
- hash: v1.k794b7964.6a9e36cf76325c2ee350e1d864e672490c3828a0aa8369ca1c2cafe1c71e5e44.O44QEYI6oU9EjrnYQ2YB6-NtfvT4NhEO2lr1CR8cmng
+ hash: v1.k794b7964.36ff58ccd3dfdbb5dcf9d4629c4d2f68ab9c2b8fb1ac42d190eaa328d8006df7.N8A44kWdcSNbtQ6AqRwi3fnIEQyGJ1bvVIqzDFi7MG0
scenes-app-mcp-analytics--intent-clustering--dark:
hash: v1.k794b7964.93cb428637db03234a4d0d09b51ef886d95ab801bb3e4dc6ca0f1ba3824b9fe3.JeUzojRsSPumu87KUEx7WXtojxL5GEF98Ps9CVS7WAY
scenes-app-mcp-analytics--intent-clustering--light:
@@ -6193,17 +6193,17 @@ snapshots:
scenes-app-mcp-analytics--tool-quality--light:
hash: v1.k794b7964.ad0afc1d54e6b1e1636b111f6b5441963db055864379e1546baa8044638441c1.d5yYULnG731hp03Bh0veJtL14UcVQ27Nwz448eTDDiM
scenes-app-mcp-analytics-dashboard-cards--daily-calls-and-errors--dark:
- hash: v1.k794b7964.e6bb5eaa07d058876ea4f4392c05ba340975ceccb055192425c70951eda0a8b3.QMIT8C8Ps-GWGUEHddKcvI27S-hJ7UktYxi3IrXUoQg
+ hash: v1.k794b7964.35efe2b95dcc1178dbeacef9e088b2d82a991f7f398f2c2ac0b11fdcbdda56e1.88qh1qEnSCr1jhBQjH1AiVgMO2AoTL8jPvr1hB8SK24
scenes-app-mcp-analytics-dashboard-cards--daily-calls-and-errors--light:
- hash: v1.k794b7964.418bc0bc01aeeb279a24a06c9440b9a32cdbd2607ad219d4c79b1a14886f60ca.CGsxnk9VIuyAr5sCUgELqLhK5KvvkoRO_LMj87x9MAQ
+ hash: v1.k794b7964.b7cefef587ac176989ee8149b0b7ffde267afaa091782ce69eca4ec29d836a69.LWDccp1mvN_WM7uEYPRMQQEbVfZOsyuMV14t35QXkz4
scenes-app-mcp-analytics-dashboard-cards--daily-tool-breakdown--dark:
- hash: v1.k794b7964.ff82e0013ec801720aaca66d9fca12bf0338d59af66869e13595f503b57d46e1.2pFhma4vKlmr6IBNzQPQoQOKSXtZael8995lkD3e5b0
+ hash: v1.k794b7964.accfc0a38802ff4dd38b7d92143b5bd3ca3e7b746a05efcfa31980810a6fe1f1.krPWvAaNVmgG9TLam2-YDPGIJtCMCXtQO3kk4Y5qPM4
scenes-app-mcp-analytics-dashboard-cards--daily-tool-breakdown--light:
- hash: v1.k794b7964.54bf4834b5b52cf310fd43f92a02768b9c0daa2f6c399950bf9e65c672ca4125.OS9cYWLdVXofXqq_4D9vsBAgpTbvHYwBOtXZSJ97w5w
+ hash: v1.k794b7964.b29c625e26dc98e608da63cc67d2680377f529e61bf9611abbbbb15950464f70.U2IBSDBcthc5QDQPZ9ORasAZvzVYIaSK4KZ2fEjFgzo
scenes-app-mcp-analytics-dashboard-cards--error-rate-by-tool--dark:
- hash: v1.k794b7964.ac9ea8a2664417065b6125988464feaf10d0d236362d7fde9d584aab4b1224c1.3d2LwZwRwJ012OgGUBuiSoJNcjDjTYhUux060JphQb4
+ hash: v1.k794b7964.8cd2e55bd24c18accd1ce65fd208a33a25ccf2a9af44d6d45d6f5b76fdd0385a.-TZTBA_Vo39aO8TLxLZshmywBRW87uKuZ77zytEiX-k
scenes-app-mcp-analytics-dashboard-cards--error-rate-by-tool--light:
- hash: v1.k794b7964.1319dfba1ed2959824eafc017d608fdd74c9daee62e5a6f3612a6e9ce8bcfb44.NgrffesRBsvcpGagN7DWEx5sxJNcHmYlU3h6THEdg5w
+ hash: v1.k794b7964.fb19ba2710284a3445ca8b3fd35276da7ed57ca13d22470ae362e1a7789bc032.BN2AkhljnBC-tp086Cjl4KxQATZ2wivmeSPAthlLtoQ
scenes-app-mcp-analytics-dashboard-cards--flagged-sessions--dark:
hash: v1.k794b7964.d97cedf2d117fe2e285f939cc13ce5fdf683ed7de4e18a3c4eb9f28fff983a34.CfkZnIjZc2LqUixiNp67M-oYSgm9RZo5S_j710llXos
scenes-app-mcp-analytics-dashboard-cards--flagged-sessions--light:
diff --git a/frontend/src/lib/charts/hooks.ts b/frontend/src/lib/charts/hooks.ts
index 306c22280bb7..3581343f48c4 100644
--- a/frontend/src/lib/charts/hooks.ts
+++ b/frontend/src/lib/charts/hooks.ts
@@ -10,15 +10,12 @@ import { themeLogic } from '~/layout/navigation-3000/themeLogic'
import { buildTheme } from './utils/theme'
-/** Rendering options the refreshed style turns on. Applied as config *defaults* — a chart's own
- * config always wins. All four are stable quill-charts config keys, so removing the flag later
- * means inlining these at the call sites (or flipping the library defaults), not deleting an API. */
const REFRESHED_CONFIG_DEFAULTS = {
curve: 'monotone',
showAxisLines: true,
showTickMarks: true,
showCrosshair: true,
- // Stacked bars round only the outermost segment, so this reads as "curved bar tops".
+ showGrid: true,
barCornerRadius: 4,
} as const
@@ -27,8 +24,6 @@ function refreshedThemeOverrides(isDarkModeOn: boolean): Partial<ChartTheme> {
gridColor: isDarkModeOn ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.06)',
gridDashPattern: [3, 3],
axisLineColor: isDarkModeOn ? 'rgba(255,255,255,0.35)' : 'rgba(0,0,0,0.35)',
- // Dashed like the grid so the hover guide reads as a temporary sibling of the grid
- // lines, slightly stronger than them so it stays findable.
crosshairColor: isDarkModeOn ? 'rgba(255,255,255,0.25)' : 'rgba(0,0,0,0.2)',
crosshairDashPattern: [3, 3],
}
@@ -55,7 +50,7 @@ export function useChartTheme(overrides?: Partial<ChartTheme>): ChartTheme {
/** Drop-in replacement for the `useMemo` that builds a chart's config object. On top of memoizing,
* it applies app-level rendering defaults — currently the refreshed style (monotone curve, axis
- * lines, tick marks, crosshair) behind `QUILL_CHART_STYLE_REFRESH`. Keys the config sets
+ * lines, tick marks, crosshair, grid) behind `QUILL_CHART_STYLE_REFRESH`. Keys the config sets
* explicitly (non-undefined) always win over the defaults. */
export function useChartConfig<T extends object>(factory: () => T, deps: DependencyList): T
export function useChartConfig<T extends object>(factory: () => T | undefined, deps: DependencyList): T | undefined
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 8d9d0655cbf2..360d97519a7f 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -30,7 +30,7 @@ const theme = useChartTheme() // reads CSS vars, tracks light/dark switches
- Series colors come from `--data-color-1..15` (ordered categorical palette from `@posthog/quill-tokens`); chrome from `--color-graph-axis-label` / `--color-graph-axis-line` / `--color-graph-crosshair`.
- `themeFromCssVars()` is the one-shot non-hook version; `DEFAULT_CHART_COLORS` is the no-DOM fallback (kept in sync with tokens by a CI-enforced test).
- Omit `color` on a series to get palette assignment by index — preferred. Explicit `color` accepts hex or `var(--...)`.
-- Restyle knobs, all optional and off by default so themes/hosts opt in: `theme.axisLineColor` strokes the L-axis baselines and tick marks without changing tick-label text color (falls back `axisColor` → `gridColor`); `theme.gridDashPattern` / `theme.crosshairDashPattern` (e.g. `[3, 3]`) dash the interior grid lines / hover crosshair (plot-edge frame strokes stay solid). Config side: `showAxisLines` draws the L-axis (alongside the grid; the grid then skips its own frame and category lines), `showTickMarks` draws short canvas tick marks snapped to the same pixel grid as the axis, and `curve: 'monotone'` smooths line/area series through every point without overshoot. With axis lines on, line strokes are trimmed at the y-axis and floored onto the x-axis so they rest against the axis instead of straddling it.
+- Restyle knobs, all optional and off by default so themes/hosts opt in: `theme.axisLineColor` strokes the L-axis baselines and tick marks without changing tick-label text color (falls back `axisColor` → `gridColor`); `theme.gridDashPattern` / `theme.crosshairDashPattern` (e.g. `[3, 3]`) dash the interior grid lines / hover crosshair (plot-edge frame strokes stay solid). Config side: `showGrid` draws the grid lines — a top-level key on every chart, including the time-series wrappers; grid lines are always aligned to the primary (left) y-axis ticks, and a `showGrid` set on the primary `yAxis` config wins (on secondary axes it is ignored — two grids with unaligned ticks would just be noise); `showAxisLines` draws the L-axis (alongside the grid; the grid then skips its own frame and category lines), `showTickMarks` draws short canvas tick marks snapped to the same pixel grid as the axis, and `curve: 'monotone'` smooths line/area series through every point without overshoot. With axis lines on, line strokes are trimmed at the y-axis and floored onto the x-axis so they rest against the axis instead of straddling it.
- `theme.skipDraw` suppresses all canvas painting (static layer + hover overlay) while still mounting the `<canvas>` element. Use it for deterministic visual-snapshot tests where the async paint pipeline (ResizeObserver → requestAnimationFrame) races the screenshot — the chart renders blank but layout and DOM selectors are unaffected.
## Series shape (all multi-series charts)
@@ -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"). `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 ("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.
- 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/charts/TimeSeriesBarChart/TimeSeriesBarChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.tsx
index d61d239c6ffc..3e10e295b645 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.tsx
@@ -15,7 +15,7 @@ import { ReferenceLines } from '../../overlays/ReferenceLine'
import { TrendLineOverlay } from '../../overlays/TrendLineOverlay'
import { ValueLabels } from '../../overlays/ValueLabels'
import type { GoalLineConfig } from '../../utils/goal-lines'
-import type { XAxisConfig, YAxisConfig } from '../../utils/use-axis-formatters'
+import { useTimeSeriesTooltipConfig, type XAxisConfig, type YAxisConfig } from '../../utils/use-axis-formatters'
import { BarChart } from '../BarChart/BarChart'
import { useTrendLineSeries, type TrendLineConfig } from '../utils/use-derived-series'
import { useGoalLines, useTimeSeries } from '../utils/use-time-series'
@@ -35,6 +35,9 @@ export interface TimeSeriesBarChartConfig {
barCornerRadius?: number
/** Show a vertical crosshair line that follows the cursor. */
showCrosshair?: boolean
+ /** Horizontal grid lines, aligned to the primary y-axis ticks. `showGrid` on the primary
+ * `yAxis` config, when set, wins. */
+ showGrid?: boolean
/** Draw L-shaped axis baselines without grid lines (ignored when `yAxis.showGrid` is true). */
showAxisLines?: boolean
/** Draw short tick marks next to each visible axis label. Pairs with `showAxisLines`. */
@@ -87,6 +90,7 @@ export function TimeSeriesBarChart<Meta = unknown>({
axisOrientation,
barCornerRadius,
showCrosshair,
+ showGrid,
showAxisLines,
showTickMarks,
tooltip: tooltipConfig,
@@ -107,6 +111,7 @@ export function TimeSeriesBarChart<Meta = unknown>({
primaryYAxis,
yAxes,
} = useTimeSeries(series, labels, theme, { xAxis, yAxis, valueLabels, legend })
+ const timeSeriesTooltipConfig = useTimeSeriesTooltipConfig(tooltipConfig, xAxis)
// `axisOrientation` flows through `barChartConfig` into chart context, so `ReferenceLine`
// reads it automatically — no need to stamp each line here.
@@ -122,13 +127,13 @@ export function TimeSeriesBarChart<Meta = unknown>({
hideYAxis: primaryYAxis?.hide,
xAxisLabel: xAxis?.label,
yAxisLabel: primaryYAxis?.label,
- showGrid: primaryYAxis?.showGrid,
+ showGrid: primaryYAxis?.showGrid ?? showGrid,
showAxisLines,
showTickMarks,
barLayout,
axisOrientation,
showCrosshair,
- tooltip: tooltipConfig,
+ tooltip: timeSeriesTooltipConfig,
animateHover,
yAxes,
bars: {
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
index 70df1327b971..ba567ad59333 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.tsx
@@ -15,7 +15,7 @@ import { ReferenceLines } from '../../overlays/ReferenceLine'
import { TrendLineOverlay } from '../../overlays/TrendLineOverlay'
import { ValueLabels } from '../../overlays/ValueLabels'
import type { GoalLineConfig } from '../../utils/goal-lines'
-import type { XAxisConfig, YAxisConfig } from '../../utils/use-axis-formatters'
+import { useTimeSeriesTooltipConfig, type XAxisConfig, type YAxisConfig } from '../../utils/use-axis-formatters'
import { ComboChart } from '../ComboChart/ComboChart'
import { useTrendLineSeries, type TrendLineConfig } from '../utils/use-derived-series'
import { useGoalLines, useTimeSeries } from '../utils/use-time-series'
@@ -36,6 +36,9 @@ export interface TimeSeriesComboChartConfig {
barCornerRadius?: number
/** Show a vertical crosshair line that follows the cursor. */
showCrosshair?: boolean
+ /** Horizontal grid lines, aligned to the primary y-axis ticks. `showGrid` on the primary
+ * `yAxis` config, when set, wins. */
+ showGrid?: boolean
/** Draw L-shaped axis baselines without grid lines (ignored when `yAxis.showGrid` is true). */
showAxisLines?: boolean
/** Draw short tick marks next to each visible axis label. Pairs with `showAxisLines`. */
@@ -87,6 +90,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
barLayout,
barCornerRadius,
showCrosshair,
+ showGrid,
showAxisLines,
showTickMarks,
curve,
@@ -105,6 +109,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
primaryYAxis,
yAxes,
} = useTimeSeries(series, labels, theme, { xAxis, yAxis, valueLabels, legend })
+ const timeSeriesTooltipConfig = useTimeSeriesTooltipConfig(tooltipConfig, xAxis)
const { referenceLines, valueDomain } = useGoalLines(goalLines, chartSeries)
@@ -118,7 +123,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
hideYAxis: primaryYAxis?.hide,
xAxisLabel: xAxis?.label,
yAxisLabel: primaryYAxis?.label,
- showGrid: primaryYAxis?.showGrid,
+ showGrid: primaryYAxis?.showGrid ?? showGrid,
showAxisLines,
showTickMarks,
curve,
@@ -126,7 +131,7 @@ export function TimeSeriesComboChart<Meta = unknown>({
defaultSeriesType,
barLayout,
barCornerRadius,
- tooltip: tooltipConfig,
+ tooltip: timeSeriesTooltipConfig,
valueDomain,
yAxes,
}
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
index c8ef8d170fc0..bea901d413cd 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
@@ -14,7 +14,7 @@ import type {
import { ReferenceLines } from '../../overlays/ReferenceLine'
import { ValueLabels } from '../../overlays/ValueLabels'
import type { GoalLineConfig } from '../../utils/goal-lines'
-import type { XAxisConfig, YAxisConfig } from '../../utils/use-axis-formatters'
+import { useTimeSeriesTooltipConfig, type XAxisConfig, type YAxisConfig } from '../../utils/use-axis-formatters'
import { LineChart } from '../LineChart/LineChart'
import {
useDerivedSeries,
@@ -45,6 +45,9 @@ export interface TimeSeriesLineChartConfig {
percentStackView?: boolean
/** Show a vertical crosshair line that follows the cursor. */
showCrosshair?: boolean
+ /** Horizontal grid lines, aligned to the primary y-axis ticks. `showGrid` on the primary
+ * `yAxis` config, when set, wins. */
+ showGrid?: boolean
/** Draw L-shaped axis baselines without grid lines (ignored when `yAxis.showGrid` is true). */
showAxisLines?: boolean
/** Draw short tick marks next to each visible axis label. Pairs with `showAxisLines`. */
@@ -95,6 +98,7 @@ export function TimeSeriesLineChart<Meta = unknown>({
comparisonOf,
percentStackView,
showCrosshair,
+ showGrid,
showAxisLines,
showTickMarks,
curve,
@@ -111,6 +115,7 @@ export function TimeSeriesLineChart<Meta = unknown>({
primaryYAxis,
yAxes,
} = useTimeSeries(series, labels, theme, { xAxis, yAxis, valueLabels, legend })
+ const timeSeriesTooltipConfig = useTimeSeriesTooltipConfig(tooltipConfig, xAxis)
const finalSeries = useDerivedSeries(chartSeries, {
confidenceIntervals,
@@ -134,13 +139,13 @@ export function TimeSeriesLineChart<Meta = unknown>({
hideYAxis: primaryYAxis?.hide,
xAxisLabel: xAxis?.label,
yAxisLabel: primaryYAxis?.label,
- showGrid: primaryYAxis?.showGrid,
+ showGrid: primaryYAxis?.showGrid ?? showGrid,
showAxisLines,
showTickMarks,
curve,
percentStackView,
showCrosshair,
- tooltip: tooltipConfig,
+ tooltip: timeSeriesTooltipConfig,
valueDomain,
floatBaseline,
yAxes,
diff --git a/packages/quill/packages/charts/src/utils/dates.ts b/packages/quill/packages/charts/src/utils/dates.ts
index db3e6b771802..0684c4f84d40 100644
--- a/packages/quill/packages/charts/src/utils/dates.ts
+++ b/packages/quill/packages/charts/src/utils/dates.ts
@@ -53,6 +53,35 @@ 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. */
+export function createTooltipDateFormatter({
+ interval,
+ timezone,
+}: {
+ interval: TimeInterval
+ timezone: string
+}): (label: string) => string {
+ return (label: string): string => {
+ const date = parseDateInTimezone(label, timezone)
+ if (!date.isValid()) {
+ return label
+ }
+ switch (interval) {
+ case 'second':
+ return date.format('MMM D, HH:mm:ss')
+ case 'minute':
+ case 'hour':
+ return date.format('MMM D, HH:mm')
+ case 'month':
+ return date.format('MMM YYYY')
+ default:
+ return date.format('MMM D, YYYY')
+ }
+ }
+}
+
function pickMode(interval: TimeInterval, parsedDates: Dayjs[], first: Dayjs, last: Dayjs): TickMode {
const spanMonths = (last.year() - first.year()) * 12 + last.month() - first.month()
const spanDays = last.diff(first, 'day')
diff --git a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
index feb7ee80eedb..8cf116ffb72b 100644
--- a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
+++ b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
@@ -1,7 +1,7 @@
import { useMemo } from 'react'
-import { DEFAULT_Y_AXIS_ID, type YAxis } from '../core/types'
-import { createXAxisTickCallback, type TimeInterval } from './dates'
+import { DEFAULT_Y_AXIS_ID, type TooltipConfig, type YAxis } from '../core/types'
+import { createTooltipDateFormatter, createXAxisTickCallback, type TimeInterval } from './dates'
import { buildYTickFormatter, type YFormatterConfig } from './y-formatters'
export interface XAxisConfig {
@@ -59,6 +59,22 @@ export function useXTickFormatter(
}, [xAxis?.tickFormatter, xAxis?.timezone, xAxis?.interval, effectiveAllDays])
}
+/** Tooltip config with the header label defaulted to a full formatted date when the x-axis is
+ * date-driven (`timezone` + `interval` set) — the axis ticks are already auto-formatted then, so
+ * a raw ISO header would be the odd one out. An explicit `labelFormatter` wins. */
+export function useTimeSeriesTooltipConfig(
+ tooltip: TooltipConfig | undefined,
+ xAxis: XAxisConfig | undefined
+): TooltipConfig | undefined {
+ const { timezone, interval } = xAxis ?? {}
+ return useMemo(() => {
+ if (tooltip?.labelFormatter || !timezone || !interval) {
+ return tooltip
+ }
+ return { ...tooltip, labelFormatter: createTooltipDateFormatter({ interval, timezone }) }
+ }, [tooltip, timezone, interval])
+}
+
/** Non-hook resolution of a {@link YAxisConfig} into a tick formatter. An explicit `tickFormatter`
* wins; otherwise a formatter is built from the format fields, or `undefined` when none are set
* (so callers auto-format against the axis's own ticks). Shared by {@link useYTickFormatter} and
diff --git a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
index fa573c752229..35f88e803db1 100644
--- a/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
+++ b/products/mcp_analytics/frontend/MCPAnalyticsToolDetail.tsx
@@ -26,7 +26,7 @@ import {
TableRow,
} from '@posthog/quill-primitives'
-import { useChartTheme } from 'lib/charts/hooks'
+import { useChartConfig, useChartTheme } from 'lib/charts/hooks'
import { TZLabel } from 'lib/components/TZLabel'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
import { humanFriendlyNumber } from 'lib/utils/numbers'
@@ -397,10 +397,13 @@ function DescriptionBlock({
function trendChartConfig(timezone: string, yAxis?: TimeSeriesLineChartConfig['yAxis']): TimeSeriesLineChartConfig {
return {
- yAxis: { showGrid: false, ...yAxis },
+ curve: 'monotone',
showAxisLines: true,
- xAxis: { interval: 'day', timezone },
+ showTickMarks: true,
showCrosshair: true,
+ showGrid: true,
+ yAxis,
+ xAxis: { interval: 'day', timezone },
tooltip: { placement: 'cursor' },
}
}
@@ -505,8 +508,11 @@ function MCPAnalyticsToolDetailContent({ toolName }: { toolName: string }): JSX.
() => seriesFor(dailyChartData, theme, ['p50', 'p95']),
[dailyChartData, theme]
)
- const countsConfig = useMemo(() => trendChartConfig(timezone), [timezone])
- const latencyConfig = useMemo(() => trendChartConfig(timezone, { tickFormatter: formatMsAsSeconds }), [timezone])
+ const countsConfig = useChartConfig(() => trendChartConfig(timezone), [timezone])
+ const latencyConfig = useChartConfig(
+ () => trendChartConfig(timezone, { tickFormatter: formatMsAsSeconds }),
+ [timezone]
+ )
return (
<SceneContent>
diff --git a/products/mcp_analytics/frontend/dashboard/ActivityChart.tsx b/products/mcp_analytics/frontend/dashboard/ActivityChart.tsx
index 8292e10dcdae..84041520e622 100644
--- a/products/mcp_analytics/frontend/dashboard/ActivityChart.tsx
+++ b/products/mcp_analytics/frontend/dashboard/ActivityChart.tsx
@@ -9,6 +9,8 @@ import {
} from '@posthog/quill-charts'
import { Skeleton } from '@posthog/quill-primitives'
+import { useChartConfig } from 'lib/charts/hooks'
+
import { type DailyActivity } from '../mcpDashboardOverviewLogic'
import { Card, CardState } from './Card'
@@ -41,12 +43,14 @@ export function ActivityChart({
]
}, [daily, theme, incompleteTail])
// quill's built-in date tick formatter only kicks in when both interval and timezone are set.
- const config = useMemo<TimeSeriesLineChartConfig>(
+ const config = useChartConfig<TimeSeriesLineChartConfig>(
() => ({
- yAxis: { showGrid: false },
+ curve: 'monotone',
showAxisLines: true,
- xAxis: { interval, timezone },
+ showTickMarks: true,
showCrosshair: true,
+ showGrid: true,
+ xAxis: { interval, timezone },
tooltip: { placement: 'cursor' },
}),
[timezone, interval]
diff --git a/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx b/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
index f4f71bd31f68..39b6dbd4699c 100644
--- a/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
+++ b/products/mcp_analytics/frontend/dashboard/ToolErrorRateChart.tsx
@@ -10,6 +10,7 @@ import {
} from '@posthog/quill-charts'
import { Skeleton } from '@posthog/quill-primitives'
+import { useChartConfig } from 'lib/charts/hooks'
import { formatPercentage } from 'lib/utils/numbers'
import { type ToolRow } from '../mcpDashboardOverviewLogic'
@@ -49,16 +50,19 @@ export function ToolErrorRateChart({
],
[sorted, theme]
)
- const config = useMemo<BarChartConfig>(() => {
+ const config = useChartConfig<BarChartConfig>(() => {
const axisMax = niceErrorAxisMax(sorted[0]?.error_rate_pct ?? 0)
return {
axisOrientation: 'horizontal',
barLayout: 'grouped',
- showGrid: false,
- showAxisLines: false,
+ showAxisLines: true,
+ showTickMarks: true,
+ showCrosshair: true,
+ showGrid: true,
+ yTickFormatter: (value: number) => formatPercentage(value, { compact: true }),
tooltip: { placement: 'cursor' },
margins: { top: 4, right: 20, bottom: 22 },
- bars: { cornerRadius: 3, minBandSize: 30, track: { hover: false }, valueDomain: [0, axisMax] },
+ bars: { cornerRadius: 4, minBandSize: 30, valueDomain: [0, axisMax] },
}
}, [sorted])
const byTool = useMemo(() => new Map(sorted.map((r) => [r.tool, r])), [sorted])
diff --git a/products/mcp_analytics/frontend/dashboard/ToolUsageChart.tsx b/products/mcp_analytics/frontend/dashboard/ToolUsageChart.tsx
index 6905fa0abe0c..d4e7df00cc3d 100644
--- a/products/mcp_analytics/frontend/dashboard/ToolUsageChart.tsx
+++ b/products/mcp_analytics/frontend/dashboard/ToolUsageChart.tsx
@@ -9,6 +9,8 @@ import {
} from '@posthog/quill-charts'
import { Skeleton } from '@posthog/quill-primitives'
+import { useChartConfig } from 'lib/charts/hooks'
+
import { type ToolDailySeries } from '../mcpDashboardOverviewLogic'
import { Card, CardState } from './Card'
@@ -35,12 +37,14 @@ export function ToolUsageChart({
})),
[data, theme]
)
- const config = useMemo<TimeSeriesBarChartConfig>(
+ const config = useChartConfig<TimeSeriesBarChartConfig>(
() => ({
barLayout: 'stacked',
- barCornerRadius: 2,
- yAxis: { showGrid: false },
+ barCornerRadius: 4,
showAxisLines: true,
+ showTickMarks: true,
+ showCrosshair: true,
+ showGrid: true,
xAxis: { interval, timezone },
tooltip: { placement: 'cursor' },
}),
diff --git a/products/mcp_analytics/frontend/tool-quality/ToolQualityCharts.tsx b/products/mcp_analytics/frontend/tool-quality/ToolQualityCharts.tsx
index 1f1f803fa887..11bd148d0be1 100644
--- a/products/mcp_analytics/frontend/tool-quality/ToolQualityCharts.tsx
+++ b/products/mcp_analytics/frontend/tool-quality/ToolQualityCharts.tsx
@@ -10,6 +10,7 @@ import {
legendItemsFromSeries,
} from '@posthog/quill-charts'
+import { useChartConfig } from 'lib/charts/hooks'
import { formatPercentage } from 'lib/utils/numbers'
import { Card, CardState } from '../dashboard/Card'
@@ -18,10 +19,13 @@ import { type DailyChartData } from '../mcpAnalyticsToolQualityLogic'
function buildConfig(timezone: string, yAxis?: TimeSeriesLineChartConfig['yAxis']): TimeSeriesLineChartConfig {
return {
- yAxis: { showGrid: false, ...yAxis },
+ curve: 'monotone',
showAxisLines: true,
- xAxis: { interval: 'day', timezone },
+ showTickMarks: true,
showCrosshair: true,
+ showGrid: true,
+ yAxis,
+ xAxis: { interval: 'day', timezone },
tooltip: { placement: 'cursor' },
}
}
@@ -91,12 +95,12 @@ export function ToolQualityCharts({
[data, theme]
)
- const countsConfig = useMemo(() => buildConfig(timezone), [timezone])
- const percentConfig = useMemo(
+ const countsConfig = useChartConfig(() => buildConfig(timezone), [timezone])
+ const percentConfig = useChartConfig(
() => buildConfig(timezone, { tickFormatter: (value: number) => formatPercentage(value, { compact: true }) }),
[timezone]
)
- const latencyConfig = useMemo(() => buildConfig(timezone, { tickFormatter: formatMsAsSeconds }), [timezone])
+ const latencyConfig = useChartConfig(() => buildConfig(timezone, { tickFormatter: formatMsAsSeconds }), [timezone])
return (
<div className="grid grid-cols-1 gap-4 lg:grid-cols-3">