BubbleChart
Compare series and read the change behind them, with the axes, legend and tooltip already wired.
@luc/ui/chartsWhat it shows
Compare two numeric dimensions while carrying a third positive magnitude in the bubble radius.
Live preview
The same observations with a third supplied measure — turnover — carried by the bubble radius.
<BubbleChart
data={[
{ factor: -1.42, forward: -1.05, turnover: 12 },
{ factor: -1.05, forward: -0.78, turnover: 8 },
{ factor: -0.63, forward: -0.41, turnover: 21 },
{ factor: -0.24, forward: -0.32, turnover: 15 },
{ factor: 0.18, forward: 0.24, turnover: 9 },
{ factor: 0.55, forward: 0.48, turnover: 27 },
{ factor: 0.94, forward: 0.86, turnover: 18 },
{ factor: 1.38, forward: 1.31, turnover: 11 },
]}
xKey="factor"
x={{ type: "value", format: { kind: "decimal", decimals: 2 } }}
axes={[{ id: "primary", format: { kind: "percent", decimals: 1 } }]}
series={[
{
key: "forward",
label: "Forward return",
type: "scatter",
tone: "accent",
sizeKey: "turnover",
},
]}
height={320}
ariaLabel="Return by size"
/>Controls
Height
A chart measures its container, so it always needs a definite height.
State
The surface the chart is in — loading, empty and error are drawn by the component.
Accessible name
A drawing is not readable by a screen reader, so it needs a name that states what it shows.
The same fixture as the live preview above; the controls change how it is drawn, not what it measures.
Code
import { BubbleChart } from "@luc/ui/charts";
<BubbleChart
data={[
{ factor: -1.42, forward: -1.05, turnover: 12 },
{ factor: -1.05, forward: -0.78, turnover: 8 },
{ factor: -0.63, forward: -0.41, turnover: 21 },
{ factor: -0.24, forward: -0.32, turnover: 15 },
{ factor: 0.18, forward: 0.24, turnover: 9 },
{ factor: 0.55, forward: 0.48, turnover: 27 },
{ factor: 0.94, forward: 0.86, turnover: 18 },
{ factor: 1.38, forward: 1.31, turnover: 11 },
]}
xKey="factor"
x={{ type: "value", format: { kind: "decimal", decimals: 2 } }}
axes={[{ id: "primary", format: { kind: "percent", decimals: 1 } }]}
series={[
{
key: "forward",
label: "Forward return",
type: "scatter",
tone: "accent",
sizeKey: "turnover",
},
]}
height={320}
ariaLabel="Return by size"
state="ready"
/>Not controllable here
series / rows— The numbers are the caller's; the fixture above is the example.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `BubbleChart` from Luc UI. It is: Compare series and read the change behind them, with the axes, legend and tooltip already wired.
Import it with: import { BubbleChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.
Chosen configuration: `height={320}`, `state="ready"`, `ariaLabel="Return by size"`.
Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.
Reproduce this state:
```tsx
<BubbleChart
data={[
{ factor: -1.42, forward: -1.05, turnover: 12 },
{ factor: -1.05, forward: -0.78, turnover: 8 },
{ factor: -0.63, forward: -0.41, turnover: 21 },
{ factor: -0.24, forward: -0.32, turnover: 15 },
{ factor: 0.18, forward: 0.24, turnover: 9 },
{ factor: 0.55, forward: 0.48, turnover: 27 },
{ factor: 0.94, forward: 0.86, turnover: 18 },
{ factor: 1.38, forward: 1.31, turnover: 11 },
]}
xKey="factor"
x={{ type: "value", format: { kind: "decimal", decimals: 2 } }}
axes={[{ id: "primary", format: { kind: "percent", decimals: 1 } }]}
series={[
{
key: "forward",
label: "Forward return",
type: "scatter",
tone: "accent",
sizeKey: "turnover",
},
]}
height={320}
ariaLabel="Return by size"
state="ready"
/>
```Usage
The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.
It is drawn by the ECharts engine.
Worked examples with real data are on the family overview: General
import { BubbleChart } from "@luc/ui/charts";<BubbleChart
data={[
{ factor: -1.42, forward: -1.05, turnover: 12 },
{ factor: -1.05, forward: -0.78, turnover: 8 },
{ factor: -0.63, forward: -0.41, turnover: 21 },
{ factor: -0.24, forward: -0.32, turnover: 15 },
{ factor: 0.18, forward: 0.24, turnover: 9 },
{ factor: 0.55, forward: 0.48, turnover: 27 },
{ factor: 0.94, forward: 0.86, turnover: 18 },
{ factor: 1.38, forward: 1.31, turnover: 11 },
]}
xKey="factor"
x={{ type: "value", format: { kind: "decimal", decimals: 2 } }}
axes={[{ id: "primary", format: { kind: "percent", decimals: 1 } }]}
series={[
{
key: "forward",
label: "Forward return",
type: "scatter",
tone: "accent",
sizeKey: "turnover",
},
]}
height={320}
ariaLabel="Return by size"
/>Data contract
Rows require a numeric x field, a numeric y series field and a positive numeric field named by `series[].sizeKey`. The chart does not derive or normalise the size measure.
Important configuration
Name the `sizeKey` in the series, format both axes, and explain the radius scale in the caption or tooltip because area is less precise than position.
Guidelines
When not to use
Do not encode a signed or unbounded quantity as radius without transforming it yourself; a negative size has no honest bubble.
Configuration
| Export | Kind | Signature |
|---|---|---|
BubbleChart | 33 documented props | <TRow extends object = Record<string, unknown>>({ family, state, height, className, visibleSeries, ariaLabel, ariaDescription, onReady, onEvent, ...spec }: CartesianChartProps<TRow>) => import("@type… |
BubbleChart props
Type: CartesianChartProps<TRow>
Values the compiler reads from the declaration.
| Prop | Type | Default | Notes |
|---|---|---|---|
animation? | ChartAnimationPreset | undefined | — | Animation budget. Defaults to `standard`. |
annotations? | AnnotationSpec | undefined | — | |
ariaDescription? | string | undefined | — | |
ariaLabel? | string | undefined | — | |
axes? | readonly AxisSpec[] | undefined | — | Extra axes beyond the primary one. |
className? | string | undefined | — | |
data? | readonly TRow[] | undefined | — | |
description? | string | undefined | — | |
engine? | ChartEngine | undefined | — | |
extendOption? | ((option: unknown) => void) | undefined | — | Advanced: mutate the assembled engine option. Clearly not the normal path. |
family? | ChartFamily | undefined | — | Override the family the wrapper defaults to. Advanced. |
height? | string | number | undefined | — | |
id? | string | undefined | — | |
interaction? | ChartInteractionSpec | undefined | — | |
legend? | boolean | undefined | — | |
onEvent? | ((event: EChartEvent) => void) | undefined | — | |
onReady? | ((chart: EChartsInstance) => void) | undefined | — | |
orientation? | "horizontal" | "vertical" | undefined | — | Bar family only: which way the bars grow. Defaults to `vertical`. |
pointCount? | number | undefined | — | The number of plotted points, when the caller already knows it. Used only to *reduce* animation for a large series; it never changes what is drawn. |
points? | Readonly<Record<string, ChartPointMeta>> | undefined | — | Per-point display metadata, keyed by the x value's canonical string form. A generic hook for a caller whose x values carry a better label or extra hover context than the axis can … |
ranges? | ChartRangeSpec | undefined | — | |
renderer? | ChartRenderer | undefined | — | Drawing layer. Defaults to `canvas`. Set `svg` when the chart is going to be captured rather than read: vector output survives PDF export and scales without a density choice. Igno… |
scale? | { allowed?: readonly YScaleMode[]; default?: YScaleMode; mode?: YScaleMode; } | undefined | — | Scale capability and current mode. `allowed` is what the *product* declares it may offer (a signed drawdown is linear-only); `default` is what it opens on; `mode` is what the read… |
series | readonly SeriesSpec[] | — | |
state? | ChartState | undefined | — | |
syncGroup? | string | undefined | — | |
title? | string | undefined | — | |
tooltip? | ChartTooltipSpec | undefined | — | |
unit? | string | undefined | — | |
universalTransition? | boolean | undefined | — | Morph the *same data* between two representations (a histogram ↔ a ranked bar, a stacked ↔ a grouped bar). Opt-in, because a morph between charts that do not share a data identity… |
visibleSeries? | readonly string[] | undefined | — | |
x? | AxisSpec | undefined | — | |
xKey? | string | undefined | — | Field that supplies the x value for tabular data. |
Accessibility
A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.
What happens on the server, and when hydration changes it.
Family
General
The shapes every product needs, on the declarative ChartSpec path.
Related