: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(product-analytics): let agents pick the proportion bar for trends (#113856)
Paul D'Ambraacce6df36340
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 87e619c0dca4..925cdb636472 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -6328,6 +6328,10 @@ snapshots:hash: v1.k794b7964.71bf9a67abbc8af67484c4ba46db9846533f0817a6c9431dbe86671f8c0c0657.gI8aNPSnINceu0ufFOIk1eB34bjlf7nWah24hc8EZRAmcp-apps-trends--pie-percentages--light:hash: v1.k794b7964.6333bf4d729ec9ca4bfd598fcf1fa09a528f1599ce8f520e0ac0dd4e090d0664.15Ipmr89-9dldfy4jSeYJzGj68hsOmPmhgafAhHmwko+ mcp-apps-trends--proportion-bar--light:+ hash: v1.k794b7964.896b2526cedb61895f05e29de23ff54a0c9f413b12667e3522218f968a88ac4c.TbAZLyhlARkRW3jGvEHVXw3IzBND9S8O6teIgr-ZzqY+ mcp-apps-trends--proportion-bar-duration--light:+ hash: v1.k794b7964.2404c9ca07928ea973d3728a28e789591aedcc48b46b268e970fd179b3d45bae.jo4UVHYfh5kgPvzZidyT3nntlludu4xKQDLEfiZMWhUmcp-apps-trends--single-series--light:hash: v1.k794b7964.1b5decab0f76ab924d787808679c22a9d7e29d3b908dc4efa02492eb5a5975ec.v1FGWBy1MIcdGPJmdIHHBHAD0lgjDTnH067dbcZqZGwmcp-apps-trends--time-series-bar--light:diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 235ff33c7edc..35dbecfa198d 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -5457,6 +5457,7 @@"ActionsBarValue","ActionsPie","ActionsDonut",+ "ActionsProportionBar","ActionsTable","WorldMap","CalendarHeatmap"@@ -5541,7 +5542,7 @@"display": {"$ref": "#/definitions/AssistantTrendsDisplayType","default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then."+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsProportionBar` - total value chart that shows the parts of one whole as a single flat bar, with one segment per breakdown value or series. Use it to show the share of each part in a total. It cannot compare to a previous period, so do not set `compareFilter.compare` with it. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then."},"formulaNodes": {"description": "Use custom formulas to perform mathematical operations like calculating percentages or metrics. Use the following syntax: `A/B`, where `A` and `B` are the names of the series. You can combine math aggregations and formulas. When using a formula, you must:\n- Identify and specify **all** events and actions needed to solve the formula.\n- Carefully review the list of available events and actions to find appropriate entities for each part of the formula.\n- Ensure that you find events and actions corresponding to both the numerator and denominator in ratio calculations. Examples of using math formulas:\n- If you want to calculate the percentage of users who have completed onboarding, you need to find and use events or actions similar to `$identify` and `onboarding complete`, so the formula will be `A / B`, where `A` is `onboarding complete` (unique users) and `B` is `$identify` (unique users). For a ratio or percentage, keep the formula as the raw ratio (e.g. `A/B`, which is in the 0-1 range) and set `aggregationAxisFormat` to `percentage_scaled` so it renders as a percentage. Do NOT multiply the formula by 100 (e.g. `A/B*100`) when using `percentage_scaled`, or the value will be scaled twice.",diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex 9bbcdbd69795..18a1c0758016 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -477,6 +477,7 @@ export type AssistantTrendsDisplayType =| ChartDisplayType.ActionsBarValue| ChartDisplayType.ActionsPie| ChartDisplayType.ActionsDonut+ | ChartDisplayType.ActionsProportionBar| ChartDisplayType.ActionsTable| ChartDisplayType.WorldMap// Not in the `display` description: the MCP chart app cannot show calendar_heatmap_data yet.@@ -516,6 +517,7 @@ export interface AssistantTrendsFilter {* `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as "top pages" or "failures by reason".* `ActionsPie` - total value pie chart; good for visualizing proportions.* `ActionsDonut` - total value donut chart; same use as `ActionsPie`.+ * `ActionsProportionBar` - total value chart that shows the parts of one whole as a single flat bar, with one segment per breakdown value or series. Use it to show the share of each part in a total. It cannot compare to a previous period, so do not set `compareFilter.compare` with it.* `ActionsTable` - total value table; good when using breakdown to list users or other entities.* `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.* @default ActionsLineGraphdiff --git a/posthog/schema.py b/posthog/schema.pyindex de5ace498f16..6dd039d82772 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -4908,10 +4908,14 @@ class AssistantTrendsFilter(BaseModel):" with one bar per breakdown value or series; good for categorical data"' such as "top pages" or "failures by reason". `ActionsPie` - total value'" pie chart; good for visualizing proportions. `ActionsDonut` - total value"- " donut chart; same use as `ActionsPie`. `ActionsTable` - total value"- " table; good when using breakdown to list users or other entities."- " `WorldMap` - total value world map; use when breaking down by country"- " using property `$geoip_country_code`, and only then."+ " donut chart; same use as `ActionsPie`. `ActionsProportionBar` - total"+ " value chart that shows the parts of one whole as a single flat bar, with"+ " one segment per breakdown value or series. Use it to show the share of"+ " each part in a total. It cannot compare to a previous period, so do not"+ " set `compareFilter.compare` with it. `ActionsTable` - total value table;"+ " good when using breakdown to list users or other entities. `WorldMap` -"+ " total value world map; use when breaking down by country using property"+ " `$geoip_country_code`, and only then."),)formulaNodes: list[TrendsFormulaNode] | None = Field(diff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 020aba5a4596..9c1ba21f597b 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -583,6 +583,7 @@ class AssistantTrendsDisplayType(StrEnum):ACTIONS_BAR_VALUE = "ActionsBarValue"ACTIONS_PIE = "ActionsPie"ACTIONS_DONUT = "ActionsDonut"+ ACTIONS_PROPORTION_BAR = "ActionsProportionBar"ACTIONS_TABLE = "ActionsTable"WORLD_MAP = "WorldMap"CALENDAR_HEATMAP = "CalendarHeatmap"diff --git a/services/mcp/src/tools/generated/query-wrappers.ts b/services/mcp/src/tools/generated/query-wrappers.tsindex 32164d5debe9..4c0d881e96df 100644--- a/services/mcp/src/tools/generated/query-wrappers.ts+++ b/services/mcp/src/tools/generated/query-wrappers.ts@@ -621,6 +621,7 @@ const AssistantTrendsDisplayType = z.enum(['ActionsBarValue','ActionsPie','ActionsDonut',+ 'ActionsProportionBar','ActionsTable','WorldMap','CalendarHeatmap',@@ -656,7 +657,7 @@ const AssistantTrendsFilter = z.object({).optional(),display: AssistantTrendsDisplayType.describe(- 'Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison ("how many X in the last 30 days", "what\'s our conversion rate this month", "how does this month compare to last"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as "top pages" or "failures by reason". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.'+ 'Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison ("how many X in the last 30 days", "what\'s our conversion rate this month", "how does this month compare to last"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as "top pages" or "failures by reason". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsProportionBar` - total value chart that shows the parts of one whole as a single flat bar, with one segment per breakdown value or series. Use it to show the share of each part in a total. It cannot compare to a previous period, so do not set `compareFilter.compare` with it. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.').default('ActionsLineGraph').optional(),diff --git a/services/mcp/src/ui-apps/components/Trends.stories.tsx b/services/mcp/src/ui-apps/components/Trends.stories.tsxindex b99f3aae3c3b..934f6a6e1445 100644--- a/services/mcp/src/ui-apps/components/Trends.stories.tsx+++ b/services/mcp/src/ui-apps/components/Trends.stories.tsx@@ -124,3 +124,29 @@ export const Donut: Story = {render: () => renderTrends(trendsQuery('ActionsDonut'), BROWSER_TOTALS),name: 'Donut',}++export const ProportionBar: Story = {+ render: () =>+ renderTrends(trendsQuery('ActionsProportionBar'), [+ { label: 'Chrome', aggregated_value: 8421 },+ { label: 'Firefox', aggregated_value: 3204 },+ { label: 'Safari', aggregated_value: 2817 },+ ]),+ name: 'Proportion bar',+}++export const ProportionBarDuration: Story = {+ render: () =>+ renderTrends(+ {+ kind: 'TrendsQuery',+ trendsFilter: { display: 'ActionsProportionBar', aggregationAxisFormat: 'duration' },+ },+ [+ { label: 'Onboarding', aggregated_value: 412 },+ { label: 'Checkout', aggregated_value: 95 },+ { label: 'Settings', aggregated_value: 38 },+ ]+ ),+ name: 'Proportion bar — duration format',+}diff --git a/services/mcp/src/ui-apps/components/TrendsVisualizer.tsx b/services/mcp/src/ui-apps/components/TrendsVisualizer.tsxindex 557f28bd0f22..0dc8ed918db9 100644--- a/services/mcp/src/ui-apps/components/TrendsVisualizer.tsx+++ b/services/mcp/src/ui-apps/components/TrendsVisualizer.tsx@@ -8,12 +8,14 @@ import {ciRanges,DefaultTooltip,PieChart,+ ProportionBar,SlopeChart,TimeSeriesBarChart,TimeSeriesLineChart,type TooltipContext,} from '@posthog/quill-charts'+import { trendsFilterToYFormatterConfig } from 'products/product_analytics/frontend/insights/trends/shared/trendsAxisFormat'import { buildTrendsBarChartModel } from 'products/product_analytics/frontend/insights/trends/TrendsBarChart/trendsBarChartTransforms'import {buildTrendsBarValueConfig,@@ -40,7 +42,7 @@ import {supportsPercentStack,} from './chartSettingsConfig'import type { TrendsResultItem, TrendsVisualizerProps } from './types'-import { formatDate, formatTooltipDate, getDisplayType, getSeriesLabel } from './utils'+import { buildProportionBarSeries, formatDate, formatTooltipDate, getDisplayType, getSeriesLabel } from './utils'const TITLE = 'Trends'@@ -106,6 +108,21 @@ export function TrendsVisualizer({ query, results }: TrendsVisualizerProps): Rea)}+ if (displayType === 'ActionsProportionBar') {+ return (+ <div>+ <ChartHeader title={TITLE} />+ <div className="flex flex-col w-full justify-center p-4">+ <ProportionBar+ series={buildProportionBarSeries(results, colorAt)}+ theme={theme}+ valueFormatter={buildYTickFormatter(trendsFilterToYFormatterConfig(query?.trendsFilter, false))}+ />+ </div>+ </div>+ )+ }+// ActionsBarValue is aggregated totals per series (no days[]) — a horizontal bar, not a time series.if (displayType === 'ActionsBarValue') {const items = results.map((item, i) => ({diff --git a/services/mcp/src/ui-apps/components/types.ts b/services/mcp/src/ui-apps/components/types.tsindex ccde7d2e2480..1a34f882519e 100644--- a/services/mcp/src/ui-apps/components/types.ts+++ b/services/mcp/src/ui-apps/components/types.ts@@ -15,6 +15,7 @@ export type ChartDisplayType =| 'BoldNumber'| 'ActionsPie'| 'ActionsDonut'+ | 'ActionsProportionBar'| 'ActionsTable'| 'WorldMap'| 'SlopeGraph'@@ -99,6 +100,7 @@ export interface TrendsResultItem {days?: string[]count?: numberaggregated_value?: number+ compare_label?: string/** Slope graph only: the last bucket is the current, still-accumulating period (set by the* backend SlopeGraphTrendsQueryRunner) so the slope dashes the provisional end like the insight. */incomplete_end?: booleandiff --git a/services/mcp/src/ui-apps/components/utils.ts b/services/mcp/src/ui-apps/components/utils.tsindex c587011784e6..cbe49d1c6ca9 100644--- a/services/mcp/src/ui-apps/components/utils.ts+++ b/services/mcp/src/ui-apps/components/utils.ts@@ -1,4 +1,6 @@-import type { ChartDisplayType, FunnelResult, TrendsQuery } from './types'+import type { Series } from '@posthog/quill-charts'++import type { ChartDisplayType, FunnelResult, TrendsQuery, TrendsResultItem } from './types'export function getDisplayType(query: TrendsQuery | undefined): ChartDisplayType {return query?.trendsFilter?.display || 'ActionsLineGraph'@@ -88,6 +90,18 @@ export function getSeriesLabel(item: { label?: string; action?: { name?: stringreturn item.label || item.action?.name || `Series ${index + 1}`}+export function buildProportionBarSeries(results: TrendsResultItem[], getColor: (index: number) => string): Series[] {+ // One bar has one total, so a previous period saved with compare on is left out.+ return results+ .filter((item) => item.compare_label !== 'previous')+ .map((item, i) => ({+ key: String(i),+ label: getSeriesLabel(item, i),+ data: [item.aggregated_value ?? 0],+ color: getColor(i),+ }))+}+export function normalizeFunnelSteps(results: FunnelResult): Array<{ name: string; count: number; order: number }> {if (results.length === 0) {return []diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.jsonindex 20f895e3acf7..11ca008c9898 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends-actors.json@@ -4343,7 +4343,7 @@},"display": {"default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.",+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsProportionBar` - total value chart that shows the parts of one whole as a single flat bar, with one segment per breakdown value or series. Use it to show the share of each part in a total. It cannot compare to a previous period, so do not set `compareFilter.compare` with it. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.","enum": ["ActionsLineGraph","ActionsBar",@@ -4357,6 +4357,7 @@"ActionsBarValue","ActionsPie","ActionsDonut",+ "ActionsProportionBar","ActionsTable","WorldMap","CalendarHeatmap"diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.jsonindex cc2e93647f3a..7f690f652fd4 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/query-trends.json@@ -4161,7 +4161,7 @@},"display": {"default": "ActionsLineGraph",- "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.",+ "description": "Visualization type. Available values: `ActionsLineGraph` - time-series line chart; most common option, as it shows change over time. `ActionsBar` - time-series bar chart with one bar per interval and breakdown values stacked in each bar. Do not use it to compare breakdown values or series as totals. Use `ActionsBarValue` for that. `ActionsUnstackedBar` - time-series bar chart with series side by side in each interval. `ActionsAreaGraph` - time-series area chart. `ActionsLineGraphCumulative` - cumulative time-series line chart; good for cumulative metrics. `SlopeGraph` - net change from the first to the last interval, one line per series. `BoxPlot` - quartiles of a numeric `math_property` for each interval. `Metric` - single large number with a change pill and a sparkline. Use for a period summary or an explicit current-versus-previous-period comparison (\"how many X in the last 30 days\", \"what's our conversion rate this month\", \"how does this month compare to last\"). Do not use for a question about change over time, a cadence, or a pattern. Use `ActionsLineGraph` so the person can inspect each interval. Set `compareFilter.compare` to `true` to compare the current period with the previous period. Without it, the pill compares the first interval with the last interval. Configure the display with the `metric*` fields below. Single series, no breakdown. `BoldNumber` - single large number with no change or sparkline. Use instead of `Metric` only when a trend is meaningless, such as an all-time total or a fixed ratio. You CANNOT use this with breakdown or if the insight has more than one series. `ActionsBarValue` - total value (NOT time-series) bar chart with one bar per breakdown value or series; good for categorical data such as \"top pages\" or \"failures by reason\". `ActionsPie` - total value pie chart; good for visualizing proportions. `ActionsDonut` - total value donut chart; same use as `ActionsPie`. `ActionsProportionBar` - total value chart that shows the parts of one whole as a single flat bar, with one segment per breakdown value or series. Use it to show the share of each part in a total. It cannot compare to a previous period, so do not set `compareFilter.compare` with it. `ActionsTable` - total value table; good when using breakdown to list users or other entities. `WorldMap` - total value world map; use when breaking down by country using property `$geoip_country_code`, and only then.","enum": ["ActionsLineGraph","ActionsBar",@@ -4175,6 +4175,7 @@"ActionsBarValue","ActionsPie","ActionsDonut",+ "ActionsProportionBar","ActionsTable","WorldMap","CalendarHeatmap"diff --git a/services/mcp/tests/unit/insight-visualizations.test.ts b/services/mcp/tests/unit/insight-visualizations.test.tsindex 9ec8c58f4fd1..95a533a42580 100644--- a/services/mcp/tests/unit/insight-visualizations.test.ts+++ b/services/mcp/tests/unit/insight-visualizations.test.ts@@ -10,6 +10,7 @@ import {isTrendsResult,} from '@/ui-apps/components/infer-visualization'import {+ buildProportionBarSeries,formatDate,formatDuration,formatNumber,@@ -234,6 +235,38 @@ describe('insight visualizations', () => {})})+ describe('buildProportionBarSeries', () => {+ it.each([+ [+ 'one part per row',+ [+ { label: 'Chrome', aggregated_value: 3 },+ { label: 'Safari', aggregated_value: 5 },+ ],+ [+ { label: 'Chrome', data: [3] },+ { label: 'Safari', data: [5] },+ ],+ ],+ [+ 'no part for the previous period of a compare',+ [+ { label: 'Chrome', aggregated_value: 3, compare_label: 'current' },+ { label: 'Chrome', aggregated_value: 2, compare_label: 'previous' },+ { label: 'Safari', aggregated_value: 5, compare_label: 'current' },+ ],+ [+ { label: 'Chrome', data: [3] },+ { label: 'Safari', data: [5] },+ ],+ ],+ ])('draws %s', (_name, results, expected) => {+ expect(+ buildProportionBarSeries(results, () => 'red').map(({ label, data }) => ({ label, data }))+ ).toEqual(expected)+ })+ })+describe('getDisplayType', () => {it('defaults to ActionsLineGraph when the query or filter is missing', () => {expect(getDisplayType(undefined)).toBe('ActionsLineGraph')