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(data-viz): per-series total and value label settings on sql charts (#114931)

posthog[bot]48d9a58765ce
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
index 61192d3353d2..69943d1e74d4 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.tsx
@@ -24,6 +24,7 @@ import {
buildBarChartConfig,
buildBarValueChartConfig,
formatSqlSeriesValue,
+ hasValueLabels,
} from './sqlLineGraphAdapter'
import { useSqlChartModel } from './useSqlChartModel'
@@ -85,7 +86,7 @@ export const SqlBarGraph = (props: SqlChartProps): JSX.Element => {
>
<ReferenceLines lines={model.config.referenceLines ?? []} />
{props.children}
- {props.chartSettings.showValuesOnSeries && (
+ {hasValueLabels(props.chartSettings, props.yData) && (
<ValueLabels
valueFormatter={valueLabelFormatter}
position={props.chartSettings.valueLabelPosition}
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
index f86dcc8c6d18..34cd0d0c6210 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.test.ts
@@ -1,5 +1,6 @@
import {
MAX_CATEGORY_LABEL_WIDTH,
+ type Series,
type TooltipContext,
type TrendLineConfig,
type ValueLabelContext,
@@ -373,7 +374,30 @@ describe('sqlLineGraphAdapter', () => {
ChartDisplayType.ActionsLineGraph
)
expect(percent.visibility).toEqual({ total: false })
- expect(plain.visibility).toBeUndefined()
+ expect(plain.visibility).toEqual({})
+ })
+
+ it.each<[string, AxisSeries<number | null>['settings'], Series['visibility']]>([
+ ['keeps an excluded series out of the total', { display: { excludeFromTotal: true } }, { total: false }],
+ ['hides value labels for the series', { display: { valueLabels: 'hide' } }, { valueLabel: false }],
+ [
+ 'combines both flags',
+ { display: { excludeFromTotal: true, valueLabels: 'hide' } },
+ { total: false, valueLabel: false },
+ ],
+ ])('%s', (_name, settings, expected) => {
+ const [series] = buildSeries([ySeries('target', [5], settings)], ChartDisplayType.ActionsStackedBar, true)
+ expect(series.visibility).toEqual(expected)
+ })
+
+ it('labels only the series that opted in when the chart setting is off', () => {
+ const [bars, target] = buildSeries(
+ [ySeries('bars', [1]), ySeries('target', [5], { display: { valueLabels: 'show' } })],
+ ChartDisplayType.ActionsStackedBar,
+ false
+ )
+ expect(bars.visibility).toEqual({ valueLabel: false })
+ expect(target.visibility).toEqual({})
})
it('only pins an explicit color, leaving palette assignment to quill otherwise', () => {
@@ -621,6 +645,14 @@ describe('sqlLineGraphAdapter', () => {
])
expect(config.totalFormatter!(15059)).toBe('$15059')
})
+
+ it('formats the total with the first column in the sum, skipping an excluded column', () => {
+ const config = buildSqlTooltipConfig({}, [
+ ySeries('target', [1], { display: { excludeFromTotal: true }, formatting: { suffix: ' goal' } }),
+ ySeries('revenue', [1], { formatting: { prefix: '$' } }),
+ ])
+ expect(config.totalFormatter!(15059)).toBe('$15059')
+ })
})
describe('buildLineChartConfig', () => {
@@ -816,9 +848,12 @@ describe('sqlLineGraphAdapter', () => {
expect(config.goalLines?.[0]).toMatchObject({ value: 100, label: 'Target' })
})
- it('omits value labels unless showValuesOnSeries is set', () => {
- const config = buildLineChartConfig({ xData: dateXData, chartSettings: {}, timezone: 'UTC' })
- expect(config.valueLabels).toBeUndefined()
+ it.each<[string, SqlLineYSeries[] | undefined, boolean]>([
+ ['no series opts in', [ySeries('a', [1])], false],
+ ['a series opts in', [ySeries('a', [1], { display: { valueLabels: 'show' } })], true],
+ ])('with showValuesOnSeries off, builds value labels only when %s', (_name, ySeriesData, enabled) => {
+ const config = buildLineChartConfig({ xData: dateXData, chartSettings: {}, timezone: 'UTC', ySeriesData })
+ expect(config.valueLabels !== undefined).toBe(enabled)
})
it('formats each value label from its own series column when showValuesOnSeries is set', () => {
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
index b6be54278d16..5a9fac208c67 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/sqlLineGraphAdapter.ts
@@ -244,11 +244,31 @@ export interface SqlLineSeriesMeta {
settings?: AxisSeriesSettings
}
-export function buildSeries(yData: SqlLineYSeries[], visualizationType: ChartDisplayType): Series<SqlLineSeriesMeta>[] {
+// A percent column doesn't sum meaningfully with the other columns.
+const isExcludedFromTotal = (settings: AxisSeriesSettings | undefined): boolean =>
+ settings?.formatting?.style === 'percent' || !!settings?.display?.excludeFromTotal
+
+const optsIntoValueLabels = (series: SqlLineYSeries): boolean => series.settings?.display?.valueLabels === 'show'
+
+export function hasValueLabels(
+ chartSettings: ChartSettings,
+ ySeriesData: SqlLineYSeries[] | null | undefined
+): boolean {
+ return !!chartSettings.showValuesOnSeries || !!ySeriesData?.some(optsIntoValueLabels)
+}
+
+export function buildSeries(
+ yData: SqlLineYSeries[],
+ visualizationType: ChartDisplayType,
+ showValuesOnSeries = false
+): Series<SqlLineSeriesMeta>[] {
+ const onlyOptedIn = !showValuesOnSeries && yData.some(optsIntoValueLabels)
return yData.map((series, index) => {
const settings = series.settings
const color = settings?.display?.color
const type = seriesDisplayType(visualizationType, settings)
+ const valueLabels = settings?.display?.valueLabels
+ const hideValueLabel = valueLabels === 'hide' || (onlyOptedIn && valueLabels !== 'show')
return {
key: getSeriesKey(series, index),
@@ -258,9 +278,10 @@ export function buildSeries(yData: SqlLineYSeries[], visualizationType: ChartDis
meta: { settings },
// Per-series type; ignored by the single-type line/bar charts, read by ComboChart.
type,
- // A percent-styled column doesn't sum meaningfully with the other columns, so keep it
- // out of the tooltip's total row (matches the legacy renderer).
- ...(settings?.formatting?.style === 'percent' ? { visibility: { total: false } } : {}),
+ visibility: {
+ total: isExcludedFromTotal(settings) ? false : undefined,
+ valueLabel: hideValueLabel ? false : undefined,
+ },
// Only pin an explicit color; otherwise let quill assign palette colors by index.
...(color ? { color } : {}),
...(visualizationType !== ChartDisplayType.ActionsBarValue && settings?.display?.yAxisPosition === 'right'
@@ -319,11 +340,11 @@ export function buildSqlTooltipConfig(
chartSettings: ChartSettings,
ySeriesData?: SqlLineYSeries[] | null
): TooltipConfig {
- // The total sums the non-percent columns (percent columns are excluded via
- // `visibility.total` in buildSeries), so it must format with a column that's actually in the
- // sum — a blind `[0]` borrows a percent column's style and renders a sum of counts as
- // "15,061.4%". Matches the legacy renderer's first-summable-column choice.
- const totalSettings = ySeriesData?.find((series) => series.settings?.formatting?.style !== 'percent')?.settings
+ // The total sums only the columns buildSeries keeps in it (via `visibility.total`), so it must
+ // format with a column that's actually in the sum — a blind `[0]` borrows a percent column's
+ // style and renders a sum of counts as "15,061.4%". Matches the legacy renderer's
+ // first-summable-column choice.
+ const totalSettings = ySeriesData?.find((series) => !isExcludedFromTotal(series.settings))?.settings
return {
enabled: true,
pinnable: true,
@@ -465,7 +486,7 @@ function buildValueLabelsConfig(
chartSettings: ChartSettings,
ySeriesData: SqlLineYSeries[] | null | undefined
): ValueLabelsConfig | undefined {
- if (!chartSettings.showValuesOnSeries) {
+ if (!hasValueLabels(chartSettings, ySeriesData)) {
return undefined
}
return {
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
index 0f7efaa893ef..53c76a866579 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/useSqlChartModel.ts
@@ -73,8 +73,8 @@ export function useSqlChartModel<
const ySeriesData = useMemo(() => capYSeriesData(yData), [yData])
const series = useMemo(
- () => (ySeriesData ? buildSeries(ySeriesData, visualizationType) : []),
- [ySeriesData, visualizationType]
+ () => (ySeriesData ? buildSeries(ySeriesData, visualizationType, chartSettings.showValuesOnSeries) : []),
+ [ySeriesData, visualizationType, chartSettings.showValuesOnSeries]
)
const theme = useChartTheme()
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.test.tsx
index ab2a45819059..020b279096d8 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.test.tsx
@@ -11,7 +11,7 @@ import { ChartDisplayType } from '~/types'
import { dataNodeLogic } from '../../DataNode/dataNodeLogic'
import { DataVisualizationLogicProps, dataVisualizationLogic } from '../dataVisualizationLogic'
import { SeriesTab, YSeriesDisplayTab, YSeriesFormattingTab } from './SeriesTab'
-import { YSeriesLogicProps } from './ySeriesLogic'
+import { YSeriesLogicProps, ySeriesLogic } from './ySeriesLogic'
const renderPartOfWholeSeriesTab = (
display: ChartDisplayType,
@@ -329,5 +329,12 @@ describe('SeriesTab', () => {
})
)
)
+
+ setQuery.mockClear()
+ ySeriesLogic(ySeriesLogicProps).actions.submitDisplay()
+ await waitFor(() => expect(setQuery).toHaveBeenCalled())
+ const savedDisplay = setQuery.mock.lastCall[0].chartSettings.yAxis[0].settings.display
+ expect(savedDisplay).not.toHaveProperty('excludeFromTotal')
+ expect(savedDisplay).not.toHaveProperty('valueLabels')
})
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
index 92a92108ff73..1097e99155ef 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/SeriesTab.tsx
@@ -517,7 +517,8 @@ export const YSeriesFormattingTab = ({ ySeriesLogicProps }: { ySeriesLogicProps:
}
export const YSeriesDisplayTab = ({ ySeriesLogicProps }: { ySeriesLogicProps: YSeriesLogicProps }): JSX.Element => {
- const { showTableSettings, dataVisualizationProps, effectiveVisualizationType } = useValues(dataVisualizationLogic)
+ const { showTableSettings, dataVisualizationProps, effectiveVisualizationType, chartSettings } =
+ useValues(dataVisualizationLogic)
const { selectedSeriesBreakdownColumn } = useValues(seriesBreakdownLogic({ key: dataVisualizationProps.key }))
const { updateSeriesIndex } = useActions(dataVisualizationLogic)
@@ -529,6 +530,34 @@ export const YSeriesDisplayTab = ({ ySeriesLogicProps }: { ySeriesLogicProps: YS
effectiveVisualizationType === ChartDisplayType.ScatterPlot
const showColorPicker = !showTableSettings && !selectedSeriesBreakdownColumn
const showLabelInput = showTableSettings || !selectedSeriesBreakdownColumn
+ const isPercentColumn = ySeriesLogicProps.series.settings?.formatting?.style === 'percent'
+ const seriesSwitches: {
+ name: 'trendLine' | 'excludeFromTotal'
+ label: string
+ info?: string
+ disabledReason?: string
+ checked?: boolean
+ }[] = [
+ { name: 'trendLine', label: 'Trend line' },
+ {
+ name: 'excludeFromTotal',
+ label: 'Exclude from total row',
+ info:
+ effectiveVisualizationType === ChartDisplayType.ActionsStackedBar
+ ? 'A bar still stacks with the other bars. Set the display type to line to draw it over the stack.'
+ : undefined,
+ disabledReason:
+ chartSettings.showTotalRow === false
+ ? 'Turn on "Show total row" to use this'
+ : isPercentColumn
+ ? 'Percent columns are always left out of the total row'
+ : undefined,
+ checked: isPercentColumn || undefined,
+ },
+ ]
+ const valueLabelsInfo = chartSettings.showValuesOnSeries
+ ? 'Auto shows values, because "Show values on series" is on for the chart.'
+ : 'Auto hides values, because "Show values on series" is off for the chart.'
return (
<Form logic={ySeriesLogic} props={ySeriesLogicProps} formKey="display" className="deprecated-space-y-4">
@@ -585,27 +614,25 @@ export const YSeriesDisplayTab = ({ ySeriesLogicProps }: { ySeriesLogicProps: YS
)}
{!showTableSettings && !hideChartSpecificOptions && (
<>
- {!selectedSeriesBreakdownColumn && (
- <LemonField name="trendLine" label="Trend line">
- {({ value, onChange }) => (
- <LemonSwitch
- checked={value}
- onChange={(newValue) => {
- onChange(newValue)
- updateSeriesIndex(
- ySeriesLogicProps.seriesIndex,
- ySeriesLogicProps.series.column.name,
- {
- display: {
- trendLine: newValue,
- },
- }
- )
- }}
- />
- )}
- </LemonField>
- )}
+ {!selectedSeriesBreakdownColumn &&
+ seriesSwitches.map(({ name, label, info, disabledReason, checked }) => (
+ <LemonField key={name} name={name} label={label} info={info}>
+ {({ value, onChange }) => (
+ <LemonSwitch
+ checked={checked ?? value}
+ disabledReason={disabledReason}
+ onChange={(newValue) => {
+ onChange(newValue)
+ updateSeriesIndex(
+ ySeriesLogicProps.seriesIndex,
+ ySeriesLogicProps.series.column.name,
+ { display: { [name]: newValue } }
+ )
+ }}
+ />
+ )}
+ </LemonField>
+ ))}
<LemonField name="yAxisPosition" label="Y-axis position">
{({ value, onChange }) => (
<LemonSegmentedButton
@@ -674,6 +701,29 @@ export const YSeriesDisplayTab = ({ ySeriesLogicProps }: { ySeriesLogicProps: YS
/>
)}
</LemonField>
+ {!selectedSeriesBreakdownColumn && (
+ <LemonField name="valueLabels" label="Values on series" info={valueLabelsInfo}>
+ {({ value, onChange }) => (
+ <LemonSegmentedButton
+ value={value}
+ className="w-full"
+ options={[
+ { label: 'Auto', value: 'auto' },
+ { label: 'Show', value: 'show' },
+ { label: 'Hide', value: 'hide' },
+ ]}
+ onChange={(newValue) => {
+ onChange(newValue)
+ updateSeriesIndex(
+ ySeriesLogicProps.seriesIndex,
+ ySeriesLogicProps.series.column.name,
+ { display: { valueLabels: newValue as 'auto' | 'show' | 'hide' } }
+ )
+ }}
+ />
+ )}
+ </LemonField>
+ )}
</>
)}
</Form>
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/ySeriesLogic.ts b/frontend/src/queries/nodes/DataVisualization/Components/ySeriesLogic.ts
index 2eb00777cd60..7b1323d13aa5 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/ySeriesLogic.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/ySeriesLogic.ts
@@ -30,8 +30,10 @@ export interface ySeriesLogicValues {
display: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}
displayAllErrors: Record<string, any>
@@ -40,8 +42,10 @@ export interface ySeriesLogicValues {
{
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
},
ValidationErrorType
@@ -54,8 +58,10 @@ export interface ySeriesLogicValues {
{
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
},
ValidationErrorType
@@ -113,15 +119,19 @@ export interface ySeriesLogicActions {
resetDisplay: (values?: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}) => {
values?: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}
}
@@ -152,16 +162,20 @@ export interface ySeriesLogicActions {
values: DeepPartial<{
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}>
) => {
values: DeepPartial<{
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}>
}
@@ -209,30 +223,38 @@ export interface ySeriesLogicActions {
submitDisplayRequest: (display: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}) => {
display: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}
}
submitDisplaySuccess: (display: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}) => {
display: {
color: string
displayType: 'area' | 'auto' | 'bar' | 'line'
+ excludeFromTotal: boolean
label: string
trendLine: boolean
+ valueLabels: 'auto' | 'hide' | 'show'
yAxisPosition: 'left' | 'right'
}
}
@@ -353,15 +375,24 @@ export const ySeriesLogic = kea<ySeriesLogicType>([
color: props.series?.settings?.display?.color ?? getSeriesColor(props.seriesIndex),
label: props.series?.settings?.display?.label ?? '',
trendLine: props.series?.settings?.display?.trendLine ?? false,
+ excludeFromTotal: props.series?.settings?.display?.excludeFromTotal ?? false,
+ valueLabels: props.series?.settings?.display?.valueLabels ?? 'auto',
yAxisPosition: props.series?.settings?.display?.yAxisPosition ?? 'left',
displayType: props.series?.settings?.display?.displayType ?? 'auto',
},
submit: async (display) => {
+ const savedDisplay = props.series.settings?.display
actions.updateSeriesIndex(props.seriesIndex, props.series.column.name, {
display: {
color: display.color,
label: display.label,
trendLine: display.trendLine,
+ ...(display.excludeFromTotal || savedDisplay?.excludeFromTotal !== undefined
+ ? { excludeFromTotal: display.excludeFromTotal }
+ : {}),
+ ...(display.valueLabels !== 'auto' || savedDisplay?.valueLabels !== undefined
+ ? { valueLabels: display.valueLabels }
+ : {}),
yAxisPosition: display.yAxisPosition,
displayType: display.displayType,
},
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 466a98105dd8..b8891c646b9e 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -2635,6 +2635,10 @@
"enum": ["auto", "line", "bar", "area"],
"type": "string"
},
+ "excludeFromTotal": {
+ "description": "Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. A bar series still stacks, so set `displayType` to `line` for a series drawn over the stack.",
+ "type": "boolean"
+ },
"label": {
"description": "Series label in legends and tooltips; replaces the column name.",
"type": "string"
@@ -2643,6 +2647,11 @@
"description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
"type": "boolean"
},
+ "valueLabels": {
+ "description": "Per-series override of chart-level `showValuesOnSeries`. `show` labels this series even when the chart setting is off, `hide` leaves it unlabeled when the setting is on, `auto` follows the chart.",
+ "enum": ["auto", "show", "hide"],
+ "type": "string"
+ },
"yAxisPosition": {
"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
"enum": ["left", "right"],
@@ -2791,7 +2800,7 @@
"type": "boolean"
},
"xAxis": {
- "$ref": "#/definitions/AssistantDataVisualizationAxis",
+ "$ref": "#/definitions/AssistantDataVisualizationColumn",
"description": "Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot` plots two measures against each other, so it needs a numeric column here too."
},
"xAxisLabel": {
@@ -2808,6 +2817,32 @@
},
"type": "object"
},
+ "AssistantDataVisualizationColumn": {
+ "additionalProperties": false,
+ "description": "A column with number formatting only. Series display settings apply only to Y-axis series.",
+ "properties": {
+ "column": {
+ "description": "Name of a column returned by the SQL query.",
+ "type": "string"
+ },
+ "settings": {
+ "$ref": "#/definitions/AssistantDataVisualizationColumnSettings",
+ "description": "Optional number formatting for this column."
+ }
+ },
+ "required": ["column"],
+ "type": "object"
+ },
+ "AssistantDataVisualizationColumnSettings": {
+ "additionalProperties": false,
+ "properties": {
+ "formatting": {
+ "$ref": "#/definitions/AssistantDataVisualizationAxisFormatting",
+ "description": "Number-formatting settings for the values in this column."
+ }
+ },
+ "type": "object"
+ },
"AssistantDataVisualizationDisplayType": {
"description": "Subset of `ChartDisplayType` values supported by `AssistantDataVisualizationNode`.\n\n- `ActionsTable` — render rows as a data table. This is the default when `display` is omitted.\n- `BoldNumber` — big-number display for single-value results (first numeric column of the first row).\n- `Metric` — big number with a change pill and a sparkline (a KPI or scorecard). Uses the first numeric Y column, one value per row.\n- `ActionsLineGraph` — line chart. Requires at least two columns, including one numeric column.\n- `ActionsBar` — bar chart with one bar per X-axis value.\n- `ActionsBarValue` — horizontal bar chart (bar ranking) with one bar per category. Requires a category column and a numeric column.\n- `ActionsPie` — pie chart for categorical proportions. Requires one label column and one numeric column.\n- `ActionsDonut` — donut (ring) chart with the total in the center. Same columns as `ActionsPie`.\n- `ActionsProportionBar` — one flat bar that shows the parts of one whole, one segment per label. Same columns as `ActionsPie`.\n- `ActionsStackedBar` — bar chart stacked by a series breakdown column.\n- `ActionsAreaGraph` — area chart. Requires at least two columns, including one numeric column.\n- `TwoDimensionalHeatmap` — 2D heatmap. Requires an X column, a Y column, and a numeric value column.\n- `ScatterPlot` — scatter plot of one measure against another. Requires two numeric columns, one per axis.\n- `BoxPlot` — box plot from pre-aggregated SQL rows. Requires six numeric summary columns.",
"enum": [
@@ -2890,7 +2925,7 @@
"columns": {
"description": "Columns to display and their order. Omit to show every column returned by the query.",
"items": {
- "$ref": "#/definitions/AssistantDataVisualizationAxis"
+ "$ref": "#/definitions/AssistantDataVisualizationColumn"
},
"type": "array"
},
@@ -18102,12 +18137,21 @@
"enum": ["auto", "line", "bar", "area"],
"type": "string"
},
+ "excludeFromTotal": {
+ "description": "Keep this series out of the tooltip's total row, e.g. a target line over stacked bars.",
+ "type": "boolean"
+ },
"label": {
"type": "string"
},
"trendLine": {
"type": "boolean"
},
+ "valueLabels": {
+ "description": "Overrides the chart's \"Show values on series\" for this series. Unset or 'auto' follows the chart setting.",
+ "enum": ["auto", "show", "hide"],
+ "type": "string"
+ },
"yAxisPosition": {
"enum": ["left", "right"],
"type": "string"
diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.ts
index 88db8ade0711..bf22de37a4de 100644
--- a/frontend/src/queries/schema/schema-assistant-queries.ts
+++ b/frontend/src/queries/schema/schema-assistant-queries.ts
@@ -1893,6 +1893,16 @@ export interface AssistantDataVisualizationAxisDisplaySettings {
label?: string
/** Custom color for this series as a hex string (e.g. `#1d4aff`). */
color?: string
+ /**
+ * Keep this series out of the tooltip's total row, e.g. a target line over stacked bars.
+ * A bar series still stacks, so set `displayType` to `line` for a series drawn over the stack.
+ */
+ excludeFromTotal?: boolean
+ /**
+ * Per-series override of chart-level `showValuesOnSeries`. `show` labels this series even when the
+ * chart setting is off, `hide` leaves it unlabeled when the setting is on, `auto` follows the chart.
+ */
+ valueLabels?: 'auto' | 'show' | 'hide'
}
export interface AssistantDataVisualizationAxisFormatting {
@@ -1923,6 +1933,19 @@ export interface AssistantDataVisualizationAxis {
settings?: AssistantDataVisualizationAxisSettings
}
+export interface AssistantDataVisualizationColumnSettings {
+ /** Number-formatting settings for the values in this column. */
+ formatting?: AssistantDataVisualizationAxisFormatting
+}
+
+/** A column with number formatting only. Series display settings apply only to Y-axis series. */
+export interface AssistantDataVisualizationColumn {
+ /** Name of a column returned by the SQL query. */
+ column: string
+ /** Optional number formatting for this column. */
+ settings?: AssistantDataVisualizationColumnSettings
+}
+
export interface AssistantDataVisualizationGoalLine {
/** Label rendered next to the goal line. */
label: string
@@ -1974,7 +1997,7 @@ export interface AssistantDataVisualizationChartSettings {
* Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot`
* plots two measures against each other, so it needs a numeric column here too.
*/
- xAxis?: AssistantDataVisualizationAxis
+ xAxis?: AssistantDataVisualizationColumn
/** Label rendered under the X axis. */
xAxisLabel?: string
/** One or more numeric columns plotted as Y series. */
@@ -2013,7 +2036,7 @@ export interface AssistantDataVisualizationChartSettings {
export interface AssistantDataVisualizationTableSettings {
/** Columns to display and their order. Omit to show every column returned by the query. */
- columns?: AssistantDataVisualizationAxis[]
+ columns?: AssistantDataVisualizationColumn[]
/** Column names to pin to the left of the table. */
pinnedColumns?: string[]
/** Transpose rows and columns. */
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index dee73bd23e5b..97a4b3b534f4 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -1477,6 +1477,10 @@ export interface ChartSettingsDisplay {
trendLine?: boolean
yAxisPosition?: 'left' | 'right'
displayType?: 'auto' | 'line' | 'bar' | 'area'
+ /** Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. */
+ excludeFromTotal?: boolean
+ /** Overrides the chart's "Show values on series" for this series. Unset or 'auto' follows the chart setting. */
+ valueLabels?: 'auto' | 'show' | 'hide'
}
export interface HeatmapGradientStop {
diff --git a/posthog/schema.py b/posthog/schema.py
index e6b828e1e8cb..bf1b2ab4aec5 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -336,6 +336,7 @@ from posthog.schema_enums import (
UsageMetricFormat as UsageMetricFormat,
ValueDisplay as ValueDisplay,
ValueLabelPosition as ValueLabelPosition,
+ ValueLabels as ValueLabels,
WebAgentAnalyticsQueryType as WebAgentAnalyticsQueryType,
WebAgentContentGrouping as WebAgentContentGrouping,
WebAnalyticsItemKind as WebAnalyticsItemKind,
@@ -567,6 +568,14 @@ class AssistantDataVisualizationAxisDisplaySettings(BaseModel):
description="Custom color for this series as a hex string (e.g. `#1d4aff`).",
)
displayType: DisplayType | None = Field(default=None, description="Chart type. `auto` uses `display`.")
+ excludeFromTotal: bool | None = Field(
+ default=None,
+ description=(
+ "Keep this series out of the tooltip's total row, e.g. a target line over"
+ " stacked bars. A bar series still stacks, so set `displayType` to `line`"
+ " for a series drawn over the stack."
+ ),
+ )
label: str | None = Field(
default=None,
description="Series label in legends and tooltips; replaces the column name.",
@@ -575,6 +584,14 @@ class AssistantDataVisualizationAxisDisplaySettings(BaseModel):
default=None,
description=("Draw a linear trend line for this series. Only meaningful for line, bar, and area charts."),
)
+ valueLabels: ValueLabels | None = Field(
+ default=None,
+ description=(
+ "Per-series override of chart-level `showValuesOnSeries`. `show` labels"
+ " this series even when the chart setting is off, `hide` leaves it"
+ " unlabeled when the setting is on, `auto` follows the chart."
+ ),
+ )
yAxisPosition: YAxisPosition | None = Field(
default=None,
description=("Which Y axis this numeric series should use. Use `right` for a secondary Y axis."),
@@ -640,6 +657,16 @@ class AssistantDataVisualizationBoxPlotSettings(BaseModel):
)
+class AssistantDataVisualizationColumnSettings(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ formatting: AssistantDataVisualizationAxisFormatting | None = Field(
+ default=None,
+ description="Number-formatting settings for the values in this column.",
+ )
+
+
class AssistantDataVisualizationGoalLine(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -1195,8 +1222,19 @@ class ChartSettingsDisplay(BaseModel):
)
color: str | None = None
displayType: DisplayType | None = None
+ excludeFromTotal: bool | None = Field(
+ default=None,
+ description=("Keep this series out of the tooltip's total row, e.g. a target line over stacked bars."),
+ )
label: str | None = None
trendLine: bool | None = None
+ valueLabels: ValueLabels | None = Field(
+ default=None,
+ description=(
+ 'Overrides the chart\'s "Show values on series" for this series. Unset or'
+ " 'auto' follows the chart setting."
+ ),
+ )
yAxisPosition: YAxisPosition | None = None
@@ -3949,72 +3987,13 @@ class AssistantDataVisualizationAxis(BaseModel):
)
-class AssistantDataVisualizationChartSettings(BaseModel):
+class AssistantDataVisualizationColumn(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
- boxPlot: AssistantDataVisualizationBoxPlotSettings | None = Field(
- default=None,
- description=(
- "Column mappings for `BoxPlot`. The SQL must return one pre-aggregated row per X-axis and series pair."
- ),
- )
- goalLines: list[AssistantDataVisualizationGoalLine] | None = Field(
- default=None, description="Horizontal goal lines drawn across the chart."
- )
- leftYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
- default=None, description="Settings for the left Y axis."
- )
- legendPosition: LegendPosition | None = Field(
- default=None,
- description=("Where the legend sits. Defaults to right for pie and donut, top for other charts."),
- )
- metric: AssistantDataVisualizationMetricSettings | None = Field(
- default=None,
- description="Settings for `Metric`. `summary` defaults to `latest`.",
- )
- pie: PieChartSettings | None = Field(default=None, description="Settings for `ActionsPie` and `ActionsDonut`.")
- rightYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
- default=None,
- description=(
- "Settings for the right Y axis. Only applies when a Y series uses"
- ' `settings.display.yAxisPosition: "right"`.'
- ),
- )
- seriesBreakdownColumn: str | None = Field(
- default=None,
- description=(
- "Column that splits a single Y series into multiple colored series — e.g."
- " breaking down a line chart by `country`. Set to `null` or omit to"
- " disable. A breakdown buckets rows by x value, so it is ignored when"
- " `display` is `ScatterPlot`."
- ),
- )
- showLegend: bool | None = Field(default=None, description="Show the chart legend.")
- showNullsAsZero: bool | None = Field(default=None, description="Replace null aggregation results with zero.")
- showTotalRow: bool | None = Field(
- default=None,
- description=("Show a total summing all Y series. Applies to line, bar, and area charts."),
- )
- showValuesOnSeries: bool | None = Field(
- default=None,
- description="Render each data point's value as a label directly on the series.",
- )
- stackBars100: bool | None = Field(
- default=None,
- description=("Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`."),
- )
- xAxis: AssistantDataVisualizationAxis | None = Field(
- default=None,
- description=(
- "Column used as the X axis. Typically a time bucket or categorical column,"
- " but `ScatterPlot` plots two measures against each other, so it needs a"
- " numeric column here too."
- ),
- )
- xAxisLabel: str | None = Field(default=None, description="Label rendered under the X axis.")
- yAxis: list[AssistantDataVisualizationAxis] | None = Field(
- default=None, description="One or more numeric columns plotted as Y series."
+ column: str = Field(..., description="Name of a column returned by the SQL query.")
+ settings: AssistantDataVisualizationColumnSettings | None = Field(
+ default=None, description="Optional number formatting for this column."
)
@@ -4022,7 +4001,7 @@ class AssistantDataVisualizationTableSettings(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
- columns: list[AssistantDataVisualizationAxis] | None = Field(
+ columns: list[AssistantDataVisualizationColumn] | None = Field(
default=None,
description=("Columns to display and their order. Omit to show every column returned by the query."),
)
@@ -10445,6 +10424,75 @@ class AssistantDataTableNode(BaseModel):
source: AssistantEventsQuery
+class AssistantDataVisualizationChartSettings(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ boxPlot: AssistantDataVisualizationBoxPlotSettings | None = Field(
+ default=None,
+ description=(
+ "Column mappings for `BoxPlot`. The SQL must return one pre-aggregated row per X-axis and series pair."
+ ),
+ )
+ goalLines: list[AssistantDataVisualizationGoalLine] | None = Field(
+ default=None, description="Horizontal goal lines drawn across the chart."
+ )
+ leftYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
+ default=None, description="Settings for the left Y axis."
+ )
+ legendPosition: LegendPosition | None = Field(
+ default=None,
+ description=("Where the legend sits. Defaults to right for pie and donut, top for other charts."),
+ )
+ metric: AssistantDataVisualizationMetricSettings | None = Field(
+ default=None,
+ description="Settings for `Metric`. `summary` defaults to `latest`.",
+ )
+ pie: PieChartSettings | None = Field(default=None, description="Settings for `ActionsPie` and `ActionsDonut`.")
+ rightYAxisSettings: AssistantDataVisualizationYAxisSettings | None = Field(
+ default=None,
+ description=(
+ "Settings for the right Y axis. Only applies when a Y series uses"
+ ' `settings.display.yAxisPosition: "right"`.'
+ ),
+ )
+ seriesBreakdownColumn: str | None = Field(
+ default=None,
+ description=(
+ "Column that splits a single Y series into multiple colored series — e.g."
+ " breaking down a line chart by `country`. Set to `null` or omit to"
+ " disable. A breakdown buckets rows by x value, so it is ignored when"
+ " `display` is `ScatterPlot`."
+ ),
+ )
+ showLegend: bool | None = Field(default=None, description="Show the chart legend.")
+ showNullsAsZero: bool | None = Field(default=None, description="Replace null aggregation results with zero.")
+ showTotalRow: bool | None = Field(
+ default=None,
+ description=("Show a total summing all Y series. Applies to line, bar, and area charts."),
+ )
+ showValuesOnSeries: bool | None = Field(
+ default=None,
+ description="Render each data point's value as a label directly on the series.",
+ )
+ stackBars100: bool | None = Field(
+ default=None,
+ description=("Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`."),
+ )
+ xAxis: AssistantDataVisualizationColumn | None = Field(
+ default=None,
+ description=(
+ "Column used as the X axis. Typically a time bucket or categorical column,"
+ " but `ScatterPlot` plots two measures against each other, so it needs a"
+ " numeric column here too."
+ ),
+ )
+ xAxisLabel: str | None = Field(default=None, description="Label rendered under the X axis.")
+ yAxis: list[AssistantDataVisualizationAxis] | None = Field(
+ default=None, description="One or more numeric columns plotted as Y series."
+ )
+
+
class AssistantDataVisualizationNode(BaseModel):
model_config = ConfigDict(
extra="forbid",
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index bdb16538c48a..6bc0e306bac7 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -251,6 +251,12 @@ class DisplayType(StrEnum):
AREA = "area"
+class ValueLabels(StrEnum):
+ AUTO = "auto"
+ SHOW = "show"
+ HIDE = "hide"
+
+
class YAxisPosition(StrEnum):
LEFT = "left"
RIGHT = "right"
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index ca2aeed0ad7b..678e402c35c8 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -9302,6 +9302,14 @@ export const DisplayTypeApi = {
Area: 'area',
} as const
+export type ValueLabelsApi = (typeof ValueLabelsApi)[keyof typeof ValueLabelsApi]
+
+export const ValueLabelsApi = {
+ Auto: 'auto',
+ Show: 'show',
+ Hide: 'hide',
+} as const
+
export type YAxisPositionApi = (typeof YAxisPositionApi)[keyof typeof YAxisPositionApi]
export const YAxisPositionApi = {
@@ -9312,8 +9320,12 @@ export const YAxisPositionApi = {
export interface ChartSettingsDisplayApi {
color?: string | null
displayType?: DisplayTypeApi | null
+ /** Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. */
+ excludeFromTotal?: boolean | null
label?: string | null
trendLine?: boolean | null
+ /** Overrides the chart's "Show values on series" for this series. Unset or 'auto' follows the chart setting. */
+ valueLabels?: ValueLabelsApi | null
yAxisPosition?: YAxisPositionApi | null
}
diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.ts
index 3984d4d69833..02447e3e8931 100644
--- a/products/desktop/packages/api-client/src/generated.ts
+++ b/products/desktop/packages/api-client/src/generated.ts
@@ -4758,12 +4758,15 @@ export namespace Schemas {
subtotals: boolean | null;
}>;
export type DisplayType = "auto" | "line" | "bar" | "area";
+ export type ValueLabels = "auto" | "show" | "hide";
export type YAxisPosition = "left" | "right";
export type ChartSettingsDisplay = Partial<{
color: string | null;
displayType: DisplayType | null;
+ excludeFromTotal: boolean | null;
label: string | null;
trendLine: boolean | null;
+ valueLabels: ValueLabels | null;
yAxisPosition: YAxisPosition | null;
}>;
export type Style = "none" | "number" | "short" | "percent";
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 9e15239beb77..a3acee43fc81 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -8168,6 +8168,14 @@ export const DisplayTypeApi = {
Area: 'area',
} as const
+export type ValueLabelsApi = (typeof ValueLabelsApi)[keyof typeof ValueLabelsApi]
+
+export const ValueLabelsApi = {
+ Auto: 'auto',
+ Show: 'show',
+ Hide: 'hide',
+} as const
+
export type YAxisPositionApi = (typeof YAxisPositionApi)[keyof typeof YAxisPositionApi]
export const YAxisPositionApi = {
@@ -8178,8 +8186,12 @@ export const YAxisPositionApi = {
export interface ChartSettingsDisplayApi {
color?: string | null
displayType?: DisplayTypeApi | null
+ /** Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. */
+ excludeFromTotal?: boolean | null
label?: string | null
trendLine?: boolean | null
+ /** Overrides the chart's "Show values on series" for this series. Unset or 'auto' follows the chart setting. */
+ valueLabels?: ValueLabelsApi | null
yAxisPosition?: YAxisPositionApi | null
}
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 309306552c96..d48e911afb57 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -10730,6 +10730,15 @@ export namespace Schemas {
Area: 'area',
} as const;
+ export type ValueLabels = typeof ValueLabels[keyof typeof ValueLabels];
+
+
+ export const ValueLabels = {
+ Auto: 'auto',
+ Show: 'show',
+ Hide: 'hide',
+ } as const;
+
export type YAxisPosition = typeof YAxisPosition[keyof typeof YAxisPosition];
@@ -10741,8 +10750,12 @@ export namespace Schemas {
export interface ChartSettingsDisplay {
color?: string | null;
displayType?: DisplayType | null;
+ /** Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. */
+ excludeFromTotal?: boolean | null;
label?: string | null;
trendLine?: boolean | null;
+ /** Overrides the chart's "Show values on series" for this series. Unset or 'auto' follows the chart setting. */
+ valueLabels?: ValueLabels | null;
yAxisPosition?: YAxisPosition | null;
}
diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.ts
index 2ec44c88357a..c1a423cc7cdd 100644
--- a/services/mcp/src/tools/generated/product_analytics.ts
+++ b/services/mcp/src/tools/generated/product_analytics.ts
@@ -125,32 +125,57 @@ const PieChartSettings = z.object({
.optional(),
})
+const AssistantDataVisualizationAxisFormatting = z.object({
+ decimalPlaces: z.coerce.number().describe('Number of decimal places to display.').optional(),
+ prefix: z.string().describe('Text prepended to each value (e.g. `$`).').optional(),
+ style: z
+ .enum(['none', 'number', 'short', 'percent'])
+ .describe(
+ '`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.'
+ )
+ .optional(),
+ suffix: z.string().describe('Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.').optional(),
+})
+
+const AssistantDataVisualizationColumnSettings = z.object({
+ formatting: AssistantDataVisualizationAxisFormatting.describe(
+ 'Number-formatting settings for the values in this column.'
+ ).optional(),
+})
+
+const AssistantDataVisualizationColumn = z.object({
+ column: z.string().describe('Name of a column returned by the SQL query.'),
+ settings: AssistantDataVisualizationColumnSettings.describe(
+ 'Optional number formatting for this column.'
+ ).optional(),
+})
+
const AssistantDataVisualizationAxisDisplaySettings = z.object({
color: z.string().describe('Custom color for this series as a hex string (e.g. `#1d4aff`).').optional(),
displayType: z.enum(['auto', 'line', 'bar', 'area']).describe('Chart type. `auto` uses `display`.').optional(),
+ excludeFromTotal: z.coerce
+ .boolean()
+ .describe(
+ "Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. A bar series still stacks, so set `displayType` to `line` for a series drawn over the stack."
+ )
+ .optional(),
label: z.string().describe('Series label in legends and tooltips; replaces the column name.').optional(),
trendLine: z.coerce
.boolean()
.describe('Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.')
.optional(),
+ valueLabels: z
+ .enum(['auto', 'show', 'hide'])
+ .describe(
+ 'Per-series override of chart-level `showValuesOnSeries`. `show` labels this series even when the chart setting is off, `hide` leaves it unlabeled when the setting is on, `auto` follows the chart.'
+ )
+ .optional(),
yAxisPosition: z
.enum(['left', 'right'])
.describe('Which Y axis this numeric series should use. Use `right` for a secondary Y axis.')
.optional(),
})
-const AssistantDataVisualizationAxisFormatting = z.object({
- decimalPlaces: z.coerce.number().describe('Number of decimal places to display.').optional(),
- prefix: z.string().describe('Text prepended to each value (e.g. `$`).').optional(),
- style: z
- .enum(['none', 'number', 'short', 'percent'])
- .describe(
- '`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.'
- )
- .optional(),
- suffix: z.string().describe('Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.').optional(),
-})
-
const AssistantDataVisualizationAxisSettings = z.object({
display: AssistantDataVisualizationAxisDisplaySettings.describe(
'Display settings for a plotted Y series.'
@@ -208,7 +233,7 @@ const AssistantDataVisualizationChartSettings = z.object({
.boolean()
.describe('Stack bars to 100% of the total. Only meaningful with `ActionsStackedBar`.')
.optional(),
- xAxis: AssistantDataVisualizationAxis.describe(
+ xAxis: AssistantDataVisualizationColumn.describe(
'Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot` plots two measures against each other, so it needs a numeric column here too.'
).optional(),
xAxisLabel: z.string().describe('Label rendered under the X axis.').optional(),
@@ -237,7 +262,7 @@ const AssistantDataVisualizationDisplayType = z.enum([
const AssistantDataVisualizationTableSettings = z.object({
columns: z
- .array(AssistantDataVisualizationAxis)
+ .array(AssistantDataVisualizationColumn)
.describe('Columns to display and their order. Omit to show every column returned by the query.')
.optional(),
pinnedColumns: z.array(z.string()).describe('Column names to pin to the left of the table.').optional(),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
index fc97cbd10e0e..f96b287dad55 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json
@@ -351,42 +351,14 @@
"description": "Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot` plots two measures against each other, so it needs a numeric column here too.",
"properties": {
"column": {
- "description": "Name of a column returned by the SQL query to map onto this axis.",
+ "description": "Name of a column returned by the SQL query.",
"type": "string"
},
"settings": {
- "description": "Optional series settings. Only applies to Y-axis series.",
+ "description": "Optional number formatting for this column.",
"properties": {
- "display": {
- "description": "Display settings for a plotted Y series.",
- "properties": {
- "color": {
- "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",
- "type": "string"
- },
- "displayType": {
- "description": "Chart type. `auto` uses `display`.",
- "enum": ["auto", "line", "bar", "area"],
- "type": "string"
- },
- "label": {
- "description": "Series label in legends and tooltips; replaces the column name.",
- "type": "string"
- },
- "trendLine": {
- "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
- "type": "boolean"
- },
- "yAxisPosition": {
- "description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
- "enum": ["left", "right"],
- "type": "string"
- }
- },
- "type": "object"
- },
"formatting": {
- "description": "Number-formatting settings for the values on this axis or series.",
+ "description": "Number-formatting settings for the values in this column.",
"properties": {
"decimalPlaces": {
"description": "Number of decimal places to display.",
@@ -442,6 +414,10 @@
"enum": ["auto", "line", "bar", "area"],
"type": "string"
},
+ "excludeFromTotal": {
+ "description": "Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. A bar series still stacks, so set `displayType` to `line` for a series drawn over the stack.",
+ "type": "boolean"
+ },
"label": {
"description": "Series label in legends and tooltips; replaces the column name.",
"type": "string"
@@ -450,6 +426,11 @@
"description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
"type": "boolean"
},
+ "valueLabels": {
+ "description": "Per-series override of chart-level `showValuesOnSeries`. `show` labels this series even when the chart setting is off, `hide` leaves it unlabeled when the setting is on, `auto` follows the chart.",
+ "enum": ["auto", "show", "hide"],
+ "type": "string"
+ },
"yAxisPosition": {
"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
"enum": ["left", "right"],
@@ -534,42 +515,14 @@
"items": {
"properties": {
"column": {
- "description": "Name of a column returned by the SQL query to map onto this axis.",
+ "description": "Name of a column returned by the SQL query.",
"type": "string"
},
"settings": {
- "description": "Optional series settings. Only applies to Y-axis series.",
+ "description": "Optional number formatting for this column.",
"properties": {
- "display": {
- "description": "Display settings for a plotted Y series.",
- "properties": {
- "color": {
- "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",
- "type": "string"
- },
- "displayType": {
- "description": "Chart type. `auto` uses `display`.",
- "enum": ["auto", "line", "bar", "area"],
- "type": "string"
- },
- "label": {
- "description": "Series label in legends and tooltips; replaces the column name.",
- "type": "string"
- },
- "trendLine": {
- "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
- "type": "boolean"
- },
- "yAxisPosition": {
- "description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
- "enum": ["left", "right"],
- "type": "string"
- }
- },
- "type": "object"
- },
"formatting": {
- "description": "Number-formatting settings for the values on this axis or series.",
+ "description": "Number-formatting settings for the values in this column.",
"properties": {
"decimalPlaces": {
"description": "Number of decimal places to display.",
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
index 075afae7cbec..8b5384cdb030 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json
@@ -362,42 +362,14 @@
"description": "Column used as the X axis. Typically a time bucket or categorical column, but `ScatterPlot` plots two measures against each other, so it needs a numeric column here too.",
"properties": {
"column": {
- "description": "Name of a column returned by the SQL query to map onto this axis.",
+ "description": "Name of a column returned by the SQL query.",
"type": "string"
},
"settings": {
- "description": "Optional series settings. Only applies to Y-axis series.",
+ "description": "Optional number formatting for this column.",
"properties": {
- "display": {
- "description": "Display settings for a plotted Y series.",
- "properties": {
- "color": {
- "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",
- "type": "string"
- },
- "displayType": {
- "description": "Chart type. `auto` uses `display`.",
- "enum": ["auto", "line", "bar", "area"],
- "type": "string"
- },
- "label": {
- "description": "Series label in legends and tooltips; replaces the column name.",
- "type": "string"
- },
- "trendLine": {
- "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
- "type": "boolean"
- },
- "yAxisPosition": {
- "description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
- "enum": ["left", "right"],
- "type": "string"
- }
- },
- "type": "object"
- },
"formatting": {
- "description": "Number-formatting settings for the values on this axis or series.",
+ "description": "Number-formatting settings for the values in this column.",
"properties": {
"decimalPlaces": {
"description": "Number of decimal places to display.",
@@ -453,6 +425,10 @@
"enum": ["auto", "line", "bar", "area"],
"type": "string"
},
+ "excludeFromTotal": {
+ "description": "Keep this series out of the tooltip's total row, e.g. a target line over stacked bars. A bar series still stacks, so set `displayType` to `line` for a series drawn over the stack.",
+ "type": "boolean"
+ },
"label": {
"description": "Series label in legends and tooltips; replaces the column name.",
"type": "string"
@@ -461,6 +437,11 @@
"description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
"type": "boolean"
},
+ "valueLabels": {
+ "description": "Per-series override of chart-level `showValuesOnSeries`. `show` labels this series even when the chart setting is off, `hide` leaves it unlabeled when the setting is on, `auto` follows the chart.",
+ "enum": ["auto", "show", "hide"],
+ "type": "string"
+ },
"yAxisPosition": {
"description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
"enum": ["left", "right"],
@@ -545,42 +526,14 @@
"items": {
"properties": {
"column": {
- "description": "Name of a column returned by the SQL query to map onto this axis.",
+ "description": "Name of a column returned by the SQL query.",
"type": "string"
},
"settings": {
- "description": "Optional series settings. Only applies to Y-axis series.",
+ "description": "Optional number formatting for this column.",
"properties": {
- "display": {
- "description": "Display settings for a plotted Y series.",
- "properties": {
- "color": {
- "description": "Custom color for this series as a hex string (e.g. `#1d4aff`).",
- "type": "string"
- },
- "displayType": {
- "description": "Chart type. `auto` uses `display`.",
- "enum": ["auto", "line", "bar", "area"],
- "type": "string"
- },
- "label": {
- "description": "Series label in legends and tooltips; replaces the column name.",
- "type": "string"
- },
- "trendLine": {
- "description": "Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.",
- "type": "boolean"
- },
- "yAxisPosition": {
- "description": "Which Y axis this numeric series should use. Use `right` for a secondary Y axis.",
- "enum": ["left", "right"],
- "type": "string"
- }
- },
- "type": "object"
- },
"formatting": {
- "description": "Number-formatting settings for the values on this axis or series.",
+ "description": "Number-formatting settings for the values in this column.",
"properties": {
"decimalPlaces": {
"description": "Number of decimal places to display.",