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(quill-charts): readable bar list values and a capped label column (#120303)

Sam Pennington40aee2b7dab2
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 22b7a2fbdf87..a22793a9f27d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -1060,6 +1060,10 @@ snapshots:
hash: v1.k794b7964.16c554b0bd1f8528c6e1d08289c6ec9fa2000f8b9af0dfc374852c88ecb98445.xJ2MACgsrbGtNe1FHLCl5uYcLY9454d1lk6I1lu33wI
components-hogcharts-barlist--share-of-total--light:
hash: v1.k794b7964.9dc5c7e4c3578e6b4170df55b54bb3028e7dfda478b4e7d7197dc40953139647.7yjEOpNKFJZaLt6XuiGJiSKZOhxemH1lVCDmQndgyEI
+ components-hogcharts-barlist--wide-with-one-long-label--dark:
+ hash: v1.k794b7964.da827e3a071b7de4e432a4b15af6c6e452d42ac7fd45f535f39c51b8aa06b746.6SDobIKa4IbJuipFFjjieWj1DMtgVcWBmwh7Xan1EQ4
+ components-hogcharts-barlist--wide-with-one-long-label--light:
+ hash: v1.k794b7964.163c8a1058bf5f2bf1d5cf8a1bde53ad2cc1f23a31b04ba44d149d346f950e92.B-juvp5CdUQ8hpm9Ryg-PYqcKww9Rrrl7pcJhLlswLM
components-hogcharts-boxplot--horizontal--dark:
hash: v1.k794b7964.30cbeacc1f375b50732dd7c20765bbedfc0dc626d4896c8fa9687aa5f9bfc001.FTUzztXbfM9Du-zf-HPWGeBiY0cPJRqb3Ybj7dYNln8
components-hogcharts-boxplot--horizontal--light:
diff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx
index 166343f6c223..f5678e284d75 100644
--- a/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx
+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx
@@ -75,6 +75,29 @@ export const NarrowWithLongLabels: Story = {
},
}
+// On a wide card the label column stops at 12rem, so one long label truncates instead of squeezing the bars.
+export const WideWithOneLongLabel: Story = {
+ render: () => {
+ const theme = useReactiveTheme()
+ return (
+ <Stage width={960} height={120}>
+ <BarList
+ series={[
+ ...BROWSERS.slice(0, 3),
+ {
+ key: 'long',
+ label: 'Browsers that report a custom user agent string from an embedded web view',
+ data: [420],
+ },
+ ]}
+ theme={theme}
+ config={{ valueDisplay: 'both' }}
+ />
+ </Stage>
+ )
+ },
+}
+
// Above the bar, a long label reads in full and the bar takes the full width of a narrow list.
export const LabelsOnTop: Story = {
render: () => {
diff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.tsx
index caa31d95968d..06f9c0bd9c4e 100644
--- a/packages/quill/packages/charts/src/charts/BarList/BarList.tsx
+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.tsx
@@ -167,7 +167,7 @@ function BarListInner<Meta = unknown>({
isTop
? { height: plotTop + rows.length * rowHeight }
: {
- gridTemplateColumns: 'fit-content(40%) minmax(0, 1fr) auto',
+ gridTemplateColumns: 'fit-content(min(40%, 12rem)) minmax(0, 1fr) auto',
gridTemplateRows: `repeat(${rows.length}, ${rowHeight}px)`,
}
}
@@ -201,7 +201,7 @@ function BarListInner<Meta = unknown>({
<div className="flex min-w-0 items-center gap-1.5" title={row.series.label}>
{renderLabel ? renderLabel(row.series) : <span className="truncate">{row.series.label}</span>}
</div>
- <div className="shrink-0 whitespace-nowrap text-right text-muted tabular-nums">
+ <div className="shrink-0 whitespace-nowrap text-right text-(--color-graph-axis-label) tabular-nums">
{valueDisplay === 'value'
? valueFormatter(row.value)
: formatShare(whole > 0 ? row.value / whole : 0)}
diff --git a/packages/quill/packages/charts/src/components/Legend/Legend.tsx b/packages/quill/packages/charts/src/components/Legend/Legend.tsx
index 63840f993c57..930eb8d4f2d3 100644
--- a/packages/quill/packages/charts/src/components/Legend/Legend.tsx
+++ b/packages/quill/packages/charts/src/components/Legend/Legend.tsx
@@ -89,7 +89,10 @@ export function Legend({
{item.label}
</span>
{item.secondaryLabel != null && item.secondaryLabel !== '' && (
- <span className="shrink-0 text-muted" data-attr="hog-chart-legend-secondary">
+ <span
+ className="shrink-0 text-(--color-graph-axis-label)"
+ data-attr="hog-chart-legend-secondary"
+ >
{item.secondaryLabel}
</span>
)}
diff --git a/packages/quill/packages/charts/src/docs/chart-types.md b/packages/quill/packages/charts/src/docs/chart-types.md
index cc81599cc9eb..9ebdbf79c754 100644
--- a/packages/quill/packages/charts/src/docs/chart-types.md
+++ b/packages/quill/packages/charts/src/docs/chart-types.md
@@ -86,7 +86,7 @@ It is a preset over a one-series stacked `BarChart` with `axisOrientation: 'hori
- `config.valueDisplay` picks the value column: `'value'` (default), `'percent'`, or `'both'` for `share · value`. `valueFormatter` formats the value part and the tooltip.
With `labelPosition: 'start'`, a list narrower than 28rem shows only the share for `'both'`, so the bar keeps its room. The root is a size container for this query, so it takes its width from its parent and not from its content.
- `renderLabel(series)` replaces the label cell content, for example with an icon or a link. The labels and values are DOM, outside the canvas, so a link in a label needs no overlay attribute.
-- `config.labelPosition: 'start'` (default) puts the label left of the bar and the value right of it. The label column sizes to its content up to 40% of the width and truncates past that. The value column sizes to its content, and the bar column takes the rest.
+- `config.labelPosition: 'start'` (default) puts the label left of the bar and the value right of it. The label column sizes to its content up to 40% of the width or 12rem, whichever is smaller, and truncates past that. The value column sizes to its content, and the bar column takes the rest.
- `config.labelPosition: 'top'` puts the label and the value on one line above the bar. Use it for long labels such as URL paths, or for narrow lists, because the bar and the label get the full width. The label line sits on top of the chart, so the tooltip shows only over the bar and its track.
- Each row is `config.rowHeight` tall (default 28, or 40 for `'top'`) and each bar is `config.barHeight` thick (default 12, or 8 for `'top'`). The chart takes its height from the rows, so it does not need a parent with a fixed height.
- The tooltip uses `hitArea: 'band'`, so a row reports its tooltip anywhere along its track. It shows the row label and the formatted value. A `tooltip` render prop replaces it, and `seriesData[0].series.meta` is the `meta` of the hovered row.