ScatterChart

Points placed by two numbers, to see how one value relates to another. Use it to look for a pattern or an outlier between two measures.

Charts need Recharts. Install it once with yarn add recharts, then import from @bolio-ui/core/charts. The package stays out of your bundle until you use a chart.

General

Each series has its own points, with an x and a y for each one. Name the axes with xAxisLabel and yAxisLabel.

Many series

Each series gets its own color. Add withLegend to name them.

Value format

valueFormatter changes how a number reads on both axes and in the tooltip.

APIs

ScatterChart.Props

AttributeDescriptionTypeAccepted valuesDefault
datathe series to plotScatterSeries[]ScatterSeries-
heightheight of the chart, in pixelsnumber-300
xAxisLabeltitle of the x axisstring--
yAxisLabeltitle of the y axisstring--
withLegendshow the legendboolean-false
withTooltipshow the values of a point on hover and focusboolean-true
withXAxisshow the x axisboolean-true
withYAxisshow the y axisboolean-true
withGridshow the grid linesboolean-true
valueFormatterhow a number is written on the axes and in the tooltip(value: number) => string--
...native props, passed to the rootHTMLAttributes'aria-label', 'className', ...-

ScatterSeries

type ScatterSeries = {
  name: string // identifies the series
  label?: string // shown in the legend, `name` when missing
  color?: string // any CSS color, a theme color when missing
  points: Array<{ x: number; y: number }>
}

Ref

The ref points at the root div.

Accessibility

Name the chart with aria-label, or with aria-labelledby pointing at a heading. A named chart becomes a group. The chart can be focused. Arrow Left and Right then move through the points and show their values in the tooltip.

Series differ only by color, so use withLegend and write the pattern you see in text next to the chart.

Edit this page on GitHub