nook
Browse the docs

Components

Scatter chart

Native

Plot paired measurements to explore relationships, including negative values.

See the prompt
Campaign spend and qualified leads

Qualified leads ยท 0 to 96

Email: 320, 48Search: 1.8K, 96Social: 1.3K, 52Partners: 620, 72Events: 2.2K, 84Referrals: 180, 38
Campaign spend and qualified leads
ObservationSpend ($)Qualified leads
Email32048
Search1.8K96
Social1.3K52
Partners62072
Events2.2K84
Referrals18038

Installation

npx nook-ui@latest add scatter-chart

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Scatter chart" component to this project, exactly as Nook ships it.

Plot paired measurements to explore relationships, including negative values.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add scatter-chart`. It writes `components/ui/scatter-chart.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/scatter-chart.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { ScatterChart } from "@/components/ui/scatter-chart";
export default function Example() {
  return (
    <ScatterChart
      title="Campaign spend and qualified leads"
      xLabel="Spend ($)"
      yLabel="Qualified leads"
      data={[
        { id: "email", label: "Email", x: 320, y: 48 },
        { id: "search", label: "Search", x: 1800, y: 96 },
        { id: "social", label: "Social", x: 1250, y: 52 },
        { id: "partners", label: "Partners", x: 620, y: 72 },
        { id: "events", label: "Events", x: 2200, y: 84 },
        { id: "referral", label: "Referrals", x: 180, y: 38 },
      ]}
    />
  );
}
```

API
- `ScatterChart`: Plot paired measurements to explore relationships, including negative values.
  - `data` (`ScatterPoint[]`): Stable IDs, labels and finite x/y measurements.
  - `xLabel / yLabel` (`string`): Axis names.
  - `title` (`string`): Visible caption and data table name.
  - `formatX / formatY` (`(value: number) => string`): Axis and table formatting.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Square marks are keyboard-focusable and named; a table gives every observation.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { ScatterChart } from "@/components/ui/scatter-chart";
export default function Example() {
  return (
    <ScatterChart
      title="Campaign spend and qualified leads"
      xLabel="Spend ($)"
      yLabel="Qualified leads"
      data={[
        { id: "email", label: "Email", x: 320, y: 48 },
        { id: "search", label: "Search", x: 1800, y: 96 },
        { id: "social", label: "Social", x: 1250, y: 52 },
        { id: "partners", label: "Partners", x: 620, y: 72 },
        { id: "events", label: "Events", x: 2200, y: 84 },
        { id: "referral", label: "Referrals", x: 180, y: 38 },
      ]}
    />
  );
}

Props

ScatterChart

Plot paired measurements to explore relationships, including negative values.

PropTypeDefaultDescription
dataScatterPoint[]โ€“Stable IDs, labels and finite x/y measurements.
xLabel / yLabelstringโ€“Axis names.
titlestringโ€“Visible caption and data table name.
formatX / formatY(value: number) => stringโ€“Axis and table formatting.

Accessibility

Square marks are keyboard-focusable and named; a table gives every observation.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.