Krizaka
Documentation

Scatter chart

The relation between two measures, a bubble's area for a third, a colour per group, and the correlation said in words.

WebBetaCharts

Web only — React, from @krizaka/charts/scatter. Beta: its API may still change in a minor version.

When to use

  • Whether two measures move together: a video's length and its watch time, a job's input and its duration.
  • Outliers in a population.

When not to use

  • A trend over time.Use instead: Line chart
  • Measures of a few entities on a common scale.Use instead: Radar chart

Installation

Install

npm install @krizaka/charts

Import

import { ScatterChart } from "@krizaka/charts/scatter";

Examples

Length and watch time

Orochia videos: length against average watch time, bubbles by views, a colour per format.

Length and watch time

Last 36 videos · bubble area = views

Scatter chart, 36. Length (min): 1 – 47; Average watch (min): 0.5 – 31.1; correlation 0.98.

Length and watch time — data
CategoryLength (min)Average watch (min)Views
Video 110.5800
Video 2158.21.8K
Video 33218.82.8K
Video 445.23.7K
Video 5188.64.7K
Video 64727.15.7K
Video 733.46.7K
Video 8219.17.6K
Video 93221.88.6K
Video 1021.69.6K
Video 11249.51.6K
Video 124730.12.5K
Video 1310.53.5K
Video 1496.34.5K
Video 153219.85.5K
Video 1641.26.5K
Video 17126.87.4K
Video 184728.18.4K
Video 1934.49.4K
Video 20157.21.4K
Video 213217.82.3K
Video 2222.63.3K
Video 23187.64.3K
Video 244731.15.3K
Video 2510.86.2K
Video 26218.17.2K
Video 273220.88.2K
Video 2842.29.2K
Video 292413.51.2K
Video 304729.12.1K
Video 3130.53.1K
Video 3295.34.1K
Video 333218.85.1K
Video 3423.66K
Video 35125.87K
Video 364727.18K

Props

PropTypeDefaultDescription
datarequiredreadonly T[]—One row per point.
titlerequiredstring—What the chart shows, in a few words: its accessible name, and its heading unless hideTitle.
xrequiredstring | ((datum: T, index: number) => number)—The fields of the two measures.
xLabelrequiredstring—The names of the measures: the axes, the tooltip, the table.
yrequiredstring | ((datum: T, index: number) => number)—The field of the vertical measure.
yLabelrequiredstring—The name of the vertical measure.
brandBrandId—The brand whose palette the charts use. Without it, a chart follows a .brand-<id> ancestor, else Krizaka. Set it when the app loads a brand stylesheet on :root (@krizaka/tokens/brands/orazaka.css).
classNamestring—A class on the figure (layout: margins, grid placement).
dataTableboolean—The "Show data" button (the table is in the page for screen readers either way). Default true.
descriptionReactNode—A sentence under the title: the period, the unit, the source.
emptyReactNode—What to show when there is nothing to draw (default: the empty label). An EmptyState of @krizaka /ui fits.
errorReactNode—The data could not be loaded: true says the default words, a node says yours (a retry button…).
exportableboolean | readonly ExportFormat[]—Export buttons: true for PNG, SVG and CSV, or the formats you want.
groupstring | ((datum: T, index: number) => string)—The field of a point's group: one colour per group (three at most read apart for everyone).
heightnumber—The height of the plot in pixels. Default 280 (a sparkline: 32).
hideTitleboolean—Visually hide the title (it stays the chart's accessible name): a card that already has its heading.
idstring—The id of the figure.
labelsChartLabelsInput—The words, translated: the buttons, the states, the written summary.
liveboolean—Streaming data (a job queue, an auction): no entrance on updates, no announcement of every new point.
loadingboolean—The data is on its way: a skeleton of the chart, announced once.
localeLocale—The locale of every figure and date ("fr-FR"). Default "en-US".
namestring | ((datum: T, index: number) => string)—The field naming a point (the tooltip's title).
rendererRenderer—svg (default): sharp, exportable as SVG. canvas: for tens of thousands of marks.
sizestring | ((datum: T, index: number) => number)—A third measure, drawn as the bubble's area.
sizeFormatValueFormat—How the third measure (the bubbles) is written.
sizeLabelstring—The name of the third measure.
styleCSSProperties—Inline style on the figure (layout only: colours come from the tokens).
summary"hidden" | "visible"—The written summary: read by screen readers only ("hidden", default), or shown under the chart ("visible").
summaryTextstring—Your own summary instead of the generated one (still read first by screen readers).
thresholdsreadonly Threshold[]—Horizontal lines at a y value.
xFormatValueFormat—How each measure is written.
yFormatValueFormat—How the vertical measure is written.

Accessibility

  • The plot is a group named by the title and described by a summary written from the data, read before anything else.
  • The data table is always in the page for assistive technology; “Show data” reveals it for everyone.
  • The engine (ECharts core and this one chart type) loads when the chart nears the screen; a skeleton of the same height holds its place, so nothing shifts.
  • Under reduced motion the chart is drawn without animation.
  • The summary gives both ranges and Pearson's correlation.

Keyboard

KeysAction
TabMoves the focus to the plot (one tab stop), then to the data and export buttons.
Arrow keysWalk the items one by one: each is announced and highlighted, its tooltip shown.
Home / EndJump to the first or the last item.
EscHides the tooltip and clears the highlight.

Best practices

  • Keep to three groups: past that, colours stop reading apart for everyone.
  • Use renderer="canvas" past a few thousand points.

Generated from the code of @krizaka/ui 2.4.0: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page