Skip to content
kerfjsGitHub

BoxPlot

Compares the spread of several groups: median, middle half and outliers.

SourcePackage @kerf-js/veneer

Preview

tsx
import { BoxPlot } from '@kerf-js/veneer'export function Regions() {  return (  <BoxPlot    title="Latency by region"    description="Last hour"    data={LATENCY_BY_REGION}    format={ms}  />  )}const wobble = (i: number) =>  (Math.sin(i * 12.9898) * 43758.5453) % 1const LATENCY_BY_REGION = [  'eu-west',  'us-east',  'ap-south',  'us-west',  'eu-north',].map((name, r) => ({  name,  values: Array.from({ length: 60 }, (_, i) =>    Math.round(      58 +        r * 21 +        Math.abs(wobble(i + r * 80)) * (40 + r * 14) +        (i === 7 + r ? 140 : 0),    ),  ),}))const ms = (v: number) => `${Math.round(v)} ms`

Installation

npm install @kerf-js/veneer

Usage

tsx
import { BoxPlot } from '@kerf-js/veneer'<BoxPlot  title="Latency by region"  description="Last hour"  data={LATENCY_BY_REGION}  format={ms}/>

Accessibility

  • Every chart has a text alternative and a table view of its numbers, so nothing depends on seeing the marks. See Chart for its keyboard support.

API Reference

PropTypeDefaultDescription
titlestring—The heading.
level2 | 3 | 4 | 6 | 5—The title's heading level: one below the heading the chart sits under. Default 3, a chart in a page section.
descriptionunknown—One supporting line under the title.
toolbarunknown—Beside the view toggle: a layout switch, a range picker.
state"error" | "loading" | "empty"—Replaces the plot, in the same frame. With no data the frame shows empty on its own.
loadingstring—Shows that work is under way.
empty{ title: string; detail?: unknown; }—The title and detail shown in place of the plot when there is no data.
error{ title: string; detail?: unknown; }—A message that marks the field invalid and says why.
actionunknown—The next step under an empty or error state: a Retry button.
data{ name: string; values: number[]; }[]—The series to draw.
summarystring | ((c: { data: { name: string; values: number[]; }[]; title: stri…—One sentence for screen readers and the page; generated from the data when absent.
formatFmt—Turns a value into the text shown.

RelatedHistogram