Scatter chart
Reveal association, clusters, and unusual points across two numeric measures.
- Effort score
- 2.4
- Impact score
- 63
- confidence
- 42
View data table 6 rows
| Data point | Effort score | Impact score | confidence |
|---|---|---|---|
| Atlas | 2.4 | 63 | 42 |
| Boreal | 4.1 | 78 | 61 |
| Cedar | 3.2 | 54 | 35 |
| Dune | 5.3 | 86 | 74 |
| Elm | 1.8 | 47 | 28 |
| Fjord | 4.7 | 69 | 57 |
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/scatter-chart.jsonThe registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.
Usage
"use client";
import { ScatterChart } from "@eduardoul/apple-ui";
const data = [
{ label: "Atlas", effort: 2.4, impact: 63, confidence: 42 },
{ label: "Boreal", effort: 4.1, impact: 78, confidence: 61 },
{ label: "Cedar", effort: 3.2, impact: 54, confidence: 35 },
{ label: "Dune", effort: 5.3, impact: 86, confidence: 74 },
];
export function Example() {
return (
<ScatterChart
title="Opportunity map"
description="Synthetic scores. Point area represents confidence."
data={data}
xKey="effort"
yKey="impact"
sizeKey="confidence"
xLabel="Effort score"
yLabel="Impact score"
/>
);
}Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.
API reference
| Property | Type | Default |
|---|---|---|
| data | ChartDatum[] | required |
| xKey | string | x |
| yKey | string | y |
| sizeKey | string | undefined |
| labelKey | string | label |
| xLabel | string | X |
| yLabel | string | Y |
| title | string | required |
| description | string | undefined |
| height | number | component default |
| loading | boolean | false |
| error | string | undefined |
| emptyMessage | string | No data to display. |
| showTable | boolean | true |
| compact | boolean | false |
| valueFormatter | (value: number) => string | localized number |
| className | string | undefined |
| style | React.CSSProperties | undefined |
Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.
Design guidance
- Use a scatter chart when the relationship between two measures is the question.
- Name both axes with the measure and unit. A point position is meaningless without that context.
- Use point size for a third measure only when it adds a clear decision signal.
- Every coordinate must be finite. Optional point sizes must also be finite and cannot be negative.
Accessibility
Give the chart a descriptive title and explain its units. Select a data point to read its values, or open the data table for the full dataset. Labels and values accompany color, and the chart adapts to reduced motion and appearance preferences. Test long labels, touch input and keyboard navigation with your own data.
Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.