Vesture

Charts

ScatterChartNew in 0.8.0

Scatter and bubble chart with multiple series, optional per-series trendlines, and legend entries that toggle series on and off.

ScatterChart

Preview

Dot size
$0k$15k$30k$45k$60k017.53552.570Ad spendRevenuePaid: 2.942489711934156, $11kPaid: 4.46386316872428, $11kPaid: 6.471347736625514, $22kPaid: 11.46494341563786, $12kPaid: 15.944650205761317, $10kPaid: 16.410468106995886, $23kPaid: 21.362397119341566, $22kPaid: 21.300437242798353, $33kPaid: 24.724588477366254, $25kPaid: 28.13485082304527, $26kPaid: 34.03122427983539, $26kPaid: 38.91370884773663, $31kPaid: 39.28230452674897, $31kPaid: 43.63701131687243, $33kPaid: 42.477829218107, $47kPaid: 50.30475823045268, $39kPaid: 51.617798353909464, $40kPaid: 54.916949588477365, $37kPaid: 56.70221193415638, $38kPaid: 59.4735853909465, $52kPaid: 65.73106995884774, $46kPaid: 65.97466563786008, $51kOrganic: 2.704372427983539, $9kOrganic: 4.420190329218107, $16kOrganic: 7.622119341563787, $17kOrganic: 14.810159465020575, $22kOrganic: 16.484310699588477, $17kOrganic: 15.14457304526749, $11kOrganic: 19.290946502057615, $14kOrganic: 25.42343106995885, $12kOrganic: 24.042026748971193, $15kOrganic: 29.64673353909465, $11kOrganic: 32.73755144032922, $27kOrganic: 35.8144804526749, $14kOrganic: 41.37752057613169, $17kOrganic: 39.92667181069959, $27kOrganic: 45.961934156378604, $31kOrganic: 49.983307613168726, $18kOrganic: 48.490792181069956, $16kOrganic: 55.98438786008231, $34kOrganic: 56.96409465020576, $19kOrganic: 59.92991255144033, $20kOrganic: 61.38184156378601, $26kOrganic: 63.8198816872428, $24k

Click a point

Usage

tsx
import { ScatterChart } from "@vesture/react";

<ScatterChart
  width={560}
  height={340}
  trendline
  xLabel="Ad spend"
  yLabel="Revenue"
  series={[{ key: "paid", label: "Paid", points: [{ x: 10, y: 24, size: 8 }, { x: 20, y: 51, size: 30 }] }]}
/>

Behavior

  • Give a point a size to turn the chart into a bubble chart; sizes are scaled into sizeRange.
  • Axis domains default to the nice-rounded data extent. Pass xDomain / yDomain to pin them.
  • renderPoint replaces the default circle and receives the pixel center, radius and series color.

Props

PropTypeDefaultDescription
series{ key; label; color?; points: { x; y; size?; label? }[] }[]—Required.
width / heightnumber—Required, in px.
xDomain / yDomain[number, number]—Fixed axis range.
xLabel / yLabelstring—Axis titles.
formatX / formatY(v: number) => string—Tick and tooltip formatting.
pointRadius / sizeRange / pointOpacitynumber / [number, number] / number4 / [4, 18] / 0.75Dot geometry for plain and bubble points.
trendlinebooleanfalseDraw a least-squares line per series.
showGrid / showLegendbooleantrueToggle chrome.
renderPoint(info) => ReactNode—Custom marker.
onPointClick(point, series) => void—Makes points clickable.