Beeswarm
Non-overlapping dot distribution along a linear or log axis with row grouping, animated metric switching, category filtering, and range brushing.
import { Beeswarm } from '@uthereal/ui/beeswarm'Beeswarm playground
18 shown
| Name | Category | MRR | Seats | NPS |
|---|---|---|---|---|
| Moss Design | Self-serve | $760 | 9 | 82 |
| Tundra Maps | Self-serve | $1,180 | 15 | 64 |
| Drift Studio | Self-serve | $1,450 | 18 | 84 |
| Finch Docs | Self-serve | $1,720 | 21 | 88 |
| Clover Ops | Self-serve | $2,100 | 26 | 67 |
| Willow Support | Self-serve | $2,850 | 34 | 73 |
| Harbor Commerce | Mid-market | $4,900 | 62 | 63 |
| Lumen Robotics | Mid-market | $7,200 | 86 | 77 |
| Redwood Analytics | Mid-market | $8,300 | 98 | 80 |
| Mariner Logistics | Mid-market | $9,400 | 115 | 66 |
| Banyan Grid | Mid-market | $11,200 | 142 | 72 |
| Quartz Payments | Mid-market | $12,900 | 165 | 69 |
| Cinder Rail | Enterprise | $21,900 | 280 | 71 |
| Kestrel Bio | Enterprise | $26,400 | 310 | 81 |
| Helio Freight | Enterprise | $34,800 | 440 | 68 |
| Solstice Health | Enterprise | $41,200 | 510 | 85 |
| Northwind Labs | Enterprise | $48,200 | 620 | 74 |
| Monolith Energy | Enterprise | $61,500 | 840 | 79 |
Overview
A beeswarm plots every item in a population as an individual dot, packed without overlap along one continuous horizontal axis. Switching the active metric or grouping attribute flies every dot on its own spring in a left-to-right wave to its new position. Clicking a category in the legend hides its dots and re-packs the remaining swarm, while hovering or focusing a legend button isolates that category. Dragging across the plot brushes a metric range, dims dots outside the selection, and updates the live summary readout. A native data table lists every visible item across all configured metrics in value order.
Use a beeswarm to reveal clusters, gaps, and individual outliers across up to 400 items such as accounts, deals, or requests. For aggregate group totals without individual items, use a bar chart. For smoothed density curves across very large populations, use a ridgeline chart.
Usage
import { useState } from 'react'
import { Beeswarm, type BeeswarmDatum } from '@uthereal/ui/beeswarm'
const metrics = [
{
key: 'mrr',
label: 'MRR',
scale: 'log' as const,
valueFormat: {
style: 'currency' as const,
currency: 'USD',
maximumFractionDigits: 0,
},
},
{ key: 'seats', label: 'Seats', scale: 'log' as const },
]
const categories = [
{ key: 'enterprise', label: 'Enterprise' },
{ key: 'mid', label: 'Mid-market' },
{ key: 'self', label: 'Self-serve' },
]
export function CustomerSwarm({ data }: { data: BeeswarmDatum[] }) {
const [metric, setMetric] = useState('mrr')
return (
<Beeswarm
label="Customers by MRR"
data={data}
metrics={metrics}
metric={metric}
categories={categories}
groupBy="region"
summarize={(items, brushed) =>
`${items.length} ${brushed ? 'selected' : 'accounts'}`
}
onBrushChange={(range, selected) => console.log(range, selected.length)}
/>
)
}Give every datum a stable id so dots retain identity when metric, groupBy, or data updates. Changing metric clears any active brush because the horizontal axis changes units. Pass brush and onBrushChange to control the brushed range from the host, or hiddenCategories and onHiddenCategoriesChange to control legend filtering.
Examples
Grouped rows, initial brush, and data table
Set groupBy and groupOrder to split the distribution into ordered horizontal lanes, pair a linear metric with a unit suffix, pre-select a range with defaultBrush, and enable tableToggle to expose the native data table below the plot.
7 selected
| Name | Category | region | p95 latency |
|---|---|---|---|
| US East (iad) | Edge | Americas | 28 ms |
| London (lhr) | Edge | Europe | 34 ms |
| US West (sfo) | Edge | Americas | 44 ms |
| Tokyo (hnd) | Edge | APAC | 48 ms |
| Frankfurt (fra) | Edge | Europe | 52 ms |
| Singapore (sin) | Edge | APAC | 67 ms |
| Chicago (ord) | Origin | Americas | 86 ms |
| Paris (cdg) | Origin | Europe | 94 ms |
| Stockholm (arn) | Origin | Europe | 112 ms |
| Sydney (syd) | Origin | APAC | 129 ms |
| Sao Paulo (gru) | Origin | Americas | 138 ms |
| Mumbai (bom) | Origin | APAC | 156 ms |
Behavior
Packing runs once per metric, grouping, category filter, or container width change. Each dot is placed in ascending x order at the vertical offset closest to its row's center line without overlapping neighbors within one diameter. Dot radius scales with container width (2.4 px to 4.6 px) and automatically shrinks down to 1.4 px until the densest row fits inside its vertical band. Pointer hover selects the nearest dot within 24 px so small dots remain easy to target.
Log scales (scale: "log") place ticks on 1, 2, 5 steps (or powers of ten across wide spans). Linear scales (scale: "linear") choose clean intervals starting at zero unless values dip below zero. Categories take --ui-series-1 through --ui-series-8 in declared order and fall back to --ui-series-other unless a category specifies its own color; colors stay bound to categories when items are filtered.
Dragging across empty plot space creates a brush; dragging inside an active brush pans the window across the axis. Clicking outside the brush, double-clicking the plot, or pressing Escape clears the selection. On touch screens, tapping inspects the nearest dot and dragging horizontally brushes while vertical page scrolling remains free. When no items are visible, the plot renders emptyLabel ("Nothing to show").
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Beeswarm chart" | Names the chart for assistive technology and captions the data table when title is omitted. |
title | string— | Optional visible figure heading above the legend and plot. Omit it to render without a heading while keeping label for assistive technology. |
description | string— | One or two sentences on what the chart shows, below the title; omit it when the title says enough. |
data | BeeswarmDatum[]Default: [{"id":"northwind","label":"Northwind Labs","category":"enterprise","values":{"mrr":48200,"seats":620,"nps":74},"groups":{"region":"Americas"}},{"id":"helio","label":"Helio Freight","category":"enterprise","values":{"mrr":34800,"seats":440,"nps":68},"groups":{"region":"Europe"}},{"id":"kestrel","label":"Kestrel Bio","category":"enterprise","values":{"mrr":26400,"seats":310,"nps":81},"groups":{"region":"Americas"}},{"id":"alder","label":"Alder Financial","category":"enterprise","values":{"mrr":19500,"seats":250,"nps":62},"groups":{"region":"Europe"}},{"id":"monolith","label":"Monolith Energy","category":"enterprise","values":{"mrr":61500,"seats":840,"nps":79},"groups":{"region":"Americas"}},{"id":"cinder","label":"Cinder Rail","category":"enterprise","values":{"mrr":28900,"seats":375,"nps":71},"groups":{"region":"APAC"}},{"id":"solstice","label":"Solstice Health","category":"enterprise","values":{"mrr":41200,"seats":510,"nps":85},"groups":{"region":"APAC"}},{"id":"verge","label":"Verge Cloud","category":"enterprise","values":{"mrr":15800,"seats":190,"nps":59},"groups":{"region":"Europe"}},{"id":"mariner","label":"Mariner Logistics","category":"mid","values":{"mrr":9400,"seats":115,"nps":66},"groups":{"region":"Americas"}},{"id":"lumen","label":"Lumen Robotics","category":"mid","values":{"mrr":7200,"seats":86,"nps":77},"groups":{"region":"Europe"}},{"id":"cobalt","label":"Cobalt Retail","category":"mid","values":{"mrr":5800,"seats":74,"nps":54},"groups":{"region":"Americas"}},{"id":"banyan","label":"Banyan Grid","category":"mid","values":{"mrr":11200,"seats":142,"nps":72},"groups":{"region":"APAC"}},{"id":"harbor","label":"Harbor Commerce","category":"mid","values":{"mrr":4900,"seats":62,"nps":63},"groups":{"region":"Europe"}},{"id":"redwood","label":"Redwood Analytics","category":"mid","values":{"mrr":8300,"seats":98,"nps":80},"groups":{"region":"Americas"}},{"id":"quartz","label":"Quartz Payments","category":"mid","values":{"mrr":12900,"seats":165,"nps":69},"groups":{"region":"Europe"}},{"id":"stratos","label":"Stratos Air","category":"mid","values":{"mrr":6500,"seats":78,"nps":58},"groups":{"region":"APAC"}},{"id":"fable","label":"Fable Media","category":"mid","values":{"mrr":4100,"seats":52,"nps":75},"groups":{"region":"Americas"}},{"id":"meadow","label":"Meadow Foods","category":"mid","values":{"mrr":5300,"seats":68,"nps":61},"groups":{"region":"APAC"}},{"id":"drift","label":"Drift Studio","category":"self","values":{"mrr":1450,"seats":18,"nps":84},"groups":{"region":"Americas"}},{"id":"pollen","label":"Pollen Craft","category":"self","values":{"mrr":890,"seats":11,"nps":71},"groups":{"region":"Europe"}},{"id":"kiln","label":"Kiln Notes","category":"self","values":{"mrr":620,"seats":8,"nps":78},"groups":{"region":"Americas"}},{"id":"clover","label":"Clover Ops","category":"self","values":{"mrr":2100,"seats":26,"nps":67},"groups":{"region":"Europe"}},{"id":"tundra","label":"Tundra Maps","category":"self","values":{"mrr":1180,"seats":15,"nps":64},"groups":{"region":"APAC"}},{"id":"pebble","label":"Pebble Metrics","category":"self","values":{"mrr":480,"seats":6,"nps":52},"groups":{"region":"Americas"}},{"id":"finch","label":"Finch Docs","category":"self","values":{"mrr":1720,"seats":21,"nps":88},"groups":{"region":"Europe"}},{"id":"spark","label":"Spark Ledger","category":"self","values":{"mrr":940,"seats":12,"nps":60},"groups":{"region":"APAC"}},{"id":"willow","label":"Willow Support","category":"self","values":{"mrr":2850,"seats":34,"nps":73},"groups":{"region":"Americas"}},{"id":"moss","label":"Moss Design","category":"self","values":{"mrr":760,"seats":9,"nps":82},"groups":{"region":"APAC"}}] | Items plotted as individual dots (up to 400, unique IDs). Each item has a stable id, label, category key, numeric values per metric, and optional groups attributes. |
metrics | BeeswarmMetric[]Default: [{"key":"mrr","label":"MRR","scale":"log","valueFormat":{"style":"currency","currency":"USD","maximumFractionDigits":0}},{"key":"seats","label":"Seats","scale":"log"},{"key":"nps","label":"NPS","scale":"linear"}] | Measures available on the horizontal axis (1–12, unique keys), each with key, label, scale ("linear" or "log"), optional unit suffix, and optional Intl valueFormat. |
metric | string— | Key of the active metric plotted on the horizontal axis. Defaults to the first entry in metrics; changing it clears any active brush and re-packs every dot in a wave. |
categories | BeeswarmCategory[]Default: [{"key":"enterprise","label":"Enterprise"},{"key":"mid","label":"Mid-market"},{"key":"self","label":"Self-serve"}] | Legend entries and dot hues (1–12, unique keys). Colors follow the category order (series1–series8, then seriesOther) and never shift when categories are hidden. |
groupBy | string | nullDefault: null | Attribute key inside each datum’s groups object to split the swarm into horizontal rows, or null for a single swarm. |
groupOrder | Record<string, string[]>— | Explicit row order per groupBy attribute; unlisted group values follow in order of appearance. |
defaultBrush | [number, number] | nullDefault: null | Initial brushed [low, high] range in active metric units when uncontrolled. Later argument edits do not reset a mounted instance. |
defaultHiddenCategories | string[]Default: [] | Initial hidden category keys when uncontrolled. Hidden dots shrink away and remaining dots re-pack; later edits do not reset a mounted instance. |
height | integerDefault: 340 | Plot height in pixels (160–800), shared across all rows including the 28 px bottom axis. |
emptyLabel | stringDefault: "Nothing to show" | Shown centered over the plot when every category is hidden or data is empty. |
tableToggle | booleanDefault: false | Show a button that reveals the data table. The table is always available to assistive technology. |
tableLabel | stringDefault: "Data table" | Name of the data table button. |
locale | string— | BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default). |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | BeeswarmTheme— | Color mode, accent, and semantic tokens including the chart palette (series1–series8) and hairline borders. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Reveal, dot-wave spring, and tooltip glide preset. System reduced-motion preferences take precedence. |
motionOptions | BeeswarmMotionOptions— | draw and morph transitions; when morph is a spring, its stiffness and damping drive the per-dot beeswarm physics. |
dir | ltr | rtl— | Reading direction for headings, legend, readout, tooltips, row labels, and table. The numeric axis remains left to right; omit to inherit page direction. |
React integration
| Prop | Purpose |
|---|---|
brush | Controlled brushed [low, high] range in active metric units, or null |
onBrushChange | Fires with (range, selected) while brushing and (null, []) when cleared |
hiddenCategories | Controlled array of hidden category keys |
onHiddenCategoriesChange | Fires with the updated hidden category keys when a legend toggle is pressed |
summarize | Custom summary builder (items, brushed) => string for the live readout line |
formatValue | Custom formatter (value, metric) => string for tooltips, ticks, and table |
preset | Application defaults, overridden by explicit instance props |
tokens | CSS variables applied after the typed theme |
ref | Ref forwarded to the root <figure> |
className, style | Applied to the root <figure> |
| Native attributes | id, data-*, and remaining <figure> attributes forwarded to the root |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Move focus across legend toggles, the plot, and optional table button |
ArrowLeft, ArrowRight | Move to the previous or next visible dot in ascending metric order |
ArrowUp, ArrowDown | Move to the nearest dot horizontally in the row above or below |
Shift + ArrowLeft, ArrowRight | Extend a brushed range from the starting dot |
Home, End | Jump to the lowest or highest visible value |
Escape | Clear the focused dot and any active brush |
The chart renders a <figure> named by title (or visually hidden label when title is omitted) and linked via aria-details to a native data table listing Name, Category, the active groupBy column when set, and every configured metric in ascending value order. Category legend buttons expose aria-pressed and item counts.
The plot is a single focusable group (aria-roledescription="beeswarm"). Moving focus across dots shows a matching category halo ring, tracks the tooltip inside the plot bounds, and announces the item name, active metric value, category, and row in a polite role="status" live region. The summary line above the plot is also a polite live region announcing brushed counts and custom summaries. Headings, legend, readout, row labels, tooltips, and tables follow dir="rtl", while the numeric horizontal axis stays left to right. Under forced-colors: active, system colors (Canvas, CanvasText, Highlight, ButtonText) replace tinted fills and shadows.
Motion and theming
When 25% of the figure enters the viewport, dots unfurl left to right from each row's center line; server-rendered HTML places every dot at its final resting position. Switching metrics, changing groupBy, or toggling categories runs one requestAnimationFrame loop that integrates each dot's spring (released across a 300 ms left-to-right wave) alongside a non-overshooting shared radius spring, stopping automatically once settled. Hover and focus glide the tooltip on a snappy spring, and the summary readout rises out of a subtle blur.
Under prefers-reduced-motion: reduce, dots jump directly to their resting coordinates, tooltips snap without glide, and the summary readout uses a brief 120 ms opacity crossfade. Under motion="none", every transition and animation resolves immediately (0 ms).
theme accepts a mode, an accent, and semantic tokens across the core, control, and chart groups plus borderStrong and borderSubtle. An application-wide UtherealProvider supplies defaults.
Composition
In an agent composition, Beeswarm is a leaf with no actions. The brushed range is host state stored at /components/instance-<id>/brush, initialized from defaultBrush. onHiddenCategoriesChange is a transient UI control bound to hiddenCategories. The host updates data, metric, or groupBy through composition updates. See Building with agents.
{
"type": "Beeswarm",
"props": {
"label": "Customers by MRR",
"metric": "mrr",
"groupBy": "region",
"metrics": [
{
"key": "mrr",
"label": "MRR",
"scale": "log",
"valueFormat": {
"style": "currency",
"currency": "USD",
"maximumFractionDigits": 0
}
},
{ "key": "seats", "label": "Seats", "scale": "log" }
],
"categories": [
{ "key": "enterprise", "label": "Enterprise" },
{ "key": "mid", "label": "Mid-market" }
],
"data": [
{
"id": "northwind",
"label": "Northwind Labs",
"category": "enterprise",
"values": { "mrr": 48200, "seats": 620 },
"groups": { "region": "Americas" }
},
{
"id": "lumen",
"label": "Lumen Robotics",
"category": "mid",
"values": { "mrr": 7200, "seats": 86 },
"groups": { "region": "Europe" }
}
]
},
"children": []
}