# ScatterChart Plot paired measurements on independent numeric axes. Compare series and enable the data table when readers need the original coordinates. [Interactive guide](/docs/components/scatterchart) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use ScatterChart to relate measurements on two independent numeric axes. ### How to compose it Provide two coordinates per point, stable IDs for changing data and axis names with units. Keep incomplete readings with null in the missing coordinate. ### What to verify Verify overlapping and out-of-domain points can still be found in the optional data table and that the summary describes the visible relationship. ## Usage ```tsx import { ScatterChart } from 'wss3-forge' import type { ScatterPoint, ScatterSeries, ScatterAxisOptions } from 'wss3-forge' ``` - Supply two numeric coordinates for each point. Give frequently updated points stable IDs. - Set both axis names and units so readers can interpret their relationship. The chart derives a domain for each axis unless you supply one. - Keep an incomplete reading in the series with null for its missing coordinate. Points outside an explicit domain and points with a missing coordinate stay in the data table. - Use the chart summary to describe the visible pattern. Add showTable to expose exact coordinates, including overlapping points. ```tsx ``` ## Runnable examples ### Payload size and response time by device ```tsx import { ScatterChart } from 'wss3-forge' import type { ScatterSeries } from 'wss3-forge' const pageMetrics = [ { key: 'desktop', label: 'Desktop', data: [ { id: 'desktop-home', label: 'Home', x: 16, y: 630 }, { id: 'desktop-pricing', label: 'Pricing', x: 27, y: 850 }, { id: 'desktop-docs', label: 'Docs', x: 43, y: 1100 }, ], }, { key: 'mobile', label: 'Mobile', data: [ { id: 'mobile-home', label: 'Home', x: 15, y: 900 }, { id: 'mobile-pricing', label: 'Pricing', x: 29, y: null }, { id: 'mobile-docs', label: 'Docs', x: 49, y: 1690 }, ], }, ] satisfies ScatterSeries[] export default function Example() { return () } ``` ## Root package API ### ScatterChart Plot paired measurements on independent numeric axes. Compare series and enable the data table when readers need the original coordinates. Props type: `ScatterChartProps` - `title` — `string` - `summary?` — `string` - `series` — `readonly ScatterSeries[]` Named series with stable keys and paired x and y values. - `xAxis?` — `ScatterAxisOptions` Horizontal axis label, domain, unit, formatter, grid and tick options. - `yAxis?` — `ScatterAxisOptions` Vertical axis label, domain, unit, formatter, grid and tick options. - `width?` — `number | string` Default `'100%'`. - `height?` — `number` Default `240`. - `showLegend?` — `boolean` Default `true`. - `showTooltip?` — `boolean` Default `true`. - `showTable?` — `boolean` Default `false`. Offer a disclosure with the source coordinates. - `emptyLabel?` — `string` Default `'No data to display.'`. - `className?` — `string` - `style?` — `CSSProperties` ## Related types ```ts export interface ScatterSeries extends Omit { data: readonly ScatterPoint[] } export interface ChartSeries { key: string label?: string kind?: 'bar' | 'line' | 'area' color?: string unit?: string formatValue?: (value: number) => string } export interface ScatterPoint { /** Stable identity within this series. Omit for static, ordered data. */ id?: string | number label?: string x: number | null y: number | null } export interface ScatterAxisOptions extends ChartValueAxisOptions { /** Ascending finite bounds. Points outside the domain remain in the data table. */ domain?: ChartDomain unit?: string } export type ChartDomain = readonly [min: number, max: number] export interface ScatterChartProps { title: string summary?: string series: readonly ScatterSeries[] xAxis?: ScatterAxisOptions yAxis?: ScatterAxisOptions width?: number | string height?: number showLegend?: boolean showTooltip?: boolean /** Offer a disclosure with the source coordinates. @default false */ showTable?: boolean emptyLabel?: string className?: string style?: CSSProperties } ```