: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(quill-charts): add bar list for ranked rows on a neutral track (#115002)
Sam Pennington8931994aee8d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 4f1082b2bf2c..b4fcc826881d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1024,6 +1024,22 @@ snapshots:hash: v1.k794b7964.8130eafe275f6eb471a60a4eec4f54f07f243c664aba0a64e5431f7728b22fe0.5-iHw88oelBcXyENYl4mnYzsVNsQR7qDfpYyz4GPdWwcomponents-hogcharts-barchart--with-value-labels--light:hash: v1.k794b7964.6aff50b1c147df21230d149c147deb023f6308cd2e01983b58e65461dd4c7207.vLZ6XqXFhSTA3hr10RUEv9vzOgxKWYtUzWj0OvoCTU0+ components-hogcharts-barlist--default--dark:+ hash: v1.k794b7964.83b0ce9bcd74e135e48fcd9ce905cc30c483407c36fb5ae03244b5d6455cb2fb.NQyHxI6NRXl4I1UBUpgRVYEM9MJ2GHHfjFPSLn0kSBI+ components-hogcharts-barlist--default--light:+ hash: v1.k794b7964.e32b3e496c727cde81ed777ed179b22318e2aeac3c036587ac87bde505a2eb95.3gu5cEYroHTfrmqu9oZM34D7NuNuPiEctauWH3egCgE+ components-hogcharts-barlist--labels-on-top--dark:+ hash: v1.k794b7964.6eb79c46269093eba9c30e0e6de43004365df57f515358d9a5e1088eb873902b.cww3DlSkcd7ZYSeM1eI1lO8YCVxlqxschxlHs2ck-_g+ components-hogcharts-barlist--labels-on-top--light:+ hash: v1.k794b7964.da00e2acc37bdf35e07ff747d4f6238cf4e5d27f5ee1dff90b0d35447e0eb4b1.aVeFvv3u6JL9T6ZyGZbR7eZcLj-MSmSZjPdAw1FaY8g+ components-hogcharts-barlist--narrow-with-long-labels--dark:+ hash: v1.k794b7964.748379913986c20ad1a16bf0d0e51cdfcd5ca155cfe17e62addd1b4f6b653cc0.XsjnBPkQkTH9RydVpxoE6PUQynIkR-J9shg5qjDnddA+ components-hogcharts-barlist--narrow-with-long-labels--light:+ hash: v1.k794b7964.35aecaea08c8579eaa743e0e57ca2f75d94d9973b361c5381986b2c93e951fbe.pCqj_B-rDfQ0OOR74gfs58Ly0nziahD52uhWvdXCv0g+ components-hogcharts-barlist--share-of-total--dark:+ hash: v1.k794b7964.16c554b0bd1f8528c6e1d08289c6ec9fa2000f8b9af0dfc374852c88ecb98445.xJ2MACgsrbGtNe1FHLCl5uYcLY9454d1lk6I1lu33wI+ components-hogcharts-barlist--share-of-total--light:+ hash: v1.k794b7964.9dc5c7e4c3578e6b4170df55b54bb3028e7dfda478b4e7d7197dc40953139647.7yjEOpNKFJZaLt6XuiGJiSKZOhxemH1lVCDmQndgyEIcomponents-hogcharts-boxplot--horizontal--dark:hash: v1.k794b7964.30cbeacc1f375b50732dd7c20765bbedfc0dc626d4896c8fa9687aa5f9bfc001.FTUzztXbfM9Du-zf-HPWGeBiY0cPJRqb3Ybj7dYNln8components-hogcharts-boxplot--horizontal--light:diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.mdindex a18f798e6bd1..668e4c3888a5 100644--- a/packages/quill/packages/charts/AGENTS.md+++ b/packages/quill/packages/charts/AGENTS.md@@ -17,6 +17,7 @@ This file is the map. Prop-level semantics live in the JSDoc on the config and p| `FunnelChart` | Funnel steps as grouped bars over a hatched drop-off track — one band per step, one bar per variant, valued as percent of first step || `PieChart` | Part of whole, one value per series; `innerRadiusRatio` for a donut || `ProportionBar` | Part of whole as one flat 100% bar with no axes, legend rows show `share · value`; takes the same `series` as `PieChart` |+| `BarList` | Ranked rows of label, bar on a neutral track, and value; takes the same `series` as `PieChart`, one row per series || `ScatterChart` | Two continuous numeric axes — one marker per `{ x, y }` point; takes `points`, not `labels` || `BoxPlot` | Distribution summaries — `{ min, p25, median, mean, p75, max }` per label || `Heatmap` | 2D density grid (latency over time) — `xLabels` × `yLabels`, `cells[row][col]` |@@ -107,18 +108,18 @@ Import helpers from `@posthog/quill-charts/testing` (jsdom only): `getHogChart`## Docs index-| Doc | Covers |-| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |-| [src/README.md](./src/README.md) | Public surface, setup, theme, custom tooltip and overlay basics, sparkline |-| [docs/chart-types.md](./src/docs/chart-types.md) | Per-chart behavior: scatter, funnel, slope, pie, proportion bar, box plot, heatmap, sankey, sparkline, metric card |-| [docs/axes.md](./src/docs/axes.md) | Defaults, grid and axis chrome, x-axis labels, y format, baseline and range, multi-axis, margins, blank-plot diagnosis |-| [docs/bars.md](./src/docs/bars.md) | Layouts, per-bar overrides, `minBarSize`, `trackData`, hit-testing, trend lines, combo |-| [docs/tooltips.md](./src/docs/tooltips.md) | `config.tooltip`, `DefaultTooltip` props, custom pieces, context fields, touch |-| [docs/legend.md](./src/docs/legend.md) | Click model, controlled state, visibility groups, row rendering, layout caps |-| [docs/overlays.md](./src/docs/overlays.md) | Built-in overlays and writing a custom one |-| [docs/interactions.md](./src/docs/interactions.md) | Clicks, drag-to-zoom, 2D brush, hover |-| [docs/CONTRIBUTING.md](./src/docs/CONTRIBUTING.md) | Layers, conventions, adding a chart type |-| [docs/TESTING.md](./src/docs/TESTING.md) | The accessor contract and test recipes |+| Doc | Covers |+| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |+| [src/README.md](./src/README.md) | Public surface, setup, theme, custom tooltip and overlay basics, sparkline |+| [docs/chart-types.md](./src/docs/chart-types.md) | Per-chart behavior: scatter, funnel, slope, pie, proportion bar, bar list, box plot, heatmap, sankey, sparkline, metric card |+| [docs/axes.md](./src/docs/axes.md) | Defaults, grid and axis chrome, x-axis labels, y format, baseline and range, multi-axis, margins, blank-plot diagnosis |+| [docs/bars.md](./src/docs/bars.md) | Layouts, per-bar overrides, `minBarSize`, `trackData`, hit-testing, trend lines, combo |+| [docs/tooltips.md](./src/docs/tooltips.md) | `config.tooltip`, `DefaultTooltip` props, custom pieces, context fields, touch |+| [docs/legend.md](./src/docs/legend.md) | Click model, controlled state, visibility groups, row rendering, layout caps |+| [docs/overlays.md](./src/docs/overlays.md) | Built-in overlays and writing a custom one |+| [docs/interactions.md](./src/docs/interactions.md) | Clicks, drag-to-zoom, 2D brush, hover |+| [docs/CONTRIBUTING.md](./src/docs/CONTRIBUTING.md) | Layers, conventions, adding a chart type |+| [docs/TESTING.md](./src/docs/TESTING.md) | The accessor contract and test recipes |## Maintenancediff --git a/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx b/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsxindex 80c0817eea06..5590e8326915 100644--- a/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx+++ b/packages/quill/packages/charts/src/charts/BarChart/BarChart.tsx@@ -111,7 +111,8 @@ function BarChartInner<Meta = unknown>({fillStyle: barFillStyle = 'flat',} = config?.bars ?? {}const isHorizontal = axisOrientation === 'horizontal'- const barTrack = trackConfig !== false+ const solidTrack = trackConfig === 'solid'+ const barTrack = trackConfig !== false && !solidTrackconst barTrackHover = trackConfig === true || (typeof trackConfig === 'object' && trackConfig.hover !== false)const { visibleSeries, legendProps } = useChartLegend(series, theme, config?.legend)@@ -291,6 +292,7 @@ function BarChartInner<Meta = unknown>({roundStackEnds,barCornerRadius,barTrack,+ solidTrack,barShadow,barFillStyle,minBarSizeScope,@@ -305,6 +307,7 @@ function BarChartInner<Meta = unknown>({roundStackEnds,barCornerRadius,barTrack,+ solidTrack,xTickFormatter,barShadow,barFillStyle,diff --git a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.tsindex c0275d2edf32..8f0a7b68b576 100644--- a/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts+++ b/packages/quill/packages/charts/src/charts/BarChart/utils/draw-bar-chart.ts@@ -17,6 +17,7 @@ import {drawBars,drawBarTracks,drawGrid,+ drawSolidBarTracks,resolveAxisLineColor,type DrawContext,} from '../../../core/canvas-renderer'@@ -27,7 +28,7 @@ import { computeVisibleXLabels } from '../../../overlays/AxisLabels'import { resolveBarShadow } from './bar-config'import { type BarLayout } from './bars-under-cursor'import type { ResolvedBarHover } from './resolve-bar-hover'-import { stackPillRects } from './stack-pills'+import { ALL_CORNERS, stackPillRects } from './stack-pills'/** Category-axis grid ticks aligned to the visible labels rather than every band: all band* centers for horizontal charts, the de-duplicated visible x-labels for vertical ones so a@@ -77,6 +78,8 @@ function withBarShadow(ctx.restore()}+const SOLID_TRACK_FALLBACK_COLOR = 'rgba(0, 0, 0, 0.06)'+export interface DrawBarChartStaticArgs {barLayout: BarLayoutisHorizontal: boolean@@ -88,6 +91,7 @@ export interface DrawBarChartStaticArgs {roundStackEnds: booleanbarCornerRadius: numberbarTrack: boolean+ solidTrack: booleanbarShadow: BarsConfig['shadow']barFillStyle: BarFillStyleminBarSizeScope?: BarsConfig['minBarSizeScope']@@ -109,6 +113,7 @@ export function drawBarChartStatic(roundStackEnds,barCornerRadius,barTrack,+ solidTrack,barShadow,barFillStyle,minBarSizeScope,@@ -176,6 +181,20 @@ export function drawBarChartStatic(): []+ if (solidTrack) {+ const [axisStart = 0, axisEnd = 0] = d3Scales.value.range()+ const bandwidth = d3Scales.band.bandwidth()+ const tracks = drawLabels.flatMap((label, dataIndex) => {+ const start = d3Scales.band(label)+ if (start == null) {+ return []+ }+ const band = { x: start, y: start, width: bandwidth, height: bandwidth, corners: ALL_CORNERS, dataIndex }+ return [computeBarTrackRect(band, axisStart, axisEnd, isHorizontal)]+ })+ drawSolidBarTracks(ctx, tracks, theme.gridColor ?? SOLID_TRACK_FALLBACK_COLOR, barCornerRadius)+ }+// Tracks are a separate pass so a later series' full-height track can't paint// over an earlier series' bar. Track is "share of a whole" semantics — only// meaningful for grouped layouts; in stacked/percent every layer would paintdiff --git a/packages/quill/packages/charts/src/charts/BarChart/utils/stack-pills.ts b/packages/quill/packages/charts/src/charts/BarChart/utils/stack-pills.tsindex 14f8e23842f2..8e2142f6ee64 100644--- a/packages/quill/packages/charts/src/charts/BarChart/utils/stack-pills.ts+++ b/packages/quill/packages/charts/src/charts/BarChart/utils/stack-pills.ts@@ -1,6 +1,6 @@import { type BarRect, type BarRoundedCorners } from '../../../core/canvas-renderer'-const ALL_CORNERS: BarRoundedCorners = { topLeft: true, topRight: true, bottomLeft: true, bottomRight: true }+export const ALL_CORNERS: BarRoundedCorners = { topLeft: true, topRight: true, bottomLeft: true, bottomRight: true }/** One fully-rounded rect per band, spanning the union of that band's stacked segments — the* pill the bar layer is clipped to for `roundStackEnds`. Bars in the same band share a band-axisdiff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsxnew file mode 100644index 000000000000..166343f6c223--- /dev/null+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.stories.tsx@@ -0,0 +1,92 @@+import { Meta, StoryObj } from '@storybook/react'++import type { Series } from '../../core/types'+import { Stage, useReactiveTheme } from '../../story-helpers'+import { BarList } from './BarList'++const BROWSERS: Series[] = [+ { key: 'chrome', label: 'Chrome', data: [4812] },+ { key: 'safari', label: 'Safari', data: [1630] },+ { key: 'firefox', label: 'Firefox', data: [744] },+ { key: 'edge', label: 'Edge', data: [512] },+ { key: 'samsung', label: 'Samsung Internet', data: [133] },+ { key: 'opera', label: 'Opera', data: [61] },+ { key: 'other', label: 'Other browsers', data: [12] },+]++const LONG_LABELS: Series[] = [+ { key: 'pricing', label: '/pricing/compare-plans-and-features', data: [920] },+ { key: 'docs', label: '/docs/getting-started/installation-guide', data: [610] },+ { key: 'blog', label: '/blog/how-we-ship-small-changes-every-day', data: [280] },+ { key: 'home', label: '/', data: [95] },+]++const meta: Meta = { title: 'Components/HogCharts/BarList', parameters: { layout: 'centered' } }+export default meta++type Story = StoryObj++export const Default: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={480} height={200}>+ <BarList series={BROWSERS} theme={theme} config={{ valueDisplay: 'percent' }} />+ </Stage>+ )+ },+}++// The rows are the top four of a larger whole, so the track is that whole and the bars are shares of it.+export const ShareOfTotal: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={480} height={136}>+ <BarList+ series={BROWSERS.slice(0, 4)}+ theme={theme}+ total={7904}+ config={{ scale: 'total', valueDisplay: 'both', rowHeight: 32, barHeight: 16 }}+ renderLabel={(series) => (+ <>+ <span+ className="h-2 w-2 shrink-0 rounded-full"+ // eslint-disable-next-line react/forbid-dom-props -- per-row color+ style={{ background: series.color }}+ />+ <span className="truncate">{series.label}</span>+ </>+ )}+ />+ </Stage>+ )+ },+}++export const NarrowWithLongLabels: Story = {+ render: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={280} height={120}>+ <BarList series={LONG_LABELS} theme={theme} />+ </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: () => {+ const theme = useReactiveTheme()+ return (+ <Stage width={280} height={176}>+ <BarList+ series={LONG_LABELS}+ theme={theme}+ config={{ labelPosition: 'top', scale: 'total', valueDisplay: 'both' }}+ />+ </Stage>+ )+ },+}diff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsxnew file mode 100644index 000000000000..f2e288c19c8f--- /dev/null+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx@@ -0,0 +1,43 @@+import { fireEvent, screen, within } from '@testing-library/react'++import type { ChartTheme, Series } from '../../core/types'+import { mockRect, renderHogChart, waitForHogChartTooltip } from '../../testing'+import { BarList } from './BarList'++const THEME: ChartTheme = { colors: ['#22d3ee', '#f14f58', '#a78bfa', '#fbbf24'], backgroundColor: '#ffffff' }++// The excluded row draws no band, so `a`, `b` and `c` split the 400px mock rect into three rows.+const ROWS: Series[] = [+ { key: 'a', label: 'Row a', data: [600], meta: { id: 'a' } },+ { key: 'excluded', label: 'Excluded row', data: [50], meta: { id: 'excluded' }, visibility: { excluded: true } },+ { key: 'b', label: 'Row b', data: [100], meta: { id: 'b' } },+ { key: 'c', label: 'Row c', data: [100], meta: { id: 'c' } },+]+const INSIDE_B = { clientX: mockRect.width / 2, clientY: mockRect.height / 2 }++describe('BarList', () => {+ it.each([+ { name: 'the sum of the rows', total: undefined, valueText: '12.5% · 100' },+ { name: 'an explicit total', total: 1000, valueText: '10% · 100' },+ ])('shows the hovered row in the tooltip and its share of $name', async ({ total, valueText }) => {+ const { chart } = renderHogChart(+ <BarList series={ROWS} theme={THEME} total={total} config={{ valueDisplay: 'both' }} />,+ { nativeTooltip: true }+ )++ const tooltip = await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))++ expect(within(tooltip).getByText('Row b')).toBeTruthy()+ expect(within(tooltip).getByText('100')).toBeTruthy()+ expect(screen.getAllByText((_, el) => el?.textContent === valueText)).toHaveLength(2)+ })++ it('hands a custom tooltip the meta of the hovered row', async () => {+ const { chart } = renderHogChart(<BarList series={ROWS} theme={THEME} tooltip={() => <span>custom</span>} />)++ await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))+ const tooltip = await chart.waitForTooltip()++ expect(tooltip.seriesData[0].series.meta).toEqual({ id: 'b' })+ })+})diff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.tsxnew file mode 100644index 000000000000..caa31d95968d--- /dev/null+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.tsx@@ -0,0 +1,216 @@+/* eslint-disable react/forbid-dom-props -- row sizes and positions come from props */+import React, { useMemo } from 'react'++import { ChartErrorBoundary } from '../../core/ChartErrorBoundary'+import type { BarChartConfig, ChartTheme, Series, TooltipContext } from '../../core/types'+import { percentage } from '../../utils/format'+import { BarChart } from '../BarChart/BarChart'+import { partValue } from '../ProportionBar/proportion-bar-data'++export interface BarListConfig {+ /** `start` (default) puts the label left of the bar and the value right of it. `top` puts the+ * label and the value on one line above the bar, so the bar and a long label get the full width. */+ labelPosition?: 'start' | 'top'+ /** `max` (default) fills the track with the largest row, to compare the rows with each other.+ * `total` makes the track the whole, so each bar shows its share of `total`. */+ scale?: 'max' | 'total'+ /** What the value column shows: the formatted value, its share of the total, or both as+ * `share · value`. Default `value`. With `labelPosition: 'start'`, a list narrower than 28rem+ * shows only the share for `both`, and the tooltip still shows the value. */+ valueDisplay?: 'value' | 'percent' | 'both'+ /** Row height in px, label line included. Default 28, or 40 with `labelPosition: 'top'`. */+ rowHeight?: number+ /** Bar thickness in px. Default 12, or 8 with `labelPosition: 'top'`. */+ barHeight?: number+ /** Corner radius in px for the bar and its track. Default 4. */+ barCornerRadius?: number+ tooltip?: {+ enabled?: boolean+ }+}++/** Shares `series` and `valueFormatter` with `PieChart` and `ProportionBar`. */+export interface BarListProps<Meta = unknown> {+ /** One series per row, valued like a `PieChart` slice: the sum of `data`, floored at 0. Rows+ * keep the order of `series`, so sort them before you pass them in. */+ series: Series<Meta>[]+ theme: ChartTheme+ config?: BarListConfig+ /** The whole that each share is a fraction of. Defaults to the sum of the rows. Set it when the+ * rows are the top of a larger whole, so the shares stay true to that whole. */+ total?: number+ /** Formats a row's raw value in the value column and the tooltip. */+ valueFormatter?: (value: number) => string+ /** Content of a row's label cell, for example an icon and a link. Defaults to the series label.+ * The cell is a flex row that truncates, so wrap long text in a `truncate` element. */+ renderLabel?: (series: Series<Meta>) => React.ReactNode+ /** Replaces the default tooltip. `ctx.seriesData[0].series.meta` is the `meta` of the hovered row. */+ tooltip?: (ctx: TooltipContext<Meta>) => React.ReactNode+ /** `data-attr` applied to the chart wrapper. */+ dataAttr?: string+ onError?: (error: Error, info: React.ErrorInfo) => void+}++const DEFAULT_ROW_HEIGHT = { start: 28, top: 40 }+const DEFAULT_BAR_HEIGHT = { start: 12, top: 8 }+const TOP_LABEL_LINE_HEIGHT = 16+const TOP_LABEL_GAP = 4+const DEFAULT_CORNER_RADIUS = 4+const MIN_BAR_SIZE = 4+const BAR_SERIES_KEY = 'bar-list'++export function BarList<Meta = unknown>({ onError, ...rest }: BarListProps<Meta>): React.ReactElement {+ return (+ <ChartErrorBoundary onError={onError}>+ <BarListInner {...rest} onError={onError} />+ </ChartErrorBoundary>+ )+}++function defaultValueFormatter(value: number): string {+ return value.toLocaleString()+}++function formatShare(fraction: number): string {+ return fraction > 0 && fraction < 0.001 ? '<0.1%' : percentage(fraction, 1)+}++function BarListInner<Meta = unknown>({+ series,+ theme,+ config,+ total,+ valueFormatter = defaultValueFormatter,+ renderLabel,+ tooltip,+ dataAttr,+ onError,+}: BarListProps<Meta>): React.ReactElement | null {+ const labelPosition = config?.labelPosition ?? 'start'+ const {+ scale = 'max',+ valueDisplay = 'value',+ rowHeight = DEFAULT_ROW_HEIGHT[labelPosition],+ barHeight = DEFAULT_BAR_HEIGHT[labelPosition],+ barCornerRadius = DEFAULT_CORNER_RADIUS,+ tooltip: tooltipConfig,+ } = config ?? {}+ const isTop = labelPosition === 'top'++ const rows = useMemo(+ () =>+ series+ .map((s, index) => ({+ series: { ...s, color: s.color || theme.colors[index % theme.colors.length] },+ value: partValue(s),+ }))+ .filter((row) => !row.series.visibility?.excluded),+ [series, theme.colors]+ )+ const whole = total ?? rows.reduce((acc, row) => acc + row.value, 0)+ const domainMax = scale === 'total' ? whole : Math.max(0, ...rows.map((row) => row.value))++ const labels = useMemo(() => rows.map((row) => row.series.key), [rows])+ const barSeries = useMemo<Series<Meta>[]>(+ () => [+ {+ key: BAR_SERIES_KEY,+ label: '',+ data: rows.map((row) => row.value),+ bars: rows.map((row) => ({ color: row.series.color, meta: row.series.meta })),+ },+ ],+ [rows]+ )++ const barOffsetInRow = (rowHeight - barHeight) / 2+ const plotTop = isTop ? Math.max(0, TOP_LABEL_LINE_HEIGHT + TOP_LABEL_GAP - barOffsetInRow) : 0++ const barConfig = useMemo<BarChartConfig>(+ () => ({+ barLayout: 'stacked',+ axisOrientation: 'horizontal',+ hideXAxis: true,+ hideYAxis: true,+ showGrid: false,+ showAxisLines: false,+ showTickMarks: false,+ showCrosshair: false,+ margins: { top: plotTop, right: 0, bottom: 0, left: 0 },+ barCornerRadius,+ bars: {+ track: 'solid',+ bandPadding: Math.max(0, 1 - barHeight / rowHeight),+ minBandSize: 0,+ minBarSize: MIN_BAR_SIZE,+ roundStackEnds: true,+ valueDomain: { min: 0, max: domainMax > 0 ? domainMax : 1 },+ },+ tooltip: {+ enabled: tooltipConfig?.enabled !== false,+ hitArea: 'band',+ valueFormatter,+ labelFormatter: (key) => rows.find((row) => row.series.key === key)?.series.label ?? key,+ },+ }),+ [barCornerRadius, barHeight, rowHeight, plotTop, domainMax, tooltipConfig?.enabled, valueFormatter, rows]+ )++ if (rows.length === 0) {+ return null+ }++ return (+ <div+ className={isTop ? 'relative min-w-0 text-xs' : '@container grid min-w-0 items-center gap-x-3 text-xs'}+ style={+ isTop+ ? { height: plotTop + rows.length * rowHeight }+ : {+ gridTemplateColumns: 'fit-content(40%) minmax(0, 1fr) auto',+ gridTemplateRows: `repeat(${rows.length}, ${rowHeight}px)`,+ }+ }+ >+ <div+ className={+ isTop ? 'absolute inset-0 flex flex-col' : 'col-start-2 row-start-1 flex flex-col self-stretch'+ }+ style={isTop ? undefined : { gridRowEnd: `span ${rows.length}` }}+ >+ <BarChart+ series={barSeries}+ labels={labels}+ theme={theme}+ config={barConfig}+ tooltip={tooltip}+ dataAttr={dataAttr}+ onError={onError}+ />+ </div>+ {rows.map((row, i) => (+ <div+ key={row.series.key}+ className={isTop ? 'absolute inset-x-0 flex h-4 items-center justify-between gap-2' : 'contents'}+ style={+ isTop+ ? { top: plotTop + i * rowHeight + barOffsetInRow - TOP_LABEL_GAP - TOP_LABEL_LINE_HEIGHT }+ : undefined+ }+ >+ <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">+ {valueDisplay === 'value'+ ? valueFormatter(row.value)+ : formatShare(whole > 0 ? row.value / whole : 0)}+ {valueDisplay === 'both' ? (+ <span className={isTop ? undefined : '@max-md:hidden'}> · {valueFormatter(row.value)}</span>+ ) : null}+ </div>+ </div>+ ))}+ </div>+ )+}diff --git a/packages/quill/packages/charts/src/core/canvas-renderer.ts b/packages/quill/packages/charts/src/core/canvas-renderer.tsindex fa877ebef56d..4db3c2011ae9 100644--- a/packages/quill/packages/charts/src/core/canvas-renderer.ts+++ b/packages/quill/packages/charts/src/core/canvas-renderer.ts@@ -1229,8 +1229,8 @@ export function clipToRoundedRects(ctx: CanvasRenderingContext2D, rects: BarRectctx.clip()}-/** Paints each track rect as a single solid colour — the neutral "remainder of the whole"- * backdrop for funnel-style stacked bars (one track per band behind the stack), as opposed+/** Paints each track rect as a single solid colour: the neutral "remainder of the whole"+ * backdrop for `bars.track: 'solid'` (one track per band behind every bar in it), as opposed* to {@link drawBarTracks}'s per-series tinted+hatched treatment for grouped layouts. */export function drawSolidBarTracks(ctx: CanvasRenderingContext2D,diff --git a/packages/quill/packages/charts/src/core/types.ts b/packages/quill/packages/charts/src/core/types.tsindex cbbbfbdf5302..588abd0ee35c 100644--- a/packages/quill/packages/charts/src/core/types.ts+++ b/packages/quill/packages/charts/src/core/types.ts@@ -437,8 +437,10 @@ export interface BarsConfig {* `barLayout: 'grouped'`; ignored for stacked/percent (the "share of a whole"* semantics don't apply when bars share a band). Defaults to `false`. `true` also* highlights the track region on hover; pass `{ hover: false }` to draw the track- * but leave it inert (no highlight when the cursor is over the empty remainder). */- track?: boolean | { hover?: boolean }+ * but leave it inert (no highlight when the cursor is over the empty remainder).+ * `'solid'` draws one neutral track per band instead, in `theme.gridColor`, behind every bar+ * in the band. It works on every layout, ignores `trackData`, and has no hover highlight. */+ track?: boolean | 'solid' | { hover?: boolean }/** Drop shadow under each bar so it reads as layered over a `track`. */shadow?: boolean | { color: string; blur: number; offsetX?: number; offsetY?: number }/** Bar fill treatment. `flat` (default) is a solid color. `gradient` is a smooth diagonaldiff --git a/packages/quill/packages/charts/src/docs/bars.md b/packages/quill/packages/charts/src/docs/bars.mdindex 395851306e33..80ea0d01bd94 100644--- a/packages/quill/packages/charts/src/docs/bars.md+++ b/packages/quill/packages/charts/src/docs/bars.md@@ -33,6 +33,12 @@ A breakdown stack floors only its top segment, so the option is aimed at single-The static layer draws true sizes and a tiny bar grows to a clickable nub under the cursor; while its track is hovered, the floored bar is also revealed in its plain color.The default `'always'` floors the static layer too.+## Solid track++`bars.track: 'solid'` draws one neutral track per band, in `theme.gridColor`, behind every bar in the band, on any layout.+It is the "remainder of the whole" backdrop for horizontal bar lists, as in `BarList`.+Unlike the hatched track it ignores `trackData` and has no hover highlight.+## Interactive extent: `trackData``Series.trackData[i]` caps a bar's interactive extent at a per-bar ceiling in value units.diff --git a/packages/quill/packages/charts/src/docs/chart-types.md b/packages/quill/packages/charts/src/docs/chart-types.mdindex d9f0528c7d5e..5732c7dd52ca 100644--- a/packages/quill/packages/charts/src/docs/chart-types.md+++ b/packages/quill/packages/charts/src/docs/chart-types.md@@ -74,6 +74,23 @@ It takes the same `series` as `PieChart` and sizes each part the same way as a p- A `tooltip` render prop receives the hovered part as `seriesData[0]`, with its raw `value` and its `fraction` of the visible parts, as on `PieChart`.- `barHeight` sets the bar thickness. The chart takes its height from the bar and the legend, so it does not need a parent with a fixed height. It does not grow to fill a flex parent either, so the legend stays next to the bar; center the pair in the parent if you want it in the middle.+## BarList++Ranked rows: a label, a bar on a neutral track, and a value, one row per series.+It is a preset over a one-series stacked `BarChart` with `axisOrientation: 'horizontal'` and `bars.track: 'solid'`.++- It takes the same `series` as `PieChart` and values a row the same way, as the sum of its data floored at 0. Rows keep the order of `series`, so sort them first.+- `config.scale: 'max'` (default) fills the track with the largest row. `'total'` makes the track the whole, so a bar shows its share.+- `total` sets the whole that shares are taken of. It defaults to the sum of the rows. Set it when the rows are the top of a larger whole.+- `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: '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.+- A non-zero row stays at least 4px long, so a row with a tiny share still shows next to the largest row.+## BoxPlotDistribution summaries: `{ min, p25, median, mean, p75, max }` per label.diff --git a/packages/quill/packages/charts/src/index.ts b/packages/quill/packages/charts/src/index.tsindex 4d3de7377cbe..422eeca3be3e 100644--- a/packages/quill/packages/charts/src/index.ts+++ b/packages/quill/packages/charts/src/index.ts@@ -117,6 +117,10 @@ export type { RadialSlicePayload } from './core/hooks/useRadialInteraction'export { ProportionBar } from './charts/ProportionBar/ProportionBar'export type { ProportionBarConfig, ProportionBarProps } from './charts/ProportionBar/ProportionBar'+// Bar list+export { BarList } from './charts/BarList/BarList'+export type { BarListConfig, BarListProps } from './charts/BarList/BarList'+// Sankeyexport { SankeyChart } from './charts/SankeyChart/SankeyChart'export type {