# Scatter plot

Compare independent numeric measures with exact point inspection, directional keyboard movement, and a complete data table.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs compare independent numeric measures with exact point inspection, directional keyboard movement, and a complete data table.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose analytics-card instead when explore revenue, compare periods and inspect chart values is the actual interface need, rather than scatter plot.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Scatter plot

```sh
npx shadcn@latest add @tidal-pro/scatter-plot
```

Stylesheets: `components/ui/tidal.css`, `components/ui/scatter-plot.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/scatter-plot.css";
import{TidalScatterPlot}from"./components/ui/scatter-plot";
export default()=><div className="tidal-scope"><TidalScatterPlot data={[{id:"example",label:"Demo",x:1,y:1}]} onSelectedChange={() => {}} selectedId={"example"} title={"Demo"} xLabel={"Demo"} yLabel={"Demo"}/></div>;
```

## Structured props

- `TidalScatterPlot.data: ReadonlyArray<TidalScatterPoint>`: Required data value accepted by this exported component.
- `TidalScatterPlot.onSelectedChange: (id: string, event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void`: Callback invoked when the selected change interaction is proposed.
- `TidalScatterPlot.selectedId: string | null`: Required selected id value accepted by this exported component.
- `TidalScatterPlot.title: ReactNode`: Required title value accepted by this exported component.
- `TidalScatterPlot.xLabel: string`: Required x label value accepted by this exported component.
- `TidalScatterPlot.yLabel: string`: Required y label value accepted by this exported component.
- `TidalScatterPlot.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalScatterPlot.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalScatterPlot.formatX?: ((value: number) => string) | undefined` (default exact): Optional format x value accepted by this exported component.
- `TidalScatterPlot.formatY?: ((value: number) => string) | undefined` (default exact): Optional format y value accepted by this exported component.
- `TidalScatterPlot.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalScatterPlot.labels?: Partial<{ plot: string; instructions: string; empty: string; invalid: string; selection: string; none: string; table: string; point: string; inspect: string; }> | undefined` (default {}): Optional labels value accepted by this exported component.
- `TidalScatterPlot.plotProps?: PlotNative | undefined`: Optional plot props value accepted by this exported component.
- `TidalScatterPlot.plotRef?: Ref<HTMLButtonElement> | undefined`: Optional plot ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/scatter-plot.tsx) | [Manifest](https://tidalui.com/examples/scatter-plot.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalScatterPlot, type TidalScatterPoint } from "./components/ui/scatter-plot";

import "./components/ui/scatter-plot.css";



const samples: readonly TidalScatterPoint[] = [
  { id: "alder", label: "Alder", x: 14, y: 92 },
  { id: "birch", label: "Birch", x: 22, y: 64 },
  { id: "cedar", label: "Cedar", x: 31, y: 88 },
  { id: "elm", label: "Elm", x: 38, y: 54 },
  { id: "fir", label: "Fir", x: 47, y: 71 },
  { id: "maple", label: "Maple", x: 59, y: 46 },
  { id: "oak", label: "Oak", x: 67, y: 61 },
  { id: "pine", label: "Pine", x: 74, y: 31 },
  { id: "reed", label: "Reed", x: 84, y: 44 },
  { id: "willow", label: "Willow", x: 92, y: 24 },
];

export function ScatterPlotDemo() {
  const [selected, setSelected] = useState<string | null>("fir");
  return (
    <div style={{ width: "100%", maxWidth: 860 }}>
      <TidalScatterPlot
        title="Response time by load"
        description="Sample request groups. Select a point to compare its exact values."
        data={samples}
        xLabel="Concurrent requests"
        yLabel="Response time (ms)"
        selectedId={selected}
        onSelectedChange={setSelected}
      />
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <ScatterPlotDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned data contains unique nonblank IDs, labels and finite x/y values; up to500 points. selectedId is null or an existing ID. Select the plot to propose its nearest point; native keyboard activation proposes the current or first point. Arrow keys propose the closest point in that numeric direction, Home/End the first/last supplied points. The exact data disclosure supplies individually labelled native buttons for every record, including duplicate coordinates. The consumer owns accepted selection. Axes stay numeric left-to-right independent of document text direction. Extreme domains are scaled before subtraction and flat domains are centered. Exact values default to String without rounding. Custom formatters, translated labels, native root/plot props and refs, disabled state and h2-h6 heading are supported. Caller plot click/keydown handlers run first and can prevent proposals. No regression line, trend inference, aggregation, fetching or persistence occurs. Modified/composition navigation keys are not intercepted. Body-only focus recovery preserves an unrelated consumer-chosen focus destination. The exact-data region enters the tab order only when its content actually overflows.
