Examples
Scatter & Bubble chart Pro
Two measures per row as points: does one rise with the other? groupKey colors and shapes points by group (with a legend that toggles them), sizeKey turns points into bubbles sized by area, and showTrend draws the least-squares line. Screen readers hear the ranges and how strongly the measures move together.
import { ScatterChart } from '@patine-ui/pro';
Live data
Loading…
<View style={{ width: 380, gap: 8 }}> <Button size="sm" variant="outline" onPress={() => setData(roll())} style={{ alignSelf: 'flex-end' }}>Shuffle</Button> <ScatterChart data={data} xKey="spend" yKey="sales" sizeKey="deals" groupKey="region" xLabel="Ad spend ($K)" yLabel="Sales ($K)" sizeLabel="Deals" showTrend accessibilityLabel="Sales against ad spend, by region" /> </View>
Try the props
groupKeysizeKeygriddesign<ScatterChart
data={regions}
xKey="spend"
yKey="sales"
xLabel="Ad spend"
yLabel="Sales"
/>
Example: flat prices by size
A housing site's sold listings: each dot is a flat, size against price, colored by neighbourhood and sized by rooms. The trend line shows what a square metre costs, and the dots far above it are the outliers.
Loading…
<View style={{ width: '100%' }}> <ScatterChart data={data} xKey="size" yKey="price" sizeKey="rooms" groupKey="area" xLabel="Size (m²)" yLabel="Price (€K)" sizeLabel="Rooms" showTrend height={280} accessibilityLabel="Sold flats in Amsterdam: size against price, by neighbourhood" /> </View>
Over time
Loading…
<ScatterChart data={data} xKey="at" yKey="ms" yLabel="Response time" valueFormatter={(v) => `${v} ms`} referenceLines={[{ value: 200, label: 'Budget' }]} style={{ width: 380 }} />
Props
The shared chart props, and:
| Prop | Type | Default | Description |
|---|---|---|---|
xKey / yKey | string | — | Numbers (or Dates on x). |
sizeKey | string | — | Sizes each point by area: a bubble chart. |
groupKey | string | — | Groups points into series with their own color, shape and legend toggle. |
series | { key, label?, color? }[] | — | Labels and colors for groups. |
xLabel / yLabel / sizeLabel | string | the keys | Names in the tooltip and summary. |
showTrend | boolean | false | The line of best fit. |
grid | 'value' | 'category' | 'both' | 'none' | 'both' | |
minValue / maxValue | number | from the data | The y axis's ends. |
referenceLines | { value, label?, color?, dashed? }[] | — | |
maxRadius | number | 18 | The biggest bubble. |
xFormatter | (x) => string | — | |
defaultHidden | string[] | — | Groups turned off at first. |