Documentation / Charts
ScatterChart
The correlation between two numeric measures: x.key gives the horizontal position, each series’ key the vertical one. Both axes are measures, so the horizontal axis is always continuous (linear, or time for dates).
Options: bubbles whose area (not radius) follows a third field, a least-squares trend line, and thresholds that cut the plot into quadrants. The number of series is capped at 3: any two marks can sit side by side here, and only the first three palette colours survive that.
A "use client" component. On large volumes, maxPoints thins the cloud through even sampling (which preserves its density); the trend line and the table view always read every row.
Examples
Scatter plot
Two segments, one colour each, on a numeric horizontal axis.
import { ScatterChart } from "@synertech/ui";
const campaigns = Array.from({ length: 26 }, (_, index) => {
const budget = 500 + index * 320;
const noise = ((index * 37) % 11) - 5;
return {
name: `Campagne ${index + 1}`,
budget,
b2b: Math.round(budget * 0.021 + noise * 3),
b2c: Math.round(budget * 0.013 + noise * 4 + 12),
clients: 5 + ((index * 13) % 40),
};
});
const euro = (value: number) => `${Math.round(value / 1000)} k€`;
export function Basic() {
return (
<ScatterChart
title="Budget et conversions"
description="26 campagnes, deux segments"
data={campaigns}
x={{
key: "budget",
scale: "linear",
label: "Budget",
format: (value) => euro(Number(value)),
}}
y={{ label: "Conversions" }}
series={[
{ key: "b2b", label: "B2B" },
{ key: "b2c", label: "B2C" },
]}
height={300}
/>
);
}Trend line
trendLine fits a least-squares line to the visible points.
import { ScatterChart } from "@synertech/ui";
const campaigns = Array.from({ length: 26 }, (_, index) => {
const budget = 500 + index * 320;
const noise = ((index * 37) % 11) - 5;
return {
name: `Campagne ${index + 1}`,
budget,
b2b: Math.round(budget * 0.021 + noise * 3),
b2c: Math.round(budget * 0.013 + noise * 4 + 12),
clients: 5 + ((index * 13) % 40),
};
});
export function TrendLine() {
return (
<ScatterChart
title="Le budget paie-t-il en B2B ?"
data={campaigns}
x={{ key: "budget", scale: "linear", label: "Budget (€)" }}
y={{ label: "Conversions" }}
series={[{ key: "b2b", label: "B2B" }]}
trendLine
height={280}
/>
);
}Bubbles
bubble sizes each mark by a third field; range bounds the radius in pixels, and label names the measure, which the tooltip and the data table write as a figure.
import { ScatterChart } from "@synertech/ui";
const campaigns = Array.from({ length: 26 }, (_, index) => {
const budget = 500 + index * 320;
const noise = ((index * 37) % 11) - 5;
return {
name: `Campagne ${index + 1}`,
budget,
b2b: Math.round(budget * 0.021 + noise * 3),
b2c: Math.round(budget * 0.013 + noise * 4 + 12),
clients: 5 + ((index * 13) % 40),
};
});
export function Bubbles() {
return (
<ScatterChart
title="Budget, conversions et clients"
description="La taille des bulles donne le nombre de clients"
data={campaigns}
x={{ key: "budget", scale: "linear", label: "Budget (€)" }}
y={{ label: "Conversions" }}
series={[{ key: "b2b", label: "B2B" }]}
bubble={{ key: "clients", range: [4, 18], label: "Clients" }}
height={300}
/>
);
}Analysis quadrants
quadrants draws a threshold on each axis; clicking a point returns the full data row.
import { ScatterChart } from "@synertech/ui";
const campaigns = Array.from({ length: 26 }, (_, index) => {
const budget = 500 + index * 320;
const noise = ((index * 37) % 11) - 5;
return {
name: `Campagne ${index + 1}`,
budget,
b2b: Math.round(budget * 0.021 + noise * 3),
b2c: Math.round(budget * 0.013 + noise * 4 + 12),
clients: 5 + ((index * 13) % 40),
};
});
export function Quadrants() {
return (
<ScatterChart
title="Campagnes efficaces"
description="Au-dessus de 120 conversions pour moins de 5 k€"
data={campaigns}
x={{ key: "budget", scale: "linear", label: "Budget (€)" }}
y={{ label: "Conversions" }}
series={[
{ key: "b2b", label: "B2B" },
{ key: "b2c", label: "B2C" },
]}
quadrants={{ x: 5000, y: 120 }}
legendToggle
tableView="toggle"
onPointClick={(point) => console.log(point.datum.name, point.formattedValue)}
height={300}
/>
);
}API reference
Components
Correlation between two numeric measures.
The one chart form where any two marks can end up side by side, which is a stricter test of the palette than neighbouring bars or lines: only the first three slots stay tellable apart there. Past three series, facet the chart or fold the tail — a fourth colour would not be distinguishable.
import { ScatterChart } from "@synertech/ui";Props — ScatterChartProps
| Prop | Type | Default | Description |
|---|---|---|---|
data• |
ChartDatum[] |
— | |
series• |
ChartSeries[] |
— | |
x• |
ChartXAxisConfig |
— | |
actions |
ReactNode |
— | Slot on the right of the caption: an export button, a range picker. A filter that frames several panels belongs in a |
bubble |
ScatterBubble |
— | Sizes each mark by a third field, turning the plot into a bubble chart. |
className |
string |
— | |
description |
ReactNode |
— | |
emphasis |
string |
— | Paints one series in its colour and greys out every other one. |
emptyState |
ReactNode |
— | Replaces the "no data" state: usually an |
error |
boolean |
false |
The data could not be loaded. Never the same thing as having none: a panel that says "no data" after a failed request states something false, and offers no way out. |
errorState |
ReactNode |
— | Replaces the whole built-in error state, message and button included. |
grid |
ChartGridLines |
"both" |
|
height |
number |
280 |
Height of the plot area in pixels. Width always follows the container. |
legend |
boolean | ChartLegendPosition |
— | |
legendToggle |
boolean |
true |
|
loading |
boolean |
false |
Dims the plot while fresh data loads; a first load shows a spinner. |
locale |
string |
— | BCP 47 tag the numbers and the dates are written in. Defaults to the |
margin |
Partial<ChartMargin> |
— | |
maxPoints |
number |
— | Thins each series to roughly this many marks. An even sample, not LTTB: a cloud is read for where its points are dense, and keeping the largest triangles would carve out the envelope and throw that density away — a lie about the very thing the chart is for. An even stride thins the cloud without changing its shape. The trend line and the data table are computed from every row, so a thinned plot still reports what the whole dataset says. Left unset, a series past |
onPointClick |
(event: ChartPointEvent) => void |
— | Called with the mark that was clicked. Enter and Space on the focused chart do the same for the mark the keyboard is on. |
onRetry |
() => void |
— | Draws the retry button in the error state, and is called when pressed. |
overlay |
ChartOverlay |
— | Draws inside the plot, with the chart's own resolved geometry. |
plotLabel |
string |
— | |
pointRadius |
number |
4.5 |
|
quadrants |
{ x?: number; y?: number } |
— | Splits the plot on a value of each axis. |
size |
ChartSize |
"md" |
|
tableView |
boolean | "toggle" |
false |
Renders the accessible data table: always ( |
title |
ReactNode |
— | |
tooltip |
boolean | ((payload: ChartTooltipPayload) => ReactNode) |
true |
|
trendLine |
boolean |
false |
Fits a least-squares line through every visible point. |
width |
number |
— | Fixes the width instead of measuring the container. |
y |
ChartYAxisConfig |
— |
+ 276 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
ScatterBubble
InterfaceThe third measure of a bubble chart.
interface ScatterBubble| Field | Type | Default | Description |
|---|---|---|---|
key• |
string |
— | Field holding the measure each mark is sized by. |
format |
(value: number) => string |
— | Writes the measure in the tooltip and the data table. Defaults to every digit, grouped in the chart's locale. |
label |
string |
— | Names the measure in the tooltip and the data table. Defaults to |
range |
[number, number] |
— | Smallest and largest radius, in pixels. |