Skip to content

Beeswarm Chart for React

A React beeswarm chart plots every observation as its own dot along one axis, nudged just enough that none overlap. Pass data as readonly BeeswarmPoint[]: the observations to plot, each drawn as one dot.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/beeswarm.json

Time to first value

Use the left and right arrow keys to move along a row, and up and down to move between rows.

  • Beeswarm
  • BeeswarmTable
  • beeswarmLegend
  • beeswarmOffsets
  • defaultBeeswarmLabels
  • +3 more

One swarm per group

Days from sign-up to first value for 178 accounts, by plan, with each plan's median. Switch the cohort and every account glides to its new value. Left and right move along a plan; up and down jump to the nearest value in the next plan.

Time to first value

Accounts that joined after the new onboarding

Colored by series

Employee NPS of 29 teams in one swarm, colored by department (fixed slots, with a legend). highlight keeps two teams in focus; hover any dot for its name.

Employee NPS by team

Spring pulse survey. Highlighted: the two support teams.

  • Engineering
  • Sales & marketing
  • Operations
  • G&A

Files to copy

14 folders · 30 files · 4 packages
From theme/src/
  • components/charts/{beeswarm.tsx, histogram.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/charts/histogram/
  • components/charts/kits/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/beeswarm.jsonRegistry item: beeswarm. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Props

PropTypeDefaultDescription
data (required)readonly BeeswarmPoint[]NoneThe observations to plot, each drawn as one dot.
groupsreadonly string[]the order groups first appear inSets the order of the rows (by group).
seriesreadonly BeeswarmSeries[][]Colour dots by series (fixed slots; up to 8, the rest fold into a grey "Other"). Without it every dot is color.
colorChartColor1Palette slot (1–8) when there are no series.
radiusnumber4.5Dot radius in px; dense swarms shrink towards 3 to keep their rows from growing too tall.
showMedianbooleantrueMark each row's median with a line.
includeZerobooleanfalseKeep 0 on the value axis.
highlightstring | string[]NoneEmphasise these points (by label or id); the rest step back.
valueLabelstringNoneNames the value axis.
format((n: number) => string)formatCompact in localeFormats a value for the labels, tooltips and data table: takes the number, returns the text shown.
localestring"en"Locale of the default number format.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<BeeswarmLabels>defaultBeeswarmLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultBeeswarmLabels. All 11 keys of BeeswarmLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
BeeswarmLabels keys and English defaults (11)
Pass any key in labels; the rest keep the defaults of defaultBeeswarmLabels.
KeyEnglish default
roleDescriptionbeeswarm chart
instructions({ rows }) => rows ? "Use the left and right arrow keys to move along a row, and up and down to move betwee...
hintTap a dot to read it
valueValue
medianMedian
rowSummary(count, median) => `${count} · median ${median}`
otherOther
pointPoint
groupGroup
seriesSeries
noDataNo data

BeeswarmTable props

PropTypeDefaultDescription
data (required)readonly BeeswarmPoint[]NoneThe observations to plot, each drawn as one dot.
format((n: number) => string)formatCompact in localeFormats a value for the labels, tooltips and data table: takes the number, returns the text shown.
labelsPartial<BeeswarmLabels>defaultBeeswarmLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultBeeswarmLabels. All 11 keys of BeeswarmLabels are listed in the key table under the props table.
localestring"en"Locale of the default number format.
seriesreadonly BeeswarmSeries[][]Colour dots by series (fixed slots; up to 8, the rest fold into a grey "Other"). Without it every dot is color.
groupsreadonly string[][]Sets the order of the rows (by group).
valueLabelstringNoneNames the value axis.
captionstringNoneHidden caption that names the table for screen readers.
classNamestringNoneAdds extra classes to the outer element.

Keyboard

KeysAction
TabFocus the chart. It is one tab stop; the arrow keys then read it.
Arrow keysAlong the value axis: step between dots in value order. Across groups (when there are several): jump to the nearest value in the next or previous group.
Home/EndJump to the first / last dot.
EscapeClear the reading.

Accessibility

  • The chart is a focusable figure named by its aria-label (the chart title), with a one-line reading hint as its description and, inside a ChartCard with a table view, aria-details pointing at that table; moving through it announces each value politely, once. Each move announces the dot's value and group; every group's count and median are available as text.
  • BeeswarmTable is the same data as a real table. Pass it to ChartCard's table prop and the Chart / Table tabs let anyone read every value without color or sight.
  • With reduced motion on, the dots start at their final positions and a data change jumps straight to the new state.

All exports on this page

  • Beeswarm — A beeswarm: every observation as its own dot along one value axis, nudged sideways just enough that no two overlap.
  • BeeswarmTable — Every point with its group, series and value, grouped by row and sorted by value.
  • beeswarmLegend — Legend items for a beeswarm's series (with the same "Other" fold as the chart).
  • beeswarmOffsets — Collision-free swarm offsets ("dodge"): each point, in order of x.
  • defaultBeeswarmLabels — The built-in English strings of Beeswarm; spread it into your own labels and change what you need.

When to use the beeswarm chart

  • Use it as a swarm plot to show how every order value, response time or salary is distributed per group, when a box plot would hide the individual points that explain a long tail.
  • Use it for a few hundred observations split by region or plan, with each row getting its own swarm and a median line, so readers can spot clusters and outliers in one glance.
  • Color dots by series when a second category matters, for example plan tier inside each region; up to eight series keep their own palette slot and the rest fold into a gray Other.
  • Skip it when you have thousands of points or only need summary statistics, because a Histogram or Box plot summarizes large samples without relying on individual dots being readable.
  • Pair it with ChartCard and BeeswarmTable for a table view, ChartLegend to explain the series colors, and a Select to switch which grouping drives the rows.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .