: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(insights): add the proportion bar display type behind a flag (#112784)
Paul D'Ambra6a015e9e3a24
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 54904098645d..f50ff4947855 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4521,9 +4521,9 @@ snapshots:lemon-ui-icons2--shelf-o--light:hash: v1.k794b7964.2af9cd7fca97270f8ce11698e014a928851ff2021cb6f5ac1f82b49924637295.hNvwQ5qzm6pPgp93CAoYrn-VgjPmzWT7ZiDiE_H5QPslemon-ui-icons2--shelf-p--dark:- hash: v1.k794b7964.d5e3c0761a0d77d08e5db21e9cd88f9d6071f7b8c9c02e86f98624daa6f66bf2.6VDrOQ0RkdizoTCf1fyBI8r7sht6vfYdPzslpABSOvw+ hash: v1.k794b7964.06736fe539d74737a210c19b4e6cd26a271b59819af0bb64463fd31ce54d208a.V2n-b5E0nFYb8_EwOpKsPzLtJz-Nrj-GVKFk-JYOjBwlemon-ui-icons2--shelf-p--light:- hash: v1.k794b7964.9bad75e6e288d37855557c6c7a69f3ab0c1b75ec8f5fc04aa311c87f559a7c35.qx8rjJ17Yy2bV5G3iQEMJbgmYVJW23nsclSc_HAhxl8+ hash: v1.k794b7964.eb63ff48968cf1f7a60f957fa2007a0607a0d917f14efec6e48586933d6d94c8.DSctX2ym2EsiONbQjHVZyT6lLl-MfAWfyBwhrOOYFWslemon-ui-icons2--shelf-q--dark:hash: v1.k794b7964.5a9d82b6aafe0fe15ba59213f33bcc9a55ece2fdd1055a09c16372aabcec884e.7_SflSd_yazp-C7g7cd-cU1HTwid_0XLpMMIqsM1glolemon-ui-icons2--shelf-q--light:diff --git a/frontend/src/lib/components/Cards/InsightCard/visualizationShape.ts b/frontend/src/lib/components/Cards/InsightCard/visualizationShape.tsindex 8926782ac786..87ed717432ab 100644--- a/frontend/src/lib/components/Cards/InsightCard/visualizationShape.ts+++ b/frontend/src/lib/components/Cards/InsightCard/visualizationShape.ts@@ -40,6 +40,7 @@ export function visualizationShape(query: InsightModel['query']): VisualizationScase ChartDisplayType.ActionsUnstackedBar:case ChartDisplayType.ActionsStackedBar:case ChartDisplayType.ActionsBarValue:+ case ChartDisplayType.ActionsProportionBar:case ChartDisplayType.BoxPlot:return 'bar'case ChartDisplayType.ActionsPie:diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 0877b82f2bd0..d8b0d83635a5 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -15,6 +15,7 @@ export const DISPLAY_TYPES_TO_CATEGORIES: Record<ChartDisplayType, ChartDisplayC[ChartDisplayType.Metric]: ChartDisplayCategory.TimeSeries,[ChartDisplayType.ActionsPie]: ChartDisplayCategory.TotalValue,[ChartDisplayType.ActionsDonut]: ChartDisplayCategory.TotalValue,+ [ChartDisplayType.ActionsProportionBar]: ChartDisplayCategory.TotalValue,[ChartDisplayType.ActionsBarValue]: ChartDisplayCategory.TotalValue,[ChartDisplayType.ActionsTable]: ChartDisplayCategory.TotalValue,[ChartDisplayType.WorldMap]: ChartDisplayCategory.TotalValue,@@ -56,11 +57,20 @@ export const NON_VALUES_ON_SERIES_DISPLAY_TYPES = [ChartDisplayType.CalendarHeatmap,ChartDisplayType.TwoDimensionalHeatmap,ChartDisplayType.ScatterPlot,+ ChartDisplayType.ActionsProportionBar,]/** Pie and donut render the same chart, so they share every pie-shaped behavior. */export const PIE_DISPLAY_TYPES = [ChartDisplayType.ActionsPie, ChartDisplayType.ActionsDonut]+/** Display types that split one total into parts, one aggregated value per series. They share the+ * data shape and the clicks; slice labels and the percent view stay pie-only. */+export const PART_OF_WHOLE_DISPLAY_TYPES = [...PIE_DISPLAY_TYPES, ChartDisplayType.ActionsProportionBar]++/** A proportion bar has no axis to read a size from, so its legend carries the shares and starts on.+ * Past this many parts, one legend row per part costs more than it helps, so the legend starts off. */+export const MAX_DEFAULT_PROPORTION_LEGEND_PARTS = 20+/** Display types for which a percent stack view is available. */export const PERCENT_STACK_VIEW_DISPLAY_TYPE = [ChartDisplayType.ActionsBar,@@ -221,6 +231,7 @@ export const FEATURE_FLAGS = {MEMBERS_CAN_USE_PERSONAL_API_KEYS: 'members-can-use-personal-api-keys', // owner: @yasen-posthog #team-platform-featuresMETRIC_INSIGHT: 'metric-insight', // owner: @sampennington #team-product-analyticsPERSONLESS_EVENTS_NOT_SUPPORTED: 'personless-events-not-supported', // owner: #team-analytics-platform+ PROPORTION_BAR_CHART: 'proportion-bar-chart', // owner: @pauldambra, gates the proportion bar in the insight and SQL chart pickersQUERY_RUNNING_TIME: 'query_running_time', // owner: #team-analytics-platformREPLAY_BROWSER_SCROLL_BUG: 'replay-browser-scroll-bug', // owner: #team-replay, temporary: gates the rendered-scroll diagnosticREPLAY_CONSOLIDATED_CONTROLS: 'replay-consolidated-controls', // owner: #team-replay, gates the single player header bar and the list View menudiff --git a/frontend/src/lib/lemon-ui/icons/icons.tsx b/frontend/src/lib/lemon-ui/icons/icons.tsxindex 2f4f72533424..82b45d1dc19f 100644--- a/frontend/src/lib/lemon-ui/icons/icons.tsx+++ b/frontend/src/lib/lemon-ui/icons/icons.tsx@@ -444,6 +444,16 @@ export function IconDonutChart(props: LemonIconProps): JSX.Element {)}+export function IconProportionBarChart(props: LemonIconProps): JSX.Element {+ return (+ <LemonIconBase {...props}>+ <rect x="3.75" y="7.25" width="16.5" height="9.5" rx="2" stroke="currentColor" strokeWidth="1.5" />+ <path d="M5.75 7.25H11V16.75H5.75A2 2 0 0 1 3.75 14.75V9.25A2 2 0 0 1 5.75 7.25Z" fill="currentColor" />+ <path d="M15.5 7.5V16.5" stroke="currentColor" strokeWidth="1.5" />+ </LemonIconBase>+ )+}+/** Insight type icon set. Drawn at the same visual weight as the left-nav icon family* (~1.5-1.75 unit strokes, slim bars). Series blue is the base color; glyphs with severaldiff --git a/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx b/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsxindex 3447da0f5a4f..421467499ecb 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/TableDisplay.tsx@@ -23,6 +23,7 @@ const DISPLAY_TYPE_LABELS: Record<ChartDisplayType, string> = {[ChartDisplayType.Metric]: 'Metric',[ChartDisplayType.ActionsPie]: 'Pie chart',[ChartDisplayType.ActionsDonut]: 'Donut chart',+ [ChartDisplayType.ActionsProportionBar]: 'Proportion bar',[ChartDisplayType.ActionsBarValue]: 'Horizontal bar chart',[ChartDisplayType.ActionsTable]: 'Table',[ChartDisplayType.WorldMap]: 'World map',diff --git a/frontend/src/queries/nodes/DataVisualization/sqlVisualizationSupport.ts b/frontend/src/queries/nodes/DataVisualization/sqlVisualizationSupport.tsindex d1821f875cfc..5e7bc12072b3 100644--- a/frontend/src/queries/nodes/DataVisualization/sqlVisualizationSupport.ts+++ b/frontend/src/queries/nodes/DataVisualization/sqlVisualizationSupport.ts@@ -15,6 +15,7 @@ const VISUALIZATION_SUPPORT: Record<ChartDisplayType, VisualizationSupport> = {[ChartDisplayType.ActionsUnstackedBar]: 'axes',[ChartDisplayType.ActionsPie]: 'axes',[ChartDisplayType.ActionsDonut]: 'axes',+ [ChartDisplayType.ActionsProportionBar]: 'axes',[ChartDisplayType.ActionsLineGraphCumulative]: 'axes',[ChartDisplayType.ScatterPlot]: 'manual',[ChartDisplayType.TwoDimensionalHeatmap]: 'manual',diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 410e2421f219..b7d195ae980b 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -17614,6 +17614,7 @@"Metric","ActionsPie","ActionsDonut",+ "ActionsProportionBar","ActionsBarValue","ActionsTable","WorldMap",@@ -17648,7 +17649,7 @@"$ref": "#/definitions/YAxisSettings"},"legendPosition": {- "description": "Where the legend sits relative to the chart. Unset falls back per chart type: right for pie, top for the rest.",+ "description": "Where the legend sits relative to the chart. Unset falls back per chart type: right for pie and donut, bottom for proportion bar, top for the rest.","enum": ["top", "bottom", "left", "right"],"type": "string"},diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex cfc2c5742488..c7ac59689dc7 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -462,8 +462,12 @@ export interface AssistantTrendsBreakdownFilter extends AssistantBreakdownFilterbreakdown_path_cleaning?: boolean}-// Remove deprecated display types.-export type AssistantTrendsDisplayType = Exclude<TrendsFilterLegacy['display'], 'ActionsStackedBar'>+// Remove deprecated display types, and the proportion bar while the `proportion-bar-chart` flag gates it in the+// pickers, so agents cannot create one for people who cannot see the option.+export type AssistantTrendsDisplayType = Exclude<+ TrendsFilterLegacy['display'],+ 'ActionsStackedBar' | 'ActionsProportionBar'+>export interface AssistantTrendsFilter {/**diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 32801259e952..e9f6a6523110 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -1559,7 +1559,7 @@ export interface ChartSettings {showYAxisBorder?: booleanshowLegend?: booleanshowAnnotations?: boolean- /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie, top for the rest. */+ /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie and donut, bottom for proportion bar, top for the rest. */legendPosition?: 'top' | 'bottom' | 'left' | 'right'showValuesOnSeries?: boolean// Deprecated: superseded by `pie.showTotal`. Retained so pre-existing pie-chart insights stilldiff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.tsindex ad90a0ce331f..7d525275100c 100644--- a/frontend/src/queries/utils.ts+++ b/frontend/src/queries/utils.ts@@ -515,6 +515,7 @@ const CANVAS_CHART_DISPLAY_TYPES = new Set<ChartDisplayType>([ChartDisplayType.ActionsBarValue,ChartDisplayType.ActionsPie,ChartDisplayType.ActionsDonut,+ ChartDisplayType.ActionsProportionBar,ChartDisplayType.Metric,ChartDisplayType.BoxPlot,ChartDisplayType.SlopeGraph,diff --git a/frontend/src/scenes/insights/utils/queryUtils.ts b/frontend/src/scenes/insights/utils/queryUtils.tsindex acc210f47020..5c41733fa68c 100644--- a/frontend/src/scenes/insights/utils/queryUtils.ts+++ b/frontend/src/scenes/insights/utils/queryUtils.ts@@ -273,6 +273,7 @@ const groupedChartDisplayTypes: Record<ChartDisplayType, ChartDisplayType> = {[ChartDisplayType.ActionsBarValue]: ChartDisplayType.ActionsBarValue,[ChartDisplayType.ActionsPie]: ChartDisplayType.ActionsBarValue,[ChartDisplayType.ActionsDonut]: ChartDisplayType.ActionsBarValue,+ [ChartDisplayType.ActionsProportionBar]: ChartDisplayType.ActionsBarValue,[ChartDisplayType.ActionsTable]: ChartDisplayType.ActionsBarValue,// separate: different breakdown limit (250)@@ -393,6 +394,7 @@ const AGGREGATED_RESULT_DISPLAYS = new Set<ChartDisplayType>([ChartDisplayType.BoldNumber,ChartDisplayType.ActionsPie,ChartDisplayType.ActionsDonut,+ ChartDisplayType.ActionsProportionBar,ChartDisplayType.ActionsBarValue,ChartDisplayType.ActionsTable,ChartDisplayType.WorldMap,diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex ed561fd78964..5cce5966e19e 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -3128,6 +3128,7 @@ export enum ChartDisplayType {Metric = 'Metric',ActionsPie = 'ActionsPie',ActionsDonut = 'ActionsDonut',+ ActionsProportionBar = 'ActionsProportionBar',ActionsBarValue = 'ActionsBarValue',ActionsTable = 'ActionsTable',WorldMap = 'WorldMap',diff --git a/posthog/constants.py b/posthog/constants.pyindex ef18e2cd9949..b4900df1349f 100644--- a/posthog/constants.py+++ b/posthog/constants.py@@ -74,6 +74,7 @@ TRENDS_TABLE = "ActionsTable"TRENDS_FUNNEL = "FunnelViz"TRENDS_PIE = "ActionsPie"TRENDS_DONUT = "ActionsDonut"+TRENDS_PROPORTION_BAR = "ActionsProportionBar"TRENDS_PATHS = "PathsViz"TRENDS_BAR = "ActionsBar"TRENDS_BAR_VALUE = "ActionsBarValue"@@ -88,6 +89,7 @@ NON_TIME_SERIES_DISPLAY_TYPES = [TRENDS_TABLE,TRENDS_PIE,TRENDS_DONUT,+ TRENDS_PROPORTION_BAR,TRENDS_BAR_VALUE,TRENDS_WORLD_MAP,TRENDS_BOLD_NUMBER,@@ -121,6 +123,7 @@ DISPLAY_TYPES = Literal["ActionsTable","ActionsPie","ActionsDonut",+ "ActionsProportionBar","ActionsBar","ActionsBarValue","WorldMap",diff --git a/posthog/schema.py b/posthog/schema.pyindex 962cebfa78df..520cf8340deb 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -16589,7 +16589,8 @@ class ChartSettings(BaseModel):default=None,description=("Where the legend sits relative to the chart. Unset falls back per chart"- " type: right for pie, top for the rest."+ " type: right for pie and donut, bottom for proportion bar, top for the"+ " rest."),)metric: MetricChartSettings | None = Nonediff --git a/posthog/schema_enums.py b/posthog/schema_enums.pyindex 02d7426b81cc..ae08c8f4786e 100644--- a/posthog/schema_enums.py+++ b/posthog/schema_enums.py@@ -776,6 +776,7 @@ class ChartDisplayType(StrEnum):METRIC = "Metric"ACTIONS_PIE = "ActionsPie"ACTIONS_DONUT = "ActionsDonut"+ ACTIONS_PROPORTION_BAR = "ActionsProportionBar"ACTIONS_BAR_VALUE = "ActionsBarValue"ACTIONS_TABLE = "ActionsTable"WORLD_MAP = "WorldMap"diff --git a/posthog/schema_helpers.py b/posthog/schema_helpers.pyindex 25f518e751b4..f49620344c7f 100644--- a/posthog/schema_helpers.py+++ b/posthog/schema_helpers.py@@ -194,6 +194,7 @@ def grouped_chart_display_types(display: ChartDisplayType) -> ChartDisplayType:| ChartDisplayType.BOLD_NUMBER| ChartDisplayType.ACTIONS_PIE| ChartDisplayType.ACTIONS_DONUT+ | ChartDisplayType.ACTIONS_PROPORTION_BAR| ChartDisplayType.ACTIONS_TABLE):# total valuediff --git a/posthog/tasks/alerts/utils.py b/posthog/tasks/alerts/utils.pyindex 4aa4c822b71c..e96ef8b59f8c 100644--- a/posthog/tasks/alerts/utils.py+++ b/posthog/tasks/alerts/utils.py@@ -83,6 +83,7 @@ NON_TIME_SERIES_DISPLAY_TYPES = {ChartDisplayType.BOLD_NUMBER,ChartDisplayType.ACTIONS_PIE,ChartDisplayType.ACTIONS_DONUT,+ ChartDisplayType.ACTIONS_PROPORTION_BAR,ChartDisplayType.ACTIONS_BAR_VALUE,ChartDisplayType.ACTIONS_TABLE,ChartDisplayType.WORLD_MAP,diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex b1210aaf26ed..914ba7819ffa 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2912,6 +2912,7 @@ export const ChartDisplayTypeApi = {Metric: 'Metric',ActionsPie: 'ActionsPie',ActionsDonut: 'ActionsDonut',+ ActionsProportionBar: 'ActionsProportionBar',ActionsBarValue: 'ActionsBarValue',ActionsTable: 'ActionsTable',WorldMap: 'WorldMap',@@ -9287,7 +9288,7 @@ export interface ChartSettingsApi {goalLines?: GoalLineApi[] | nullheatmap?: HeatmapSettingsApi | nullleftYAxisSettings?: YAxisSettingsApi | null- /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie, top for the rest. */+ /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie and donut, bottom for proportion bar, top for the rest. */legendPosition?: LegendPositionApi | nullmetric?: MetricChartSettingsApi | nullpie?: PieChartSettingsApi | nulldiff --git a/products/product_analytics/backend/hogql_queries/trends/display.py b/products/product_analytics/backend/hogql_queries/trends/display.pyindex dd48f178dd5b..3334f79afab1 100644--- a/products/product_analytics/backend/hogql_queries/trends/display.py+++ b/products/product_analytics/backend/hogql_queries/trends/display.py@@ -19,6 +19,7 @@ class TrendsDisplay:self.display_type == ChartDisplayType.BOLD_NUMBERor self.display_type == ChartDisplayType.ACTIONS_PIEor self.display_type == ChartDisplayType.ACTIONS_DONUT+ or self.display_type == ChartDisplayType.ACTIONS_PROPORTION_BARor self.display_type == ChartDisplayType.ACTIONS_BAR_VALUEor self.display_type == ChartDisplayType.WORLD_MAPor self.display_type == ChartDisplayType.CALENDAR_HEATMAPdiff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_display.py b/products/product_analytics/backend/hogql_queries/trends/test/test_display.pynew file mode 100644index 000000000000..dfc9b91215c9--- /dev/null+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_display.py@@ -0,0 +1,22 @@+from unittest import TestCase++from parameterized import parameterized++from posthog.schema import ChartDisplayType++from products.product_analytics.backend.hogql_queries.trends.display import TrendsDisplay+++class TestTrendsDisplay(TestCase):+ @parameterized.expand(+ [+ (ChartDisplayType.ACTIONS_PIE, True),+ (ChartDisplayType.ACTIONS_DONUT, True),+ (ChartDisplayType.ACTIONS_PROPORTION_BAR, True),+ (ChartDisplayType.ACTIONS_BAR_VALUE, True),+ (ChartDisplayType.ACTIONS_LINE_GRAPH, False),+ (ChartDisplayType.ACTIONS_BAR, False),+ ]+ )+ def test_is_total_value(self, display: ChartDisplayType, expected: bool) -> None:+ assert TrendsDisplay(display).is_total_value() is expecteddiff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 7530a28fbd9a..1aeb59980cd5 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1839,6 +1839,7 @@ export const ChartDisplayTypeApi = {Metric: 'Metric',ActionsPie: 'ActionsPie',ActionsDonut: 'ActionsDonut',+ ActionsProportionBar: 'ActionsProportionBar',ActionsBarValue: 'ActionsBarValue',ActionsTable: 'ActionsTable',WorldMap: 'WorldMap',@@ -8214,7 +8215,7 @@ export interface ChartSettingsApi {goalLines?: GoalLineApi[] | nullheatmap?: HeatmapSettingsApi | nullleftYAxisSettings?: YAxisSettingsApi | null- /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie, top for the rest. */+ /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie and donut, bottom for proportion bar, top for the rest. */legendPosition?: LegendPositionApi | nullmetric?: MetricChartSettingsApi | nullpie?: PieChartSettingsApi | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex e9b733da5c0f..101da1c7cc92 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -5277,6 +5277,7 @@ export namespace Schemas {Metric: 'Metric',ActionsPie: 'ActionsPie',ActionsDonut: 'ActionsDonut',+ ActionsProportionBar: 'ActionsProportionBar',ActionsBarValue: 'ActionsBarValue',ActionsTable: 'ActionsTable',WorldMap: 'WorldMap',@@ -10602,7 +10603,7 @@ export namespace Schemas {goalLines?: GoalLine[] | null;heatmap?: HeatmapSettings | null;leftYAxisSettings?: YAxisSettings | null;- /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie, top for the rest. */+ /** Where the legend sits relative to the chart. Unset falls back per chart type: right for pie and donut, bottom for proportion bar, top for the rest. */legendPosition?: LegendPosition | null;metric?: MetricChartSettings | null;pie?: PieChartSettings | null;