UI

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

Accounts by MRRActive paying workspaces segmented by plan tier.

18 shown

Accounts by MRR
NameCategoryMRRSeatsNPS
Moss DesignSelf-serve$760982
Tundra MapsSelf-serve$1,1801564
Drift StudioSelf-serve$1,4501884
Finch DocsSelf-serve$1,7202188
Clover OpsSelf-serve$2,1002667
Willow SupportSelf-serve$2,8503473
Harbor CommerceMid-market$4,9006263
Lumen RoboticsMid-market$7,2008677
Redwood AnalyticsMid-market$8,3009880
Mariner LogisticsMid-market$9,40011566
Banyan GridMid-market$11,20014272
Quartz PaymentsMid-market$12,90016569
Cinder RailEnterprise$21,90028071
Kestrel BioEnterprise$26,40031081
Helio FreightEnterprise$34,80044068
Solstice HealthEnterprise$41,20051085
Northwind LabsEnterprise$48,20062074
Monolith EnergyEnterprise$61,50084079
Loading interactive preview…

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.

API response latency by region

7 selected

Americas4Europe4APAC4

API response latency by region
NameCategoryregionp95 latency
US East (iad)EdgeAmericas28 ms
London (lhr)EdgeEurope34 ms
US West (sfo)EdgeAmericas44 ms
Tokyo (hnd)EdgeAPAC48 ms
Frankfurt (fra)EdgeEurope52 ms
Singapore (sin)EdgeAPAC67 ms
Chicago (ord)OriginAmericas86 ms
Paris (cdg)OriginEurope94 ms
Stockholm (arn)OriginEurope112 ms
Sydney (syd)OriginAPAC129 ms
Sao Paulo (gru)OriginAmericas138 ms
Mumbai (bom)OriginAPAC156 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.

ArgumentType / defaultDescription
labelstringDefault: "Beeswarm chart"Names the chart for assistive technology and captions the data table when title is omitted.
titlestring—Optional visible figure heading above the legend and plot. Omit it to render without a heading while keeping label for assistive technology.
descriptionstring—One or two sentences on what the chart shows, below the title; omit it when the title says enough.
dataBeeswarmDatum[]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.
metricsBeeswarmMetric[]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.
metricstring—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.
categoriesBeeswarmCategory[]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.
groupBystring | nullDefault: nullAttribute key inside each datum’s groups object to split the swarm into horizontal rows, or null for a single swarm.
groupOrderRecord<string, string[]>—Explicit row order per groupBy attribute; unlisted group values follow in order of appearance.
defaultBrush[number, number] | nullDefault: nullInitial brushed [low, high] range in active metric units when uncontrolled. Later argument edits do not reset a mounted instance.
defaultHiddenCategoriesstring[]Default: []Initial hidden category keys when uncontrolled. Hidden dots shrink away and remaining dots re-pack; later edits do not reset a mounted instance.
heightintegerDefault: 340Plot height in pixels (160–800), shared across all rows including the 28 px bottom axis.
emptyLabelstringDefault: "Nothing to show"Shown centered over the plot when every category is hidden or data is empty.
tableTogglebooleanDefault: falseShow a button that reveals the data table. The table is always available to assistive technology.
tableLabelstringDefault: "Data table"Name of the data table button.
localestring—BCP 47 locale for numbers and dates. Omit it to inherit the application locale (en-US by default).
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeBeeswarmTheme—Color mode, accent, and semantic tokens including the chart palette (series1–series8) and hairline borders. See Theming.
motionnone | subtle | expressiveDefault: "subtle"Reveal, dot-wave spring, and tooltip glide preset. System reduced-motion preferences take precedence.
motionOptionsBeeswarmMotionOptions—draw and morph transitions; when morph is a spring, its stiffness and damping drive the per-dot beeswarm physics.
dirltr | 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

PropPurpose
brushControlled brushed [low, high] range in active metric units, or null
onBrushChangeFires with (range, selected) while brushing and (null, []) when cleared
hiddenCategoriesControlled array of hidden category keys
onHiddenCategoriesChangeFires with the updated hidden category keys when a legend toggle is pressed
summarizeCustom summary builder (items, brushed) => string for the live readout line
formatValueCustom formatter (value, metric) => string for tooltips, ticks, and table
presetApplication defaults, overridden by explicit instance props
tokensCSS variables applied after the typed theme
refRef forwarded to the root <figure>
className, styleApplied to the root <figure>
Native attributesid, data-*, and remaining <figure> attributes forwarded to the root

Keyboard & accessibility

KeyInteraction
TabMove focus across legend toggles, the plot, and optional table button
ArrowLeft, ArrowRightMove to the previous or next visible dot in ascending metric order
ArrowUp, ArrowDownMove to the nearest dot horizontally in the row above or below
Shift + ArrowLeft, ArrowRightExtend a brushed range from the starting dot
Home, EndJump to the lowest or highest visible value
EscapeClear 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": []
}

On this page