: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
fix(insights): remove max-height cap on bar-value chart container (#66104)
Sam Pennington464f50368c64
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 1837d4c4861a..aaac0088b8b7 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2596,6 +2596,14 @@ snapshots:hash: v1.k794b7964.d8d3e3ecade64da3301879f5c9a72a9e0a4f879fd23adc9c22940150ced641c4._P8QZDgkeQ4Z5Ii0RfD5kHotcs8VMJdg7y7F9UhxXyEinsights-trendsbarchart--aggregated-compare-breakdown--light:hash: v1.k794b7964.71df39ed07e55a63f5769f6771aa97fafb3b45f83bb3316e820b1d5c62eacc17.fqe0WSxWna4P6aIUpMidVoxtseV69UR9iFJyEX0uXv8+ insights-trendsbarchart--bar-value-50-breakdowns--dark:+ hash: v1.k794b7964.0aa74828d652bcc08c7edf6e846f25079cd634404524a2f46ecfab9ca58b3253.RC1OqPi8ALE8mT4L0qBcaNeMFwNYDmyvdY32qCX8Lao+ insights-trendsbarchart--bar-value-50-breakdowns--light:+ hash: v1.k794b7964.da48bff1f9643e5f27c0371f29bee5b1478389736d9e9baf4d159effe918f7f9.DTLbuDHBCHUpqdykg69Lzh-lasHbn-AzA9k50D9Eig8+ insights-trendsbarchart--bar-value-single-breakdown--dark:+ hash: v1.k794b7964.e2b8f5afe06a39c4cf3ae1beb282fed9a64117a91ac92ffa91a8f9fa0a09a69d.QWoL7QbuoCoXDv6xoLFepkGX5DRp5NfndCYdz1TZjE4+ insights-trendsbarchart--bar-value-single-breakdown--light:+ hash: v1.k794b7964.13733d2478cb0d86b2fbed8cae08efb73555fbd2798dc199118ccde0bf192b6b.ujkbY4JXzzAH9hNg6G5F5z4q6Lt4CkeCQMYu_H0cAocinsights-trendsbarchart--compare--dark:hash: v1.k794b7964.471bac2dc88d109f8b59fb9824be9b97aa91a0e92e71053ccfa7483c5d1a33a7.lBVLXYRSp4frYlGbUwXnYMibF-b5l_ZyGDNqL8q3rLIinsights-trendsbarchart--compare--light:diff --git a/frontend/src/queries/nodes/InsightViz/InsightViz.scss b/frontend/src/queries/nodes/InsightViz/InsightViz.scssindex be3cbdaee61f..f90d4bad9465 100644--- a/frontend/src/queries/nodes/InsightViz/InsightViz.scss+++ b/frontend/src/queries/nodes/InsightViz/InsightViz.scss@@ -229,6 +229,15 @@margin: 0;}+ &--ActionsBarValue {+ // Keep the standard height as a floor so a few-row chart still fills it (a single bar+ // shouldn't shrink), but drop the height/max-height cap so many breakdown rows grow the+ // container instead of being clipped.+ height: auto;+ min-height: var(--insight-viz-min-height);+ max-height: none;+ }+&--BoldNumber {display: flex;align-items: center;diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsxindex 86d276b9413b..4050204e1a6e 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx@@ -1,8 +1,9 @@import { Meta, StoryObj } from '@storybook/react'import { BindLogic } from 'kea'-import { useState } from 'react'+import { type CSSProperties, useState } from 'react'import { insightLogic } from 'scenes/insights/insightLogic'+import { TrendInsight } from 'scenes/trends/Trends'import { mswDecorator } from '~/mocks/browser'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'@@ -10,6 +11,7 @@ import type { DataNodeLogicProps } from '~/queries/nodes/DataNode/dataNodeLogic'import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'import { getCachedResults } from '~/queries/nodes/InsightViz/utils'import type { InsightLogicProps, InsightShortId } from '~/types'+import { InsightType } from '~/types'import { TrendsBarChart } from './TrendsBarChart'@@ -113,6 +115,33 @@ function renderTrendsBarChart(insightFixture: any): JSX.Element {)}+function renderTrendInsight(insightFixture: any): JSX.Element {+ const [dashboardItemId] = useState(() => `TrendsBarChartStory.${uniqueNode++}` as InsightShortId)+ const cachedInsight = { ...insightFixture, short_id: dashboardItemId }++ const insightProps: InsightLogicProps = { dashboardItemId, doNotLoad: true, cachedInsight }+ const dataNodeLogicProps: DataNodeLogicProps = {+ query: cachedInsight.query.source,+ key: insightVizDataNodeKey(insightProps),+ cachedResults: getCachedResults(cachedInsight, cachedInsight.query.source),+ doNotLoad: true,+ }++ return (+ <BindLogic logic={insightLogic} props={insightProps}>+ <BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>+ {/* TrendInsight renders `.TrendsInsight` but not the `.InsightVizDisplay` ancestor that+ defines `--insight-viz-min-height`. Define it here so the chart's height behaves like the+ real insight page — without it the standard-height floor no-ops and a single bar collapses. */}+ {/* eslint-disable-next-line react/forbid-dom-props */}+ <div style={{ width: 720, '--insight-viz-min-height': '32rem' } as CSSProperties}>+ <TrendInsight view={InsightType.TRENDS} />+ </div>+ </BindLogic>+ </BindLogic>+ )+}+const CURRENT_DAYS = ['2023-07-04', '2023-07-05', '2023-07-06', '2023-07-07', '2023-07-08', '2023-07-09', '2023-07-10']const CURRENT_LABELS = ['4-Jul-2023',@@ -453,3 +482,77 @@ const PERCENT_STACK_BREAKDOWN_INSIGHT = {export const PercentStackBreakdown: Story = {render: () => renderTrendsBarChart(PERCENT_STACK_BREAKDOWN_INSIGHT),}++// 50 breakdown rows — verifies all bars are visible and the container grows rather than clipping.+// If TrendsInsight--ActionsBarValue loses its max-height:none override, only ~20 rows show up.+const BAR_VALUE_50_BREAKDOWNS = Array.from({ length: 50 }, (_, i) => ({+ action: ACTION,+ label: `/blog/post-${String(i + 1).padStart(2, '0')}`,+ count: 0,+ aggregated_value: Math.max(5, Math.round(9000 / (i + 1))),+ data: [],+ labels: [],+ days: [],+ breakdown_value: `/blog/post-${String(i + 1).padStart(2, '0')}`,+ filter: {+ date_from: '2023-07-04T00:00:00Z',+ date_to: '2023-07-10T23:59:59Z',+ display: 'ActionsBarValue',+ insight: 'TRENDS',+ interval: 'day',+ },+}))++const BAR_VALUE_50_BREAKDOWNS_INSIGHT = {+ id: 203,+ short_id: 'barValue50',+ name: 'Page views by URL (50 breakdowns)',+ derived_name: 'Pageview count',+ filters: {},+ last_refresh: '2023-07-11T12:00:00Z',+ refreshing: false,+ saved: true,+ is_sample: false,+ description: '',+ tags: [],+ favorited: false,+ created_at: '2023-07-11T12:00:00Z',+ updated_at: '2023-07-11T12:00:00Z',+ last_modified_at: '2023-07-11T12:00:00Z',+ dashboards: [],+ dashboard_tiles: [],+ result: BAR_VALUE_50_BREAKDOWNS,+ query: {+ kind: 'InsightVizNode',+ source: {+ dateRange: { date_from: '2023-07-04', date_to: '2023-07-10' },+ filterTestAccounts: false,+ interval: 'day',+ kind: 'TrendsQuery',+ series: [{ event: '$pageview', kind: 'EventsNode', math: 'total', name: '$pageview' }],+ trendsFilter: { display: 'ActionsBarValue' },+ breakdownFilter: { breakdown: '$current_url', breakdown_type: 'event' },+ version: 2,+ },+ full: true,+ },+}++export const BarValue50Breakdowns: Story = {+ render: () => renderTrendInsight(BAR_VALUE_50_BREAKDOWNS_INSIGHT),+}++// 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.+const BAR_VALUE_SINGLE_BREAKDOWN_INSIGHT = {+ ...BAR_VALUE_50_BREAKDOWNS_INSIGHT,+ id: 204,+ short_id: 'barValueSingle',+ name: 'Page views by URL (single breakdown)',+ result: BAR_VALUE_50_BREAKDOWNS.slice(0, 1),+}++export const BarValueSingleBreakdown: Story = {+ render: () => renderTrendInsight(BAR_VALUE_SINGLE_BREAKDOWN_INSIGHT),+}