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(quill-charts): add dual y-axis config to TimeSeriesLineChart (#64899)

Sam Penningtonc93d3c32f1b8
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 3ffa0eb78724..1731e93e5e3f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -892,6 +892,14 @@ snapshots:
hash: v1.k794b7964.c5a1a997378245bd048d35ff7ab54694c9e333ff6369e5c30d40357df99842fa.xXPbAc4NqAr0LvV-0z_5t3MYqgWR7l0eVtIt35KNfhE
components-hogcharts-timeserieslinechart--drag-to-zoom--light:
hash: v1.k794b7964.7d8de1c664f78dad36682304cd25c746266b6fb509d28bcaf2d8ae629a808284.eGlPABfqYjC1-H2VGiv5lJxfPOXP5U2fpK2cr7CtOT4
+ components-hogcharts-timeserieslinechart--dual-y-axis--dark:
+ hash: v1.k794b7964.9dd0eaaa2cc7cb1f24435e4ef698026fdff68203f5f47458aae13f44d1f5a728.q1wTd45_ueu_x_Zse6xADTOqGZ08WtEMo0EVf1th-Ws
+ components-hogcharts-timeserieslinechart--dual-y-axis--light:
+ hash: v1.k794b7964.74c876ccaa5fec4e36be5caab089532d26162d4cc8e5d0462331cbfb9b945b07.P2nBmV3pHVf81hjDjOYyrU5VnlwdRy-VAn19v7huY2A
+ components-hogcharts-timeserieslinechart--dual-y-axis-mixed-scales--dark:
+ hash: v1.k794b7964.29818ddbe1b02235c664d60287f532df226476a1397e5fd338462b91cb8b1a43.Gb-KIUMh9HExDL0NOX4gpVcDQKhglUXmBLo_CKKV4Ik
+ components-hogcharts-timeserieslinechart--dual-y-axis-mixed-scales--light:
+ hash: v1.k794b7964.3fe1803ae3e039ead859da938fdef88300ab6ff08254757da777556a499636ff.Ne7zpBUPko3GyNTT5tmSZqQeKABJyVdObd1Sz2V_Cj0
components-hogcharts-timeserieslinechart--moving-average--dark:
hash: v1.k794b7964.e332e9beb6b72bee51ab22b8078273883dabe8cd97163f6005a44367378fa8f7.H_JLql_NFDi4zX-Gn0svc0N_NewsyAhqaII4UGIXykg
components-hogcharts-timeserieslinechart--moving-average--light:
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 0855da47cdae..0d77289d8ee3 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -74,6 +74,7 @@ Charts fill their container and need a parent with real dimensions — a `0`-hei
- `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.
- `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`. `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).
- y-axis `format`: `numeric | short | percentage | percentage_scaled | currency | duration | duration-ms`, plus `prefix`/`suffix`.
+- Dual / multi y-axis: give a series a `yAxisId` to scale it against a second axis. On `TimeSeriesLineChart`, pass `config.yAxis` as an **array** — one `YAxisConfig` per axis — to format/scale each axis independently: set `id` (matches `Series.yAxisId`; first entry defaults to `'left'`), `position` (`'left'`/`'right'`; first entry defaults to `'left'`, the rest to `'right'`), and the usual `scale`/`format`/`tickFormatter`/`label`/`showGrid` per entry. A single object stays single-axis (unchanged). The second axis only renders when a series actually targets it; the primary (left) axis owns the gridlines. `TimeSeriesBarChart`/`ComboChart` already render per-`yAxisId` axes but share one tick formatter across gutters.
- `onDateRangeZoom` (on `LineChart`/`TimeSeriesLineChart`/base `Chart`) enables x-axis drag-to-zoom: the user drags horizontally and the callback fires once with `{ startLabel, endLabel, startIndex, endIndex }` for the spanned range. The cursor switches to a crosshair when set. x-axis only — no effect on charts with a vertical interaction axis.
## Maintenance
diff --git a/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx b/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx
index 7b485a6c45fe..ad2ac2272445 100644
--- a/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx
+++ b/packages/quill/packages/charts/src/charts/LineChart/LineChart.tsx
@@ -79,6 +79,7 @@ function LineChartInner<Meta = unknown>({
showGrid = false,
showAxisLines = false,
valueDomain,
+ yAxes: yAxisRenderConfigs,
} = config ?? {}
const { visibleSeries, legendProps } = useChartLegend(series, theme, config?.legend)
@@ -127,6 +128,7 @@ function LineChartInner<Meta = unknown>({
scaleType: yScaleType,
percentStack: percentStackView,
valueDomain,
+ axes: yAxisRenderConfigs,
})
const yTickCount = yTickCountForHeight(dimensions.plotHeight)
@@ -149,7 +151,7 @@ function LineChartInner<Meta = unknown>({
_private: lineChartPrivate,
}
},
- [yScaleType, percentStackView, stackedData, valueDomain]
+ [yScaleType, percentStackView, stackedData, valueDomain, yAxisRenderConfigs]
)
const drawStatic = useCallback(
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.stories.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.stories.tsx
index 8fbeee1fa133..51ed6aab8b63 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.stories.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.stories.tsx
@@ -48,6 +48,72 @@ export const Basic: Story = {
},
}
+/** Two series on independent y-axes: revenue (currency, left) and conversion rate (percentage,
+ * right), each formatting its own ticks. Pass `yAxis` as an array — one entry per axis. */
+export const DualYAxis: Story = {
+ render: () => {
+ const theme = useReactiveTheme()
+ const series: Series[] = [
+ { key: 'revenue', label: 'Revenue', color: '', data: [1100, 1300, 1250, 1700, 1500, 1900, 1800] },
+ {
+ key: 'conversion',
+ label: 'Conversion',
+ color: '',
+ data: [0.022, 0.028, 0.025, 0.034, 0.031, 0.038, 0.036],
+ yAxisId: 'right',
+ },
+ ]
+ return (
+ <Stage>
+ <TimeSeriesLineChart
+ series={series}
+ labels={DAYS}
+ theme={theme}
+ config={{
+ yAxis: [
+ { id: 'left', label: 'Revenue', format: 'currency', currency: 'USD', showGrid: true },
+ { id: 'right', position: 'right', label: 'Conversion', format: 'percentage_scaled' },
+ ],
+ }}
+ />
+ </Stage>
+ )
+ },
+}
+
+/** Mixed scale types across axes: a linear count on the left and a log-scaled latency series on
+ * the right, each with its own formatter. */
+export const DualYAxisMixedScales: Story = {
+ render: () => {
+ const theme = useReactiveTheme()
+ const series: Series[] = [
+ { key: 'requests', label: 'Requests', color: '', data: [120, 180, 150, 210, 170, 240, 220] },
+ {
+ key: 'latency',
+ label: 'p99 latency',
+ color: '',
+ data: [12, 80, 35, 600, 90, 1400, 300],
+ yAxisId: 'right',
+ },
+ ]
+ return (
+ <Stage>
+ <TimeSeriesLineChart
+ series={series}
+ labels={DAYS}
+ theme={theme}
+ config={{
+ yAxis: [
+ { id: 'left', label: 'Requests', format: 'short', showGrid: true },
+ { id: 'right', position: 'right', label: 'p99 latency', scale: 'log', suffix: 'ms' },
+ ],
+ }}
+ />
+ </Stage>
+ )
+ },
+}
+
export const DragToZoom: Story = {
render: () => {
const theme = useReactiveTheme()
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
index 79ddfe38298e..e112170e075a 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
@@ -145,6 +145,125 @@ describe('TimeSeriesLineChart', () => {
})
})
+ describe('config.yAxis array (dual y-axis)', () => {
+ const LEFT_RIGHT_SERIES: Series[] = [
+ { key: 'rev', label: 'Revenue', data: [1000, 1500, 1200] },
+ { key: 'conv', label: 'Conversion', data: [0.01, 0.02, 0.015], yAxisId: 'right' },
+ ]
+ const DUAL_CONFIG = { yAxis: [{ id: 'left' }, { id: 'right', position: 'right' as const }] }
+ const num = (t: string): number => parseFloat(t.replace(/[^0-9.eE+-]/g, ''))
+
+ it('renders both a left and a right y-axis when a series targets each', () => {
+ const { chart } = renderHogChart(
+ <TimeSeriesLineChart series={LEFT_RIGHT_SERIES} labels={LABELS} theme={THEME} config={DUAL_CONFIG} />
+ )
+ expect(chart.hasRightAxis).toBe(true)
+ expect(chart.yTicks().length).toBeGreaterThan(0)
+ expect(chart.yRightTicks().length).toBeGreaterThan(0)
+ })
+
+ it('formats each axis with its own tick formatter', () => {
+ const { chart } = renderHogChart(
+ <TimeSeriesLineChart
+ series={LEFT_RIGHT_SERIES}
+ labels={LABELS}
+ theme={THEME}
+ config={{
+ yAxis: [
+ { id: 'left', tickFormatter: (v) => `L${v}` },
+ { id: 'right', position: 'right', tickFormatter: (v) => `R${v}` },
+ ],
+ }}
+ />
+ )
+ expect(chart.yTicks().every((t) => t.startsWith('L'))).toBe(true)
+ expect(chart.yRightTicks().every((t) => t.startsWith('R'))).toBe(true)
+ })
+
+ it('builds an independent scale per axis — left covers the large series, right the small one', () => {
+ const { chart } = renderHogChart(
+ <TimeSeriesLineChart
+ series={LEFT_RIGHT_SERIES}
+ labels={LABELS}
+ theme={THEME}
+ config={{
+ yAxis: [
+ { id: 'left', tickFormatter: (v) => `L${v}` },
+ { id: 'right', position: 'right', tickFormatter: (v) => `R${v}` },
+ ],
+ }}
+ />
+ )
+ expect(Math.max(...chart.yTicks().map(num))).toBeGreaterThanOrEqual(1000)
+ expect(Math.max(...chart.yRightTicks().map(num))).toBeLessThanOrEqual(1)
+ })
+
+ it('renders the right-axis title from the right entry label', () => {
+ const { container, chart } = renderHogChart(
+ <TimeSeriesLineChart
+ series={LEFT_RIGHT_SERIES}
+ labels={LABELS}
+ theme={THEME}
+ config={{
+ yAxis: [
+ { id: 'left', label: 'Revenue' },
+ { id: 'right', position: 'right', label: 'Conversion' },
+ ],
+ }}
+ />
+ )
+ expect(chart.yAxisLabel()).toBe('Revenue')
+ expect(container.querySelector('[data-attr="hog-chart-axis-title-yr"]')?.textContent).toBe('Conversion')
+ })
+
+ it('reserves right margin so right-axis tick labels are not clipped', () => {
+ const { container } = renderHogChart(
+ <TimeSeriesLineChart
+ series={LEFT_RIGHT_SERIES}
+ labels={LABELS}
+ theme={THEME}
+ config={{
+ yAxis: [
+ { id: 'left' },
+ { id: 'right', position: 'right', tickFormatter: (v) => `${v} requests/s` },
+ ],
+ }}
+ />
+ )
+ const rightTicks = Array.from(
+ container.querySelectorAll<HTMLElement>('[data-attr="hog-chart-axis-tick-yr"]')
+ )
+ expect(rightTicks.length).toBeGreaterThan(0)
+ // The mocked canvas is 800px wide; each right-gutter label sits inside it with room to spare.
+ for (const el of rightTicks) {
+ const left = parseFloat(el.style.left)
+ expect(Number.isFinite(left)).toBe(true)
+ expect(left).toBeLessThan(800)
+ expect(800 - left).toBeGreaterThanOrEqual(12)
+ }
+ })
+
+ it('treats a single-object yAxis as one axis (no right gutter) — back-compat', () => {
+ const { chart } = renderHogChart(
+ <TimeSeriesLineChart
+ series={SERIES}
+ labels={LABELS}
+ theme={THEME}
+ config={{ yAxis: { format: 'percentage' } }}
+ />
+ )
+ expect(chart.hasRightAxis).toBe(false)
+ expect(chart.yRightTicks()).toHaveLength(0)
+ })
+
+ it('does not render a right axis when an array config has no right-axis series', () => {
+ const { chart } = renderHogChart(
+ <TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={DUAL_CONFIG} />
+ )
+ expect(chart.hasRightAxis).toBe(false)
+ })
+ })
+
describe('config.valueLabels', () => {
it.each([
['omitted', undefined],
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
index 48f7e4b40204..d0959484d2fd 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.tsx
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react'
import { ChartLegend } from '../../components/Legend/ChartLegend'
import { useChartLegend } from '../../components/Legend/useChartLegend'
+import { DEFAULT_Y_AXIS_ID } from '../../core/types'
import type {
ChartLegendConfig,
ChartTheme,
@@ -11,11 +12,13 @@ import type {
Series,
TooltipConfig,
TooltipContext,
+ YAxisRenderConfig,
} from '../../core/types'
import { ReferenceLines } from '../../overlays/ReferenceLine'
import { ValueLabels } from '../../overlays/ValueLabels'
import { buildGoalLineReferenceLines, goalLineValueDomain, type GoalLineConfig } from '../../utils/goal-lines'
import {
+ resolveYTickFormatter,
useXTickFormatter,
useYTickFormatter,
type XAxisConfig,
@@ -36,9 +39,33 @@ import {
export type { ConfidenceIntervalConfig, MovingAverageConfig, TrendLineConfig }
+interface NormalizedYAxis {
+ id: string
+ position: 'left' | 'right'
+ config: YAxisConfig
+}
+
+/** Normalize the `yAxis` config into a per-axis list. A single object (or omitted) is the primary
+ * left axis; an array assigns ids/positions, defaulting the first entry to the primary left axis
+ * and subsequent entries to the right. */
+function normalizeYAxisList(yAxis: YAxisConfig | YAxisConfig[] | undefined): NormalizedYAxis[] {
+ if (!Array.isArray(yAxis)) {
+ return yAxis ? [{ id: DEFAULT_Y_AXIS_ID, position: 'left', config: yAxis }] : []
+ }
+ return yAxis.map((config, index) => ({
+ id: config.id ?? (index === 0 ? DEFAULT_Y_AXIS_ID : `axis-${index}`),
+ position: config.position ?? (index === 0 ? 'left' : 'right'),
+ config,
+ }))
+}
+
export interface TimeSeriesLineChartConfig {
xAxis?: XAxisConfig
- yAxis?: YAxisConfig
+ /** Single object = one y-axis (today's behavior). Array = one entry per axis for dual y-axis
+ * charts: set `id` (matches `Series.yAxisId`; first entry defaults to `'left'`) and `position`
+ * (`'left'`/`'right'`; first entry defaults to `'left'`, the rest to `'right'`). A series renders
+ * against a secondary axis when its `yAxisId` matches an entry's `id`. */
+ yAxis?: YAxisConfig | YAxisConfig[]
valueLabels?: boolean | ValueLabelsConfig
goalLines?: GoalLineConfig[]
confidenceIntervals?: ConfidenceIntervalConfig[]
@@ -100,8 +127,30 @@ export function TimeSeriesLineChart<Meta = unknown>({
tooltip: tooltipConfig,
legend,
} = config ?? {}
+ const axisList = useMemo(() => normalizeYAxisList(yAxis), [yAxis])
+ // Scalar y-config describes the primary (left) axis — drives single-axis rendering, the default
+ // value-label formatter, and the left gutter when a right-axis series is present.
+ const primaryYAxis = useMemo<YAxisConfig | undefined>(
+ () => (axisList.find((a) => a.id === DEFAULT_Y_AXIS_ID) ?? axisList[0])?.config,
+ [axisList]
+ )
+ // Per-axis render configs only when the caller passed an array — a single object keeps the
+ // existing single-axis path untouched (no `yAxes` on the LineChart config).
+ const yAxesRenderConfig = useMemo<YAxisRenderConfig[] | undefined>(() => {
+ if (!Array.isArray(yAxis)) {
+ return undefined
+ }
+ return axisList.map(({ id, position, config }) => ({
+ id,
+ position,
+ scaleType: config.scale,
+ tickFormatter: resolveYTickFormatter(config),
+ label: config.label,
+ }))
+ }, [yAxis, axisList])
+
const xTickFormatter = useXTickFormatter(xAxis, labels)
- const yTickFormatter = useYTickFormatter(yAxis)
+ const yTickFormatter = useYTickFormatter(primaryYAxis)
// Toggling works off the raw series so the legend lists the user's series (not derived trend
// lines / CI bands); hidden ones flow through the derived pipeline already excluded.
@@ -127,19 +176,20 @@ export function TimeSeriesLineChart<Meta = unknown>({
const valueDomain = useMemo(() => goalLineValueDomain(referenceLines), [referenceLines])
const lineChartConfig: LineChartConfig = {
- yScaleType: yAxis?.scale,
+ yScaleType: primaryYAxis?.scale,
xTickFormatter,
yTickFormatter,
hideXAxis: xAxis?.hide,
- hideYAxis: yAxis?.hide,
+ hideYAxis: primaryYAxis?.hide,
xAxisLabel: xAxis?.label,
- yAxisLabel: yAxis?.label,
- showGrid: yAxis?.showGrid,
+ yAxisLabel: primaryYAxis?.label,
+ showGrid: primaryYAxis?.showGrid,
showAxisLines,
percentStackView,
showCrosshair,
tooltip: tooltipConfig,
valueDomain,
+ yAxes: yAxesRenderConfig,
}
return (
diff --git a/packages/quill/packages/charts/src/core/Chart.tsx b/packages/quill/packages/charts/src/core/Chart.tsx
index 5866962e26b6..8f85ed609b57 100644
--- a/packages/quill/packages/charts/src/core/Chart.tsx
+++ b/packages/quill/packages/charts/src/core/Chart.tsx
@@ -123,7 +123,37 @@ export function Chart<Meta = unknown>({
animateHover,
margins: marginsOverride,
maxCategoryLabelWidth,
+ yAxes,
} = config ?? {}
+
+ // Per-axis tick formatters, sides, and right-axis title for multi-axis charts. Each gutter
+ // formats against its own axis config; absent here, an axis auto-formats against its ticks.
+ const yAxisFormatters = useMemo<Record<string, (value: number) => string> | undefined>(() => {
+ if (!yAxes) {
+ return undefined
+ }
+ const map: Record<string, (value: number) => string> = {}
+ for (const axis of yAxes) {
+ if (axis.tickFormatter) {
+ map[axis.id] = axis.tickFormatter
+ }
+ }
+ return Object.keys(map).length > 0 ? map : undefined
+ }, [yAxes])
+ const yAxisPositions = useMemo<Record<string, 'left' | 'right'> | undefined>(() => {
+ if (!yAxes) {
+ return undefined
+ }
+ const map: Record<string, 'left' | 'right'> = {}
+ for (const axis of yAxes) {
+ map[axis.id] = axis.position
+ }
+ return map
+ }, [yAxes])
+ const yAxisLabelRight = useMemo<string | undefined>(
+ () => yAxes?.find((axis) => axis.position === 'right')?.label,
+ [yAxes]
+ )
const hoverAnimationMs = resolveHoverAnimationMs(animateHover)
const interactionAxis: 'x' | 'y' = axisOrientation === 'horizontal' ? 'y' : 'x'
const {
@@ -145,6 +175,9 @@ export function Chart<Meta = unknown>({
override: marginsOverride,
valueRangeSeries,
maxCategoryLabelWidth,
+ yAxisFormatters,
+ yAxisPositions,
+ yAxisLabelRight,
})
const { canvasRef, overlayCanvasRef, wrapperRef, dimensions, ctx, overlayCtx } = useChartCanvas({ margins })
@@ -268,6 +301,7 @@ export function Chart<Meta = unknown>({
xTickFormatter={xTickFormatter}
yTickFormatter={resolvedYFormatter}
userYTickFormatter={yTickFormatter}
+ yAxisFormatters={yAxisFormatters}
hideXAxis={hideXAxis}
hideYAxis={hideYAxis}
axisColor={axisColor}
@@ -278,6 +312,7 @@ export function Chart<Meta = unknown>({
<AxisTitles
xAxisLabel={xAxisLabel}
yAxisLabel={yAxisLabel}
+ yAxisLabelRight={yAxisLabelRight}
hideXAxis={hideXAxis}
hideYAxis={hideYAxis}
axisColor={axisColor}
diff --git a/packages/quill/packages/charts/src/core/hooks/useChartMargins.ts b/packages/quill/packages/charts/src/core/hooks/useChartMargins.ts
index 05368088b144..81236f825dce 100644
--- a/packages/quill/packages/charts/src/core/hooks/useChartMargins.ts
+++ b/packages/quill/packages/charts/src/core/hooks/useChartMargins.ts
@@ -43,6 +43,14 @@ interface UseChartMarginsOptions {
/** When set, clamp the reserved category-label width to this ceiling so a single long label
* can't grow the axis margin without bound. Mirrors AxisLabels' display truncation. */
maxCategoryLabelWidth?: number
+ /** Per-axis tick formatters keyed by axis id, for sizing each gutter against its own labels.
+ * Falls back to `yTickFormatter` for axes not listed. Multi-axis charts only. */
+ yAxisFormatters?: Record<string, (value: number) => string>
+ /** Per-axis sides keyed by axis id, overriding the alternating-side default. Keeps the margin
+ * reservation in step with the scales' config-driven positions. Multi-axis charts only. */
+ yAxisPositions?: Record<string, 'left' | 'right'>
+ /** Right-side y-axis title — reserves extra right margin so it doesn't clip. */
+ yAxisLabelRight?: string
}
function widestCategoryLabelWidth(
@@ -92,11 +100,15 @@ export function useChartMargins({
override,
valueRangeSeries,
maxCategoryLabelWidth = 0,
+ yAxisFormatters,
+ yAxisPositions,
+ yAxisLabelRight,
}: UseChartMarginsOptions): ChartMargins {
const isHorizontal = axisOrientation === 'horizontal'
const valueSeries = valueRangeSeries ?? series
const normalizedXAxisLabel = normalizeAxisLabel(xAxisLabel)
const normalizedYAxisLabel = normalizeAxisLabel(yAxisLabel)
+ const normalizedYAxisLabelRight = normalizeAxisLabel(yAxisLabelRight)
const hasMultipleAxes = useMemo(() => {
const axisIds = new Set(
@@ -151,15 +163,17 @@ export function useChartMargins({
let left = 0
let right = 0
for (const { axisId, position } of orderedAxisPositions(valueSeries)) {
- const width = Math.ceil(widestValueLabelWidth(byAxis.get(axisId) ?? [], yTickFormatter)) + Y_LABEL_RIGHT_PADDING
- if (position === 'left') {
+ const formatter = yAxisFormatters?.[axisId] ?? yTickFormatter
+ const side = yAxisPositions?.[axisId] ?? position
+ const width = Math.ceil(widestValueLabelWidth(byAxis.get(axisId) ?? [], formatter)) + Y_LABEL_RIGHT_PADDING
+ if (side === 'left') {
left += width + (left > 0 ? GUTTER_GAP : 0)
} else {
right += width + (right > 0 ? GUTTER_GAP : 0)
}
}
return { left, right }
- }, [hideYAxis, isHorizontal, hasMultipleAxes, valueSeries, yTickFormatter])
+ }, [hideYAxis, isHorizontal, hasMultipleAxes, valueSeries, yTickFormatter, yAxisFormatters, yAxisPositions])
return useMemo<ChartMargins>(() => {
const bottom = hideXAxis
@@ -168,10 +182,14 @@ export function useChartMargins({
const leftLabelReserve = gutterReserves ? gutterReserves.left : Math.ceil(yLabelWidth) + Y_LABEL_RIGHT_PADDING
const left = hideYAxis
? COLLAPSED_AXIS_MARGIN
- : Math.max(MIN_LEFT_MARGIN, leftLabelReserve + Y_LABEL_LEFT_GUTTER, xLabelHalfWidth + X_LABEL_EDGE_PADDING) +
- (normalizedYAxisLabel ? Y_AXIS_TITLE_MARGIN : 0)
+ : Math.max(
+ MIN_LEFT_MARGIN,
+ leftLabelReserve + Y_LABEL_LEFT_GUTTER,
+ xLabelHalfWidth + X_LABEL_EDGE_PADDING
+ ) + (normalizedYAxisLabel ? Y_AXIS_TITLE_MARGIN : 0)
const rightFloor = hasMultipleAxes && !hideYAxis ? MIN_RIGHT_MARGIN_DUAL_AXIS : DEFAULT_MARGINS.right
- const right = Math.max(rightFloor, gutterReserves?.right ?? 0, xLabelHalfWidth + X_LABEL_EDGE_PADDING)
+ const rightLabelReserve = (gutterReserves?.right ?? 0) + (normalizedYAxisLabelRight ? Y_AXIS_TITLE_MARGIN : 0)
+ const right = Math.max(rightFloor, rightLabelReserve, xLabelHalfWidth + X_LABEL_EDGE_PADDING)
const computed: ChartMargins = { top: DEFAULT_MARGINS.top, right, bottom, left }
return override ? { ...computed, ...override } : computed
}, [
@@ -183,6 +201,7 @@ export function useChartMargins({
xLabelHalfWidth,
normalizedXAxisLabel,
normalizedYAxisLabel,
+ normalizedYAxisLabelRight,
override,
])
}
diff --git a/packages/quill/packages/charts/src/core/scales.test.ts b/packages/quill/packages/charts/src/core/scales.test.ts
index 0407b1a0f63c..066323abdb7d 100644
--- a/packages/quill/packages/charts/src/core/scales.test.ts
+++ b/packages/quill/packages/charts/src/core/scales.test.ts
@@ -393,6 +393,46 @@ describe('hog-charts scales', () => {
// The right axis is unaffected — nice() can nudge 500 up a little, but nowhere near 1000.
expect(result.yAxes!.y1.scale.domain()[1]).toBeLessThan(1000)
})
+
+ it('applies a per-axis scaleType from options.axes to that axis only', () => {
+ const left = makeSeries({ key: 'left', data: [1, 1000], yAxisId: DEFAULT_Y_AXIS_ID })
+ const right = makeSeries({ key: 'right', data: [1, 1000], yAxisId: 'y1' })
+ const result = createScales([left, right], ['a', 'b'], dimensions, {
+ axes: [
+ { id: DEFAULT_Y_AXIS_ID, position: 'left', scaleType: 'linear' },
+ { id: 'y1', position: 'right', scaleType: 'log' },
+ ],
+ })
+ // The log axis compresses the low end far more than the linear one for identical data.
+ const linearMid = result.yAxes![DEFAULT_Y_AXIS_ID].scale(100)
+ const logMid = result.yAxes!.y1.scale(100)
+ expect(linearMid).not.toBeCloseTo(logMid, 0)
+ })
+
+ it('honors a config-driven position over the alternating default', () => {
+ const a = makeSeries({ key: 'a', data: [0, 10], yAxisId: DEFAULT_Y_AXIS_ID })
+ const b = makeSeries({ key: 'b', data: [0, 1000], yAxisId: 'y1' })
+ // Both axes forced to the right side — the alternating default would put 'left' on the left.
+ const result = createScales([a, b], ['x', 'y'], dimensions, {
+ axes: [
+ { id: DEFAULT_Y_AXIS_ID, position: 'right' },
+ { id: 'y1', position: 'right' },
+ ],
+ })
+ expect(result.yAxes![DEFAULT_Y_AXIS_ID].position).toBe('right')
+ expect(result.yAxes!.y1.position).toBe('right')
+ })
+
+ it('uses a single-axis options.axes scaleType for the sole axis', () => {
+ const only = makeSeries({ key: 'only', data: [1, 10, 100, 1000] })
+ const result = createScales([only], ['a', 'b', 'c', 'd'], dimensions, {
+ axes: [{ id: DEFAULT_Y_AXIS_ID, position: 'left', scaleType: 'log' }],
+ })
+ // Single axis → no yAxes map, but the sole scale picks up the log scaleType.
+ expect(result.yAxes).toBeUndefined()
+ const [min] = result.y.domain() as [number, number]
+ expect(min).toBeGreaterThan(0)
+ })
})
describe('computePercentStackData', () => {
diff --git a/packages/quill/packages/charts/src/core/scales.ts b/packages/quill/packages/charts/src/core/scales.ts
index 5366f0c7e4d6..98c3a44758e9 100644
--- a/packages/quill/packages/charts/src/core/scales.ts
+++ b/packages/quill/packages/charts/src/core/scales.ts
@@ -316,16 +316,22 @@ export function createScales(
/** Applied to the primary y-axis only — goal lines (`{ include }`) render against the
* primary axis, so secondary axes keep their own data-derived scale. */
valueDomain?: ValueDomain
+ /** Per-axis overrides keyed by axis id. When an axis is listed its `scaleType` and
+ * `position` win; otherwise it falls back to `options.scaleType` and the alternating-side
+ * default from {@link orderedAxisPositions}. */
+ axes?: { id: string; position?: 'left' | 'right'; scaleType?: 'linear' | 'log' }[]
} = {}
): ScaleSet {
const x = createXScale(labels, dimensions)
const positions = orderedAxisPositions(series)
const hasMultipleAxes = positions.length > 1
+ const axisOverrides = new Map((options.axes ?? []).map((a) => [a.id, a]))
if (!hasMultipleAxes) {
+ const soleAxisId = positions[0]?.axisId ?? DEFAULT_Y_AXIS_ID
const y = createYScale(series, dimensions, {
- scaleType: options.scaleType,
+ scaleType: axisOverrides.get(soleAxisId)?.scaleType ?? options.scaleType,
percentStack: options.percentStack,
valueDomain: options.valueDomain,
})
@@ -335,12 +341,13 @@ export function createScales(
const byAxis = groupVisibleSeriesByAxis(series)
const yAxes: Record<string, { scale: D3YScale; position: 'left' | 'right' }> = {}
positions.forEach(({ axisId, position }, axisIndex) => {
+ const override = axisOverrides.get(axisId)
const scale = createYScale(byAxis.get(axisId) ?? [], dimensions, {
- scaleType: options.scaleType,
+ scaleType: override?.scaleType ?? options.scaleType,
percentStack: options.percentStack,
valueDomain: axisIndex === 0 ? options.valueDomain : undefined,
})
- yAxes[axisId] = { scale, position }
+ yAxes[axisId] = { scale, position: override?.position ?? position }
})
const primaryAxis = yAxes[DEFAULT_Y_AXIS_ID] ?? yAxes[positions[0].axisId]
diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.ts
index bbf05deae673..799888c23dc5 100644
--- a/packages/quill/packages/charts/src/core/types.ts
+++ b/packages/quill/packages/charts/src/core/types.ts
@@ -234,6 +234,27 @@ export interface ChartConfig {
* with the full value revealed on hover. Also clamps the axis margin to this width so a long
* label can't push the plot off screen. Omit (default) to render labels untruncated. */
maxCategoryLabelWidth?: number
+ /** Per-axis config for multi-axis (dual y-axis) charts — one entry per distinct
+ * {@link Series.yAxisId}. When set, each axis formats ticks, labels, and scales independently;
+ * the scalar `yScaleType`/`yTickFormatter`/`yAxisLabel` then describe the primary (left) axis.
+ * Omit for single-axis charts. */
+ yAxes?: YAxisRenderConfig[]
+}
+
+/** Per-axis render config for a multi-axis (dual y-axis) chart. One entry per distinct
+ * {@link Series.yAxisId}; series resolve to their axis by id. Drives each axis's scale type,
+ * tick formatting, side, and label independently. */
+export interface YAxisRenderConfig {
+ /** Axis id — matches {@link Series.yAxisId}. The default-axis id is {@link DEFAULT_Y_AXIS_ID}. */
+ id: string
+ /** Which side this axis renders on. */
+ position: 'left' | 'right'
+ /** Scale type for this axis. Defaults to 'linear'. */
+ scaleType?: 'linear' | 'log'
+ /** Resolved tick formatter for this axis. When omitted, ticks auto-format against their values. */
+ tickFormatter?: (value: number) => string
+ /** Axis title. */
+ label?: string
}
/** Built-in legend config for the multi-series charts. The chart renders a {@link Legend} and,
diff --git a/packages/quill/packages/charts/src/index.ts b/packages/quill/packages/charts/src/index.ts
index 64f5c5a0e583..209931fb4b19 100644
--- a/packages/quill/packages/charts/src/index.ts
+++ b/packages/quill/packages/charts/src/index.ts
@@ -98,6 +98,7 @@ export type {
TooltipConfig,
TooltipContext,
ValueDomain,
+ YAxisRenderConfig,
YAxisScale,
} from './core/types'
export { DEFAULT_Y_AXIS_ID } from './core/types'
diff --git a/packages/quill/packages/charts/src/overlays/AxisLabels.tsx b/packages/quill/packages/charts/src/overlays/AxisLabels.tsx
index 7a76ea4ab3bb..56f0c62afa50 100644
--- a/packages/quill/packages/charts/src/overlays/AxisLabels.tsx
+++ b/packages/quill/packages/charts/src/overlays/AxisLabels.tsx
@@ -11,6 +11,9 @@ interface AxisLabelsProps {
/** The *unresolved* user y-tick formatter (config). When set, every stacked axis uses it; when
* unset, each axis auto-formats against its own ticks. Only consulted for the multi-axis path. */
userYTickFormatter?: (value: number) => string
+ /** Per-axis tick formatters keyed by axis id. A gutter prefers its own formatter, then
+ * `userYTickFormatter`, then auto-formats against its ticks. Only consulted for the multi-axis path. */
+ yAxisFormatters?: Record<string, (value: number) => string>
hideXAxis?: boolean
hideYAxis?: boolean
axisColor?: string
@@ -230,6 +233,7 @@ export const AxisLabels = React.memo(function AxisLabels({
xTickFormatter,
yTickFormatter,
userYTickFormatter,
+ yAxisFormatters,
hideXAxis,
hideYAxis,
axisColor = 'rgba(0, 0, 0, 0.5)',
@@ -268,7 +272,7 @@ export const AxisLabels = React.memo(function AxisLabels({
const gutters: Gutter[] = []
Object.entries(scales.yAxes).forEach(([axisId, axis]) => {
const ticks = axis.ticks()
- const formatter = userYTickFormatter ?? autoFormatterFor(ticks)
+ const formatter = yAxisFormatters?.[axisId] ?? userYTickFormatter ?? autoFormatterFor(ticks)
const offset = axis.position === 'left' ? leftCum : rightCum
gutters.push({ key: `y-${axisId}`, side: axis.position, offset, ticks, scale: axis.scale, formatter })
const width = widthOf(ticks, formatter) + GUTTER_GAP
@@ -279,7 +283,7 @@ export const AxisLabels = React.memo(function AxisLabels({
}
})
return gutters
- }, [hideYAxis, orientation, scales.yAxes, scales.y, yTicks, yTickFormatter, userYTickFormatter])
+ }, [hideYAxis, orientation, scales.yAxes, scales.y, yTicks, yTickFormatter, userYTickFormatter, yAxisFormatters])
const visibleXLabels = useMemo(
() =>
diff --git a/packages/quill/packages/charts/src/overlays/AxisTitles.tsx b/packages/quill/packages/charts/src/overlays/AxisTitles.tsx
index 083104b2c6a8..44f47f47541e 100644
--- a/packages/quill/packages/charts/src/overlays/AxisTitles.tsx
+++ b/packages/quill/packages/charts/src/overlays/AxisTitles.tsx
@@ -7,6 +7,8 @@ import { AXIS_LABEL_FONT, measureLabelWidth } from '../utils/text-measure'
export interface AxisTitlesProps {
xAxisLabel?: string
yAxisLabel?: string
+ /** Title for the right-side y-axis on a dual-axis chart. */
+ yAxisLabelRight?: string
hideXAxis?: boolean
hideYAxis?: boolean
axisColor: string
@@ -68,6 +70,7 @@ function truncateAxisTitle(label: string, maxWidth: number): string {
export function AxisTitles({
xAxisLabel,
yAxisLabel,
+ yAxisLabelRight,
hideXAxis,
hideYAxis,
axisColor,
@@ -75,22 +78,28 @@ export function AxisTitles({
const { dimensions } = useChartLayout()
const fullXAxisLabel = normalizeAxisLabel(xAxisLabel)
const fullYAxisLabel = normalizeAxisLabel(yAxisLabel)
+ const fullYAxisLabelRight = normalizeAxisLabel(yAxisLabelRight)
const showXAxisTitle = !hideXAxis && !!fullXAxisLabel
const showYAxisTitle = !hideYAxis && !!fullYAxisLabel
+ const showYAxisTitleRight = !hideYAxis && !!fullYAxisLabelRight
- if (!showXAxisTitle && !showYAxisTitle) {
+ if (!showXAxisTitle && !showYAxisTitle && !showYAxisTitleRight) {
return null
}
const xCenter = dimensions.plotLeft + dimensions.plotWidth / 2
const xBaseline = dimensions.height - X_AXIS_TITLE_BASELINE_OFFSET
const yCenter = dimensions.plotTop + dimensions.plotHeight / 2
+ const rightTitleX = dimensions.width - Y_AXIS_TITLE_X
const xTitle = fullXAxisLabel
? truncateAxisTitle(fullXAxisLabel, Math.max(0, dimensions.plotWidth - TITLE_EDGE_PADDING * 2))
: undefined
const yTitle = fullYAxisLabel
? truncateAxisTitle(fullYAxisLabel, Math.max(0, dimensions.plotHeight - TITLE_EDGE_PADDING * 2))
: undefined
+ const yTitleRight = fullYAxisLabelRight
+ ? truncateAxisTitle(fullYAxisLabelRight, Math.max(0, dimensions.plotHeight - TITLE_EDGE_PADDING * 2))
+ : undefined
return (
<svg aria-hidden="true" style={SVG_STYLE}>
@@ -122,6 +131,21 @@ export function AxisTitles({
{yTitle}
</text>
)}
+ {showYAxisTitleRight && yTitleRight && (
+ <text
+ data-attr="hog-chart-axis-title-yr"
+ data-full-label={fullYAxisLabelRight}
+ x={rightTitleX}
+ y={yCenter}
+ fill={axisColor}
+ textAnchor="middle"
+ dominantBaseline="middle"
+ transform={`rotate(90 ${rightTitleX} ${yCenter})`}
+ style={AXIS_TITLE_STYLE}
+ >
+ {yTitleRight}
+ </text>
+ )}
</svg>
)
}
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 95c623e15ebb..241be30a888c 100644
--- a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
+++ b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
@@ -17,6 +17,12 @@ export interface XAxisConfig {
}
export interface YAxisConfig extends YFormatterConfig {
+ /** Axis id — matches `Series.yAxisId`. Only meaningful in the array (multi-axis) form; the
+ * first entry defaults to the primary axis id (`'left'`). */
+ id?: string
+ /** Which side this axis renders on. Only meaningful in the array (multi-axis) form; the first
+ * entry defaults to `'left'`, subsequent entries to `'right'`. */
+ position?: 'left' | 'right'
label?: string
scale?: 'linear' | 'log'
/** Custom tick formatter. When set, it wins over `format`. */
@@ -48,36 +54,40 @@ export function useXTickFormatter(
}, [xAxis?.tickFormatter, xAxis?.timezone, xAxis?.interval, effectiveAllDays])
}
+/** 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
+ * the per-axis resolution in multi-axis charts (where a hook can't run per array entry). */
+export function resolveYTickFormatter(yAxis: YAxisConfig | undefined): ((value: number) => string) | undefined {
+ if (yAxis?.tickFormatter) {
+ return yAxis.tickFormatter
+ }
+ if (
+ yAxis?.format === undefined &&
+ yAxis?.prefix === undefined &&
+ yAxis?.suffix === undefined &&
+ yAxis?.decimalPlaces === undefined &&
+ yAxis?.minDecimalPlaces === undefined &&
+ yAxis?.currency === undefined
+ ) {
+ return undefined
+ }
+ return buildYTickFormatter({
+ format: yAxis.format,
+ prefix: yAxis.prefix,
+ suffix: yAxis.suffix,
+ decimalPlaces: yAxis.decimalPlaces,
+ minDecimalPlaces: yAxis.minDecimalPlaces,
+ currency: yAxis.currency,
+ })
+}
+
export function useYTickFormatter(yAxis: YAxisConfig | undefined): ((value: number) => string) | undefined {
- return useMemo(() => {
- if (yAxis?.tickFormatter) {
- return yAxis.tickFormatter
- }
- if (
- yAxis?.format === undefined &&
- yAxis?.prefix === undefined &&
- yAxis?.suffix === undefined &&
- yAxis?.decimalPlaces === undefined &&
- yAxis?.minDecimalPlaces === undefined &&
- yAxis?.currency === undefined
- ) {
- return undefined
- }
- return buildYTickFormatter({
- format: yAxis.format,
- prefix: yAxis.prefix,
- suffix: yAxis.suffix,
- decimalPlaces: yAxis.decimalPlaces,
- minDecimalPlaces: yAxis.minDecimalPlaces,
- currency: yAxis.currency,
- })
- }, [
- yAxis?.tickFormatter,
- yAxis?.format,
- yAxis?.prefix,
- yAxis?.suffix,
- yAxis?.decimalPlaces,
- yAxis?.minDecimalPlaces,
- yAxis?.currency,
- ])
+ // Read the formatter-relevant fields here (not the whole object) so the memo stays stable across
+ // unrelated config-identity changes — the same field set forms the dependency array.
+ const { tickFormatter, format, prefix, suffix, decimalPlaces, minDecimalPlaces, currency } = yAxis ?? {}
+ return useMemo(
+ () => resolveYTickFormatter({ tickFormatter, format, prefix, suffix, decimalPlaces, minDecimalPlaces, currency }),
+ [tickFormatter, format, prefix, suffix, decimalPlaces, minDecimalPlaces, currency]
+ )
}
diff --git a/products/product_analytics/frontend/insights/retention/shared/retentionChartTransforms.test.ts b/products/product_analytics/frontend/insights/retention/shared/retentionChartTransforms.test.ts
index 1614cad06fe7..9cfe13d36496 100644
--- a/products/product_analytics/frontend/insights/retention/shared/retentionChartTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/retention/shared/retentionChartTransforms.test.ts
@@ -1,4 +1,4 @@
-import type { Series, TooltipConfig } from '@posthog/quill-charts'
+import type { Series, TooltipConfig, YAxisConfig } from '@posthog/quill-charts'
import type { RetentionTrendPayload } from 'scenes/retention/types'
@@ -330,9 +330,10 @@ describe('retentionChartTransforms', () => {
getColor: colorAt,
maxCohorts: 6,
})
- expect(model.lineConfig.yAxis?.label).toBe(expectedLabel)
+ const lineYAxis = model.lineConfig.yAxis as YAxisConfig
+ expect(lineYAxis?.label).toBe(expectedLabel)
expect(model.barConfig.yAxis?.label).toBe(expectedLabel)
- expect(model.lineConfig.yAxis?.format).toBe(expectedFormat)
+ expect(lineYAxis?.format).toBe(expectedFormat)
})
})
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.test.ts b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.test.ts
index 182594e036e2..afa9159646dd 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.test.ts
@@ -1,5 +1,5 @@
import { DEFAULT_Y_AXIS_ID } from '@posthog/quill-charts'
-import type { TooltipConfig } from '@posthog/quill-charts'
+import type { TooltipConfig, YAxisConfig } from '@posthog/quill-charts'
import { ChartDisplayType } from '~/types'
@@ -178,17 +178,19 @@ describe('stickinessChartTransforms', () => {
it('returns yAxis with percent tick formatter and a linear scale by default', () => {
const config = buildStickinessLineTimeSeriesConfig({})
- expect(config.yAxis).not.toBeUndefined()
- expect(config.yAxis!.scale).toBe('linear')
- expect(config.yAxis!.showGrid).toBe(true)
- expect(config.yAxis!.tickFormatter).not.toBeUndefined()
- expect(config.yAxis!.tickFormatter!(50)).toBe('50.0%')
+ const yAxis = config.yAxis as YAxisConfig
+ expect(yAxis).not.toBeUndefined()
+ expect(yAxis.scale).toBe('linear')
+ expect(yAxis.showGrid).toBe(true)
+ expect(yAxis.tickFormatter).not.toBeUndefined()
+ expect(yAxis.tickFormatter!(50)).toBe('50.0%')
})
it('switches the y-scale to log when yAxisScaleType is log10', () => {
const config = buildStickinessLineTimeSeriesConfig({ yAxisScaleType: 'log10' })
- expect(config.yAxis).not.toBeUndefined()
- expect(config.yAxis!.scale).toBe('log')
+ const yAxis = config.yAxis as YAxisConfig
+ expect(yAxis).not.toBeUndefined()
+ expect(yAxis.scale).toBe('log')
})
it('omits an xAxis date config — labels are pre-formatted interval counts', () => {
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/trendsChartTransforms.test.ts b/products/product_analytics/frontend/insights/trends/TrendsLineChart/trendsChartTransforms.test.ts
index 92bad10d51f6..5d363542fc95 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/trendsChartTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/trendsChartTransforms.test.ts
@@ -1,5 +1,5 @@
import { DEFAULT_Y_AXIS_ID } from '@posthog/quill-charts'
-import type { TooltipConfig } from '@posthog/quill-charts'
+import type { TooltipConfig, YAxisConfig } from '@posthog/quill-charts'
import { ciRanges } from 'lib/statistics'
@@ -470,7 +470,7 @@ describe('trendsChartTransforms', () => {
yAxisLabel: 'Unique users',
})
expect(config.xAxis?.label).toBe('Signup date')
- expect(config.yAxis?.label).toBe('Unique users')
+ expect((config.yAxis as YAxisConfig)?.label).toBe('Unique users')
})
it('derives yAxis from buildTrendsYAxisConfig when isPercentStackView is true and passes through tooltip / showCrosshair', () => {