: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(bi): calculate reference lines across chart groups (#115546)
Marius Andraca5a188bff59
diff --git a/docs/published/handbook/engineering/data-warehouse.md b/docs/published/handbook/engineering/data-warehouse.mdindex 8f6ef6eef435..368aeaa62034 100644--- a/docs/published/handbook/engineering/data-warehouse.md+++ b/docs/published/handbook/engineering/data-warehouse.md@@ -68,6 +68,8 @@ Direct connections group tables by schema. Search matches table and folder names## Calculated measures in BI mode+Chart settings offer **Reference lines** for BI line and bar charts. Add a constant target, or choose **Mean**, **Median**, **Minimum**, or **Maximum** across returned marks on the left axis. **Per series** calculates a separate reference for each color group or measure and includes its name in the label. Calculated lines update with the results, after aggregation and table calculations; they exclude missing values and respect result limits. They do not re-aggregate the underlying source rows or apply to the right axis. Calculated lines are hidden on 100% stacked charts, where constant percentage targets remain available.+The **Marks** card offers table calculations per measure: percent of total, running total, difference or percent change from the preceding point, trailing moving average, and rank. **Compute using** selects the dimension to traverse, with the date dimension chosen by default; other dimensions partition the calculation. Moving averages use a trailing window including the current point, in ascending order. Partial windows average available non-null values; **Require a full window** leaves the result empty until every point in the window has a value. Calculations run before the result limit, and zero denominators produce empty cells.**Analysis → Missing dates** defaults to **Observed points only**. **Show gaps** creates empty buckets that occupy a point in the window but do not contribute to an average. **Fill with zero** makes those buckets contribute zero. Filling runs before calculations, separately for each series and comparison period, across the selected date range. It requires one bucketed date dimension matching the worksheet date column and a bounded range. It is available for project and warehouse tables in tables and time-series charts; direct connections do not support it. Saved worksheets and dashboard date overrides retain these semantics.diff --git a/frontend/src/lib/components/GoalLinesList.tsx b/frontend/src/lib/components/GoalLinesList.tsxindex 4f99025f28b3..29cf3c59c1ea 100644--- a/frontend/src/lib/components/GoalLinesList.tsx+++ b/frontend/src/lib/components/GoalLinesList.tsx@@ -1,5 +1,12 @@import { IconGear, IconTrash } from '@posthog/icons'-import { LemonColorGlyph, LemonColorPicker, LemonLabel, LemonMenu, LemonSegmentedButton } from '@posthog/lemon-ui'+import {+ LemonColorGlyph,+ LemonColorPicker,+ LemonLabel,+ LemonMenu,+ LemonSegmentedButton,+ LemonSelect,+} from '@posthog/lemon-ui'import { getSeriesColorPalette } from 'lib/colors'import { LemonButton } from 'lib/lemon-ui/LemonButton'@@ -10,6 +17,8 @@ import { Tooltip } from 'lib/lemon-ui/Tooltip'import { GoalLine } from '~/queries/schema/schema-general'interface GoalLinesListProps {+ allowCalculations?: boolean+ calculationDisabledReason?: stringgoalLines: GoalLine[]updateGoalLine: (goalLineIndex: number,@@ -19,138 +28,199 @@ interface GoalLinesListProps {removeGoalLine: (goalLineIndex: number) => void}-export function GoalLinesList({ goalLines, updateGoalLine, removeGoalLine }: GoalLinesListProps): JSX.Element {+export function GoalLinesList({+ goalLines,+ updateGoalLine,+ removeGoalLine,+ allowCalculations = false,+ calculationDisabledReason,+}: GoalLinesListProps): JSX.Element {const seriesColor = getSeriesColorPalette()return (<>- {goalLines.map(({ label, value = 0, displayLabel = true, position, borderColor }, goalLineIndex) => {- return (- <div className="flex flex-1 gap-1 items-center mb-1.5" key={`${goalLineIndex}`}>- <LemonColorPicker- colors={seriesColor}- selectedColor={borderColor || undefined}- onSelectColor={(color) => updateGoalLine(goalLineIndex, 'borderColor', color)}- showCustomColor- customButton={- <div className="cursor-pointer">- <LemonColorGlyph color={borderColor} size="small" />+ {goalLines.map(+ (+ { label, value = 0, displayLabel = true, position, borderColor, calculation, scope },+ goalLineIndex+ ) => {+ return (+ <div key={goalLineIndex} className="mb-1.5">+ {allowCalculations && (+ <div className="flex flex-wrap gap-1 mb-1">+ <LemonSelect+ size="small"+ aria-label={`Reference line ${goalLineIndex + 1} calculation`}+ value={calculation ?? 'fixed'}+ onChange={(value) => updateGoalLine(goalLineIndex, 'calculation', value)}+ options={[+ { value: 'fixed', label: 'Constant' },+ { value: 'mean', label: 'Mean', disabledReason: calculationDisabledReason },+ {+ value: 'median',+ label: 'Median',+ disabledReason: calculationDisabledReason,+ },+ {+ value: 'min',+ label: 'Minimum',+ disabledReason: calculationDisabledReason,+ },+ {+ value: 'max',+ label: 'Maximum',+ disabledReason: calculationDisabledReason,+ },+ ]}+ />+ {calculation && calculation !== 'fixed' && (+ <LemonSelect+ size="small"+ aria-label={`Reference line ${goalLineIndex + 1} scope`}+ value={scope ?? 'all'}+ onChange={(value) => updateGoalLine(goalLineIndex, 'scope', value)}+ options={[+ { value: 'all', label: 'Across all series' },+ { value: 'series', label: 'Per series' },+ ]}+ />+ )}</div>- }- />- <LemonInput- placeholder="Label"- className="grow mx-0.5"- value={label}- onChange={(value) => updateGoalLine(goalLineIndex, 'label', value)}- />- <LemonInput- type="number"- step="any"- placeholder="Value"- className="w-25 mr-0.5"- value={value}- onChange={(value) =>- updateGoalLine(- goalLineIndex,- 'value',- value !== undefined && !Number.isNaN(value) ? value : 0- )- }- />- <LemonMenu- items={[- {- title: 'Label settings',- items: [- {- key: 'display-label',- label: () => (- <LemonSwitch- label="Show label"- className="pb-2"- fullWidth- checked={displayLabel}- onChange={(checked) =>- updateGoalLine(goalLineIndex, 'displayLabel', checked)- }- data-attr="goal-line-show-label-switch"- />- ),- },+ )}+ <div className="flex flex-1 flex-wrap gap-1 items-center">+ <LemonColorPicker+ colors={seriesColor}+ selectedColor={borderColor || undefined}+ onSelectColor={(color) => updateGoalLine(goalLineIndex, 'borderColor', color)}+ showCustomColor+ customButton={+ <div className="cursor-pointer">+ <LemonColorGlyph color={borderColor} size="small" />+ </div>+ }+ />+ <LemonInput+ placeholder="Label"+ className="grow mx-0.5"+ value={label}+ onChange={(value) => updateGoalLine(goalLineIndex, 'label', value)}+ />+ {(!allowCalculations || !calculation || calculation === 'fixed') && (+ <LemonInput+ type="number"+ step="any"+ placeholder="Value"+ className="w-25 mr-0.5"+ value={value}+ onChange={(value) =>+ updateGoalLine(+ goalLineIndex,+ 'value',+ value !== undefined && !Number.isNaN(value) ? value : 0+ )+ }+ />+ )}+ <LemonMenu+ items={[{- key: 'label-placement',- label: () => {- const disabledReason = displayLabel- ? undefined- : 'Enable the label to change its position first.'-- const label = (- <LemonLabel- className={`font-medium mr-1 ${displayLabel ? 'cursor-pointer' : 'cursor-not-allowed opacity-65'}`}- onClick={() =>- displayLabel- ? updateGoalLine(- goalLineIndex,- 'position',- position === 'start' ? 'end' : 'start'- )- : undefined- }- >- Label position- </LemonLabel>- )-- return (- <div className="flex gap-1 mx-2 mb-2">- {disabledReason ? (- <Tooltip title={disabledReason}>- <span>{label}</span>- </Tooltip>- ) : (- label- )}- <LemonSegmentedButton- value={position ?? 'end'}- onChange={(value) =>- updateGoalLine(- goalLineIndex,- 'position',- value as 'start' | 'end'- )+ title: 'Label settings',+ items: [+ {+ key: 'display-label',+ label: () => (+ <LemonSwitch+ label="Show label"+ className="pb-2"+ fullWidth+ checked={displayLabel}+ onChange={(checked) =>+ updateGoalLine(goalLineIndex, 'displayLabel', checked)}- options={[- { value: 'start', label: 'Start' },- { value: 'end', label: 'End' },- ]}- size="xsmall"- data-attr="goal-line-position-selector"- disabledReason={disabledReason}+ data-attr="goal-line-show-label-switch"/>- </div>- )- },+ ),+ },+ {+ key: 'label-placement',+ label: () => {+ const disabledReason = displayLabel+ ? undefined+ : 'Enable the label to change its position first.'++ const label = (+ <LemonLabel+ className={`font-medium mr-1 ${displayLabel ? 'cursor-pointer' : 'cursor-not-allowed opacity-65'}`}+ onClick={() =>+ displayLabel+ ? updateGoalLine(+ goalLineIndex,+ 'position',+ position === 'start' ? 'end' : 'start'+ )+ : undefined+ }+ >+ Label position+ </LemonLabel>+ )++ return (+ <div className="flex gap-1 mx-2 mb-2">+ {disabledReason ? (+ <Tooltip title={disabledReason}>+ <span>{label}</span>+ </Tooltip>+ ) : (+ label+ )}+ <LemonSegmentedButton+ value={position ?? 'end'}+ onChange={(value) =>+ updateGoalLine(+ goalLineIndex,+ 'position',+ value as 'start' | 'end'+ )+ }+ options={[+ { value: 'start', label: 'Start' },+ { value: 'end', label: 'End' },+ ]}+ size="xsmall"+ data-attr="goal-line-position-selector"+ disabledReason={disabledReason}+ />+ </div>+ )+ },+ },+ ],},- ],- },- ]}- placement="bottom-end"- closeOnClickInside={false}- >- <LemonButton icon={<IconGear />} title="Goal line settings" noPadding size="small" />- </LemonMenu>- <LemonButton- key="delete"- icon={<IconTrash />}- status="danger"- title="Delete goal line"- noPadding- size="small"- onClick={() => removeGoalLine(goalLineIndex)}- />- </div>- )- })}+ ]}+ placement="bottom-end"+ closeOnClickInside={false}+ >+ <LemonButton+ icon={<IconGear />}+ title="Goal line settings"+ noPadding+ size="small"+ />+ </LemonMenu>+ <LemonButton+ key="delete"+ icon={<IconTrash />}+ status="danger"+ title="Delete goal line"+ noPadding+ size="small"+ onClick={() => removeGoalLine(goalLineIndex)}+ />+ </div>+ </div>+ )+ }+ )}</>)}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsxindex c97b8db7c1ce..556afed78870 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx@@ -504,6 +504,11 @@ describe('SqlLineGraph', () => {],expectedLabels: ['Floor', 'Ceiling'],},+ {+ name: 'renders a calculated reference line for each series',+ goalLines: [{ label: 'Average', value: 0, calculation: 'mean' as const, scope: 'series' as const }],+ expectedLabels: ['Average · a'],+ },])('$name', async ({ goalLines, expectedLabels }) => {renderLine({ yAxis: [{ column: 'a' }], goalLines },diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.test.tsnew file mode 100644index 000000000000..46d6b0dc617c--- /dev/null+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.test.ts@@ -0,0 +1,43 @@+import type { Series } from '@posthog/quill-charts'++import { resolveSQLReferenceLines } from './sqlReferenceLines'++const series: Series[] = [+ { key: 'basic', label: 'Basic', data: [0, 10, NaN, 20] },+ { key: 'plus', label: 'Plus', data: [30, 50] },+ { key: 'right', label: 'Secondary axis', data: [1000], yAxisId: 'right' },+ { key: 'excluded', label: 'Excluded', data: [2000], visibility: { excluded: true } },+]++describe('resolveSQLReferenceLines', () => {+ it.each([+ ['mean', 22],+ ['median', 20],+ ['min', 0],+ ['max', 50],+ ] as const)('calculates %s from finite primary-axis marks, including zero', (calculation, expected) => {+ expect(resolveSQLReferenceLines([{ label: 'Reference', value: 999, calculation }], series)).toEqual([+ expect.objectContaining({ label: 'Reference', value: expected }),+ ])+ })++ it('calculates each group separately and leaves saved settings unchanged as results change', () => {+ const line = { label: 'Average', value: 999, calculation: 'mean' as const, scope: 'series' as const }+ expect(resolveSQLReferenceLines([line], series)).toEqual([+ { ...line, label: 'Average · Basic', value: 10 },+ { ...line, label: 'Average · Plus', value: 40 },+ ])+ expect(resolveSQLReferenceLines([line], [{ key: 'basic', label: 'Basic', data: [12, 18] }])).toEqual([+ { ...line, label: 'Average · Basic', value: 15 },+ ])+ expect(line.value).toBe(999)+ })++ it('keeps constant lines while omitting calculated lines without finite values', () => {+ const fixed = { label: 'Target', value: 50 }+ const mean = { label: 'Average', value: 0, calculation: 'mean' as const }+ expect(resolveSQLReferenceLines([fixed, mean], [])).toEqual([fixed])+ expect(resolveSQLReferenceLines([fixed, mean], series, true)).toEqual([fixed])+ expect(resolveSQLReferenceLines([mean], [{ key: 'empty', label: 'Empty', data: [NaN, Infinity] }])).toEqual([])+ })+})diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.tsnew file mode 100644index 000000000000..2ec67ab99c43--- /dev/null+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlReferenceLines.ts@@ -0,0 +1,39 @@+import { max, mean, median, min } from 'd3'++import type { Series } from '@posthog/quill-charts'++import type { GoalLine } from '~/queries/schema/schema-general'++export function resolveSQLReferenceLines(+ lines: GoalLine[] | undefined,+ series: Series[],+ isPercentStack = false+): GoalLine[] {+ const primarySeries = series.filter((item) => item.yAxisId !== 'right' && !item.visibility?.excluded)+ return (lines ?? []).flatMap((line) => {+ if (!line.calculation || line.calculation === 'fixed') {+ return [line]+ }+ if (isPercentStack) {+ return []+ }+ const calculate: (values: number[]) => number | undefined = { mean, median, min, max }[line.calculation]+ const groups = line.scope === 'series' ? primarySeries.map((item) => [item]) : [primarySeries]+ return groups.flatMap((group) => {+ const values = group.flatMap((item) => item.data).filter(Number.isFinite)+ const value = calculate(values)+ return value === undefined || !Number.isFinite(value)+ ? []+ : [+ {+ ...line,+ value,+ label:+ line.scope === 'series'+ ? [line.label, group[0].label].filter(Boolean).join(' · ')+ : line.label,+ },+ ]+ })+ })+}diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.tsindex 9343d8ef4d45..eb8919c508ae 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts@@ -24,6 +24,7 @@ import {exceedsMaxSeries,warnTooManySeries,} from './sqlLineGraphAdapter'+import { resolveSQLReferenceLines } from './sqlReferenceLines'export interface SqlChartModel<TConfig> {series: Series<SqlLineSeriesMeta>[]@@ -76,7 +77,11 @@ export function useSqlChartModel<xData,chartSettings,timezone,- goalLines,+ goalLines: resolveSQLReferenceLines(+ goalLines,+ series,+ visualizationType === ChartDisplayType.ActionsStackedBar && chartSettings.stackBars100+ ),visualizationType,ySeriesData,series,diff --git a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsxindex de20bd224e14..a15f1f6fe07e 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/DisplayTab.tsx@@ -64,7 +64,7 @@ const LINE_STYLE_OPTIONS: { value: 'smooth' | 'linear'; label: string }[] = [export const DisplayTab = (): JSX.Element => {const { effectiveVisualizationType, xData, yData, dataVisualizationProps } = useValues(dataVisualizationLogic)const { seriesBreakdownData } = useValues(seriesBreakdownLogic({ key: dataVisualizationProps.key }))- const { goalLines, chartSettings } = useValues(displayLogic)+ const { goalLines, chartSettings, query } = useValues(displayLogic)const { addGoalLine, updateGoalLine, removeGoalLine, updateChartSettings } = useActions(displayLogic)const isStackedBarChart = effectiveVisualizationType === ChartDisplayType.ActionsStackedBar@@ -527,7 +527,9 @@ export const DisplayTab = (): JSX.Element => {key: 'goals',header: (<div className="flex items-center gap-1 flex-1">- <span className="flex-1">Goals</span>+ <span className="flex-1">+ {query.kind === 'BIVisualizationNode' ? 'Reference lines' : 'Goals'}+ </span>{goalLines.length > 0 && (<LemonBadge.Number status="muted" size="small" count={goalLines.length} />)}@@ -537,6 +539,12 @@ export const DisplayTab = (): JSX.Element => {content: (<><GoalLinesList+ allowCalculations={query.kind === 'BIVisualizationNode'}+ calculationDisabledReason={+ isStackedBarChart && chartSettings.stackBars100+ ? 'Calculated lines are hidden on 100% stacked charts. Use a constant or turn off percentage stacking.'+ : undefined+ }goalLines={goalLines}removeGoalLine={removeGoalLine}updateGoalLine={updateGoalLine}@@ -547,8 +555,20 @@ export const DisplayTab = (): JSX.Element => {icon={<IconPlusSmall />}fullWidth>- Add goal line+ {query.kind === 'BIVisualizationNode'+ ? 'Add reference line'+ : 'Add goal line'}</LemonButton>+ {query.kind === 'BIVisualizationNode' && (+ <p className="text-xs text-secondary mt-2 mb-0">+ Calculations use returned marks on the left axis after aggregation and+ table calculations. Per series adds a line for each color group or+ measure. Result limits apply.+ {isStackedBarChart && chartSettings.stackBars100 && (+ <span> Calculated lines are hidden on 100% stacked charts.</span>+ )}+ </p>+ )}</>),}diff --git a/frontend/src/queries/nodes/DataVisualization/displayLogic.ts b/frontend/src/queries/nodes/DataVisualization/displayLogic.tsindex 3b469160349d..91cfdfad8cff 100644--- a/frontend/src/queries/nodes/DataVisualization/displayLogic.ts+++ b/frontend/src/queries/nodes/DataVisualization/displayLogic.ts@@ -32,6 +32,7 @@ export interface displayLogicActions {settings: ChartSettings} // dataVisualizationLogicaddGoalLine: () => {+ label: stringyData: AxisSeries<number | null>[]}removeGoalLine: (goalLineIndex: number) => {@@ -72,7 +73,10 @@ export const displayLogic = kea<displayLogicType>([actions: [dataVisualizationLogic, ['setQuery', 'updateChartSettings', '_setQuery']],})),actions(({ values }) => ({- addGoalLine: () => ({ yData: values.yData }),+ addGoalLine: () => ({+ yData: values.yData,+ label: values.query.kind === 'BIVisualizationNode' ? 'Reference' : 'Q4 Goal',+ }),updateGoalLine: (goalLineIndex: number, key: string, value: string | number | boolean) => ({goalLineIndex,key,@@ -85,7 +89,7 @@ export const displayLogic = kea<displayLogicType>([goalLines: [[] as GoalLine[],{- addGoalLine: (state, { yData }) => {+ addGoalLine: (state, { yData, label }) => {const yDataFlat =yData?.flatMap((n) => n.data).filter((value): value is number => value !== null) ?? []const yDataAvg = Math.round(d3.mean(yDataFlat) ?? 0)@@ -93,7 +97,7 @@ export const displayLogic = kea<displayLogicType>([return [...state,{- label: 'Q4 Goal',+ label,value: yDataAvg ?? 0,displayLabel: true,},diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 5dd5cc56e05e..452cba91332d 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -29244,6 +29244,11 @@"borderColor": {"type": "string"},+ "calculation": {+ "description": "Recalculate from returned chart marks. An absent calculation uses the fixed value.",+ "enum": ["fixed", "mean", "median", "min", "max"],+ "type": "string"+ },"displayIfCrossed": {"type": "boolean"},@@ -29257,6 +29262,11 @@"enum": ["start", "end"],"type": "string"},+ "scope": {+ "description": "SQL chart calculations use the primary axis, across all series or separately per series.",+ "enum": ["all", "series"],+ "type": "string"+ },"value": {"type": "number"}diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 62d81afb8510..91f7aa4bdbe8 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -1433,6 +1433,10 @@ export interface GoalLine {displayLabel?: booleandisplayIfCrossed?: booleanposition?: 'start' | 'end'+ /** Recalculate from returned chart marks. An absent calculation uses the fixed value. */+ calculation?: 'fixed' | 'mean' | 'median' | 'min' | 'max'+ /** SQL chart calculations use the primary axis, across all series or separately per series. */+ scope?: 'all' | 'series'}export interface ChartAxis {diff --git a/posthog/schema.py b/posthog/schema.pyindex 21688d4b0406..164d5f8144be 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -72,6 +72,7 @@ from posthog.schema_enums import (Breakdown1 as Breakdown1,BreakdownAttributionType as BreakdownAttributionType,BreakdownType as BreakdownType,+ Calculation as Calculation,CalendarHeatmapMathType as CalendarHeatmapMathType,ChartDisplayCategory as ChartDisplayCategory,ChartDisplayType as ChartDisplayType,@@ -277,6 +278,7 @@ from posthog.schema_enums import (RetentionType as RetentionType,RoktAdsDefaultSources as RoktAdsDefaultSources,Scale as Scale,+ Scope as Scope,SeriesColorMode as SeriesColorMode,SessionAttributionGroupBy as SessionAttributionGroupBy,SessionsV2JoinMode as SessionsV2JoinMode,@@ -1817,10 +1819,18 @@ class GoalLine(BaseModel):extra="forbid",)borderColor: str | None = None+ calculation: Calculation | None = Field(+ default=None,+ description=("Recalculate from returned chart marks. An absent calculation uses the fixed value."),+ )displayIfCrossed: bool | None = NonedisplayLabel: bool | None = Nonelabel: strposition: Position | None = None+ scope: Scope | None = Field(+ default=None,+ description=("SQL chart calculations use the primary axis, across all series or separately per series."),+ )value: floatdiff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 734a80387a8f..fa51f0151aad 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -1664,11 +1664,24 @@ class FunnelVizType(StrEnum):FLOW = "flow"+class Calculation(StrEnum):+ FIXED = "fixed"+ MEAN = "mean"+ MEDIAN = "median"+ MIN = "min"+ MAX = "max"++class Position(StrEnum):START = "start"END = "end"+class Scope(StrEnum):+ ALL = "all"+ SERIES = "series"++class GoogleAdsDefaultSources(StrEnum):GOOGLE = "google"ADWORDS = "adwords"diff --git a/products/business_intelligence/frontend/biSceneLogic.test.ts b/products/business_intelligence/frontend/biSceneLogic.test.tsindex b3f4dec454ab..e1cdbb25916f 100644--- a/products/business_intelligence/frontend/biSceneLogic.test.ts+++ b/products/business_intelligence/frontend/biSceneLogic.test.ts@@ -227,6 +227,7 @@ describe('biSceneLogic', () => {it('saves the wrapper and reopens the insight without a draft or SQL editor', async () => {const node = worksheet()node.chartSettings!.yAxis![0].settings = { formatting: { prefix: '$', suffix: '' } }+ node.chartSettings!.goalLines = [{ label: 'Average', value: 0, calculation: 'mean', scope: 'series' }]logic.actions.restoreWorksheet(node)logic.actions.setName('Revenue worksheet')await expectLogic(logic, () => logic.actions.saveInsight()).toFinishAllListeners()@@ -243,6 +244,7 @@ describe('biSceneLogic', () => {await expectLogic(logic).toFinishAllListeners()expect(logic.values.worksheet.config).toEqual(config)expect(logic.values.worksheet.chartSettings?.yAxis?.[0].settings?.formatting?.prefix).toBe('$')+ expect(logic.values.worksheet.chartSettings?.goalLines).toEqual(node.chartSettings!.goalLines)expect(logic.values.hasUnsavedChanges).toBe(false)})diff --git a/products/customer_analytics/frontend/components/Accounts/AccountSessionReplays.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountSessionReplays.stories.tsxindex 7bc58887b6eb..9829c6104d0e 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountSessionReplays.stories.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountSessionReplays.stories.tsx@@ -1,6 +1,7 @@import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'import type { Meta, StoryObj } from '@storybook/react'+import { useValues } from 'kea'import { useEffect } from 'react'import { teamLogic } from 'scenes/teamLogic'@@ -42,7 +43,12 @@ const meta: Meta<typeof AccountSessionReplays> = {},decorators: [(Story, { parameters }) => {+ const { currentTeamLoading, customerAnalyticsConfig } = useValues(teamLogic)useEffect(() => {+ // A late bootstrap response would overwrite the story's account configuration.+ if (currentTeamLoading) {+ return+ }teamLogic.actions.loadCurrentTeamSuccess({...MOCK_DEFAULT_TEAM,customer_analytics_config: {@@ -50,7 +56,11 @@ const meta: Meta<typeof AccountSessionReplays> = {account_group_type_index: 0,},})- }, [])+ }, [currentTeamLoading])+ // Mount after configuration so the initial replay request cannot resolve to the setup state.+ if (currentTeamLoading || customerAnalyticsConfig.account_group_type_index !== 0) {+ return <></>+ }return (<div className={parameters.narrow ? 'w-128 p-2' : 'w-192 p-2'}><Story />diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex cb82e8761ce3..ab47d473bb6a 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2992,6 +2992,16 @@ export interface TrendsFormulaNodeApi {formula: string}+export type CalculationApi = (typeof CalculationApi)[keyof typeof CalculationApi]++export const CalculationApi = {+ Fixed: 'fixed',+ Mean: 'mean',+ Median: 'median',+ Min: 'min',+ Max: 'max',+} as const+export type PositionApi = (typeof PositionApi)[keyof typeof PositionApi]export const PositionApi = {@@ -2999,12 +3009,23 @@ export const PositionApi = {End: 'end',} as const+export type ScopeApi = (typeof ScopeApi)[keyof typeof ScopeApi]++export const ScopeApi = {+ All: 'all',+ Series: 'series',+} as const+export interface GoalLineApi {borderColor?: string | null+ /** Recalculate from returned chart marks. An absent calculation uses the fixed value. */+ calculation?: CalculationApi | nulldisplayIfCrossed?: boolean | nulldisplayLabel?: boolean | nulllabel: stringposition?: PositionApi | null+ /** SQL chart calculations use the primary axis, across all series or separately per series. */+ scope?: ScopeApi | nullvalue: number}diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 5162a4c404e0..95ec6fa92c8a 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1856,6 +1856,16 @@ export interface TrendsFormulaNodeApi {formula: string}+export type CalculationApi = (typeof CalculationApi)[keyof typeof CalculationApi]++export const CalculationApi = {+ Fixed: 'fixed',+ Mean: 'mean',+ Median: 'median',+ Min: 'min',+ Max: 'max',+} as const+export type PositionApi = (typeof PositionApi)[keyof typeof PositionApi]export const PositionApi = {@@ -1863,12 +1873,23 @@ export const PositionApi = {End: 'end',} as const+export type ScopeApi = (typeof ScopeApi)[keyof typeof ScopeApi]++export const ScopeApi = {+ All: 'all',+ Series: 'series',+} as const+export interface GoalLineApi {borderColor?: string | null+ /** Recalculate from returned chart marks. An absent calculation uses the fixed value. */+ calculation?: CalculationApi | nulldisplayIfCrossed?: boolean | nulldisplayLabel?: boolean | nulllabel: stringposition?: PositionApi | null+ /** SQL chart calculations use the primary axis, across all series or separately per series. */+ scope?: ScopeApi | nullvalue: number}diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 9e963a9841c1..58cd26ed800f 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -5313,6 +5313,17 @@ export namespace Schemas {formula: string;}+ export type Calculation = typeof Calculation[keyof typeof Calculation];+++ export const Calculation = {+ Fixed: 'fixed',+ Mean: 'mean',+ Median: 'median',+ Min: 'min',+ Max: 'max',+ } as const;+export type Position = typeof Position[keyof typeof Position];@@ -5321,12 +5332,24 @@ export namespace Schemas {End: 'end',} as const;+ export type Scope = typeof Scope[keyof typeof Scope];+++ export const Scope = {+ All: 'all',+ Series: 'series',+ } as const;+export interface GoalLine {borderColor?: string | null;+ /** Recalculate from returned chart marks. An absent calculation uses the fixed value. */+ calculation?: Calculation | null;displayIfCrossed?: boolean | null;displayLabel?: boolean | null;label: string;position?: Position | null;+ /** SQL chart calculations use the primary axis, across all series or separately per series. */+ scope?: Scope | null;value: number;}