ScatterChart

Scatter plots for visualizing correlations between two variables. Add a size dimension to create bubble charts, or categories for colored groupings.

Playground

Experiment with different settings:

Props

Midnight
0.7
OffOn
6
Code
<ScatterChart
  data={data}
  theme="midnight"
  opacity={0.7}
  showGrid
  minSize={6}
/>

Bubble Chart

Add a sizeKey to create a bubble chart where point size represents a third dimension:

$88$350$612$875$1137Price ($)5.193145.855286.518427.18567.842Quantity
tsx
<ScatterChart
  data={data}
  xKey="price"
  yKey="quantity"
  sizeKey="revenue"
  theme="midnight"
  xLabel="Price ($)"
  yLabel="Quantity"
/>

Grouped by Category

Add a categoryKey to color points by category:

North
South
East
West
87.667349.998612.329874.661,136.992Price ($)5.193145.855286.518427.18567.842Quantity
tsx
<ScatterChart
  data={data}
  xKey="price"
  yKey="quantity"
  categoryKey="region"
  theme="midnight"
  xLabel="Price ($)"
  yLabel="Quantity"
/>

With Annotations

Add reference lines and areas to highlight thresholds:

Target87.667349.998612.329874.661,136.992Price ($)5.193145.855286.518427.18567.842Quantity

Logarithmic Scale

Use xScaleType="log" and/or yScaleType="log" for data with exponential distributions. This is ideal for visualizing data like revenue vs employees, where values span multiple orders of magnitude.

$200$500$1K$2K$5KRevenue ($)2050100200500Employees
tsx
<ScatterChart
  data={companies}
  xKey="revenue"
  yKey="employees"
  sizeKey="valuation"
  xScaleType="log"
  yScaleType="log"
  theme="midnight"
  xLabel="Revenue ($)"
  yLabel="Employees"
/>

Click Events

Handle clicks on data points:

tsx
<ScatterChart
  data={data}
  xKey="price"
  yKey="quantity"
  theme="midnight"
  onPointClick={({ data, index, value }) => {
    console.log('Clicked point:', data, 'at index', index);
  }}
/>

Props

PropTypeDefaultDescription
data*T[]-Data array
xKey*keyof T-Key for X-axis values
yKey*keyof T-Key for Y-axis values
sizeKeykeyof T-Key for bubble size (creates bubble chart)
categoryKeykeyof T-Key for categories (creates colored groups)
widthnumber500Chart width
heightnumber400Chart height
theme*ThemeName-Theme name
xLabelstring-X-axis label
yLabelstring-Y-axis label
xScaleType'linear' | 'log''linear'X-axis scale type
yScaleType'linear' | 'log''linear'Y-axis scale type
minSizenumber6Minimum point size
maxSizenumber30Maximum point size
opacitynumber0.7Point opacity
showGridbooleantrueShow grid lines
formatX(value: number) => string-X-axis value formatter
formatY(value: number) => string-Y-axis value formatter
onPointClick(event: DataPointClickEvent) => void-Click handler for data points
renderTooltip(props: TooltipRenderProps) => ReactNode-Custom tooltip renderer
annotationsAnnotation[]-Reference lines and areas