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.

fix(insights): restore embedded chart label width (#104484)

Daniel Parker3bb66f1c6a0e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2448b45d08e1..e80a88a6c054 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3580,10 +3580,6 @@ snapshots:
hash: v1.k794b7964.e02ba31b6e04cffc9eb214f21a65ce0e414eaf4982625bc37da4d64aa553ffb0.oPix6yvyfc3ngjRWHpWDvtzd1s9m2pi838jOaGXQ7Ng
insights-trendsbarchart--bar-value-50-breakdowns--light:
hash: v1.k794b7964.ce7fbccc760b55b0301fcdeb207ab214e7641045ba7f5f2cf8d2f30e2669bcb6.8UMExS_ADGQkLT6To6P9PxRxguH7_UR5F8p1mSWqNFw
- insights-trendsbarchart--bar-value-embedded-narrow--dark:
- hash: v1.k794b7964.124355320709b76b2793e174f3e567bc3ebff636ca141259f7c1a6957174de97.7uqL2nE_Yrln4Yle7SBKWivovRwHWixY8oHoThArE1g
- insights-trendsbarchart--bar-value-embedded-narrow--light:
- hash: v1.k794b7964.8cef593146d4fa32e26825979fe8519f9c39c7f915851e7a1f2073bb6130be30.XB_jDffyHCmxdTgf_2hhq1COBcZZHN75YO3KN2j8US8
insights-trendsbarchart--bar-value-single-breakdown--dark:
hash: v1.k794b7964.6ae67f2e37c4535b9d36b89f81179ecf45c1fdc42069cc5a8baa6b1f07ebf1b5.Nst28ZQ5fdw4jL5VQG-kVeI1Pb1cG5ochKjm0sTmYbI
insights-trendsbarchart--bar-value-single-breakdown--light:
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx
index 195d7511db2f..bd5c6348bdbb 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx
@@ -552,27 +552,6 @@ export const BarValue50Breakdowns: Story = {
render: () => renderTrendInsight(BAR_VALUE_50_BREAKDOWNS_INSIGHT),
}
-const SHORT_BREAKDOWN_LABELS = [
- ...Array.from({ length: 25 }, (_, index) => String(500 + index * 37)),
- 'Other (all remaining values)',
-]
-
-const BAR_VALUE_EMBEDDED_NARROW_INSIGHT = {
- ...BAR_VALUE_50_BREAKDOWNS_INSIGHT,
- id: 205,
- short_id: 'barValueEmbeddedNarrow',
- name: 'Users by screen height',
- result: BAR_VALUE_50_BREAKDOWNS.slice(0, SHORT_BREAKDOWN_LABELS.length).map((result, index) => ({
- ...result,
- label: SHORT_BREAKDOWN_LABELS[index],
- breakdown_value: SHORT_BREAKDOWN_LABELS[index],
- })),
-}
-
-export const BarValueEmbeddedNarrow: Story = {
- render: () => renderTrendsBarChart(BAR_VALUE_EMBEDDED_NARROW_INSIGHT, { embedded: true, width: 600 }),
-}
-
// A single breakdown row should still fill the standard chart height — the lone bar must not
// shrink. Guards the min-height floor on TrendsInsight--ActionsBarValue: drop it back to `auto`
// and this snapshot collapses to a thin one-row bar instead of filling the container.
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
index f77f29cafd5d..e039ea56a413 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx
@@ -63,7 +63,6 @@ interface TrendsBarChartProps {
const EMPTY_LABELS: string[] = []
const AGGREGATED_TOOLTIP_CONFIG = { pinnable: false, placement: 'cursor' as const }
-const EMBEDDED_MAX_CATEGORY_LABEL_WIDTH = 64
type AggregationLabelFn = (groupTypeIndex: number | null | undefined) => { plural: string }
@@ -302,7 +301,7 @@ export function TrendsBarChart({
yAxisLabel: trendsFilter?.yAxisLabel,
// Breakdown values become category (y-axis) labels here; truncate long ones (e.g. URLs)
// so they don't grow the margin and push the plot off screen. Full value shows on hover.
- maxCategoryLabelWidth: embedded ? EMBEDDED_MAX_CATEGORY_LABEL_WIDTH : MAX_CATEGORY_LABEL_WIDTH,
+ maxCategoryLabelWidth: MAX_CATEGORY_LABEL_WIDTH,
// Dashboard/card tiles are a fixed height, so cap the rows to those that fit. The full
// insight page is `embedded: false` — even when opened from a dashboard (dashboardId in
// the URL) — so it keeps the grow-to-fit-all behavior and renders every breakdown row.