Distribution · Advanced

Box / violin plot

Distribution summary by group (quartiles, median, outliers).

Open in playground
Use when
Distribution and outliers together, such as response time by API
Avoid when
The audience is not used to quartiles (a beeswarm is easier)

Try it

30

Box / violin plot

Response time by API (ms)
Box / violin plotBox plot. /login median 115.5ms, /search median 206ms, /cart median 146ms, /pay median 331ms, /feed median 186.5ms.
Box / violin plot data
/loginmedian 115.5ms, IQR 95.8ms to 141.8ms
/searchmedian 206ms, IQR 171.5ms to 263ms
/cartmedian 146ms, IQR 118ms to 166.8ms
/paymedian 331ms, IQR 272.8ms to 384.3ms
/feedmedian 186.5ms, IQR 148.8ms to 219.8ms
The payment API is the slowestAdvanced

Hover over the chart, or Tab in and use the arrow keys to move between items. The numbers are sample data.

Variants

Named looks for this chart. Each one is the example above with a few options or fields changed. The CLI (ztd-charts example box --variant <id>) and the MCP server know the same names.

Violin

Response time by API (ms)
Sample data

Box and violin

Response time by API (ms)
Sample data

Without outliers

Response time by API (ms)
Sample data

Code

BoxPlot.tsx
import { ChartCard, BoxPlot } from "ztd-charts";

const data = [
  {"api":"/login","ms":210},
  {"api":"/login","ms":150},
  {"api":"/login","ms":104},
  {"api":"/login","ms":126},
  {"api":"/login","ms":170},
  {"api":"/login","ms":157},
  // … 394 more rows
];

export function Example() {
  return (
    <ChartCard number="30" title="Box / violin plot" subtitle="Response time by API (ms)" takeaway="The payment API is the slowest" level="advanced" replay>
      <BoxPlot
        data={data}
        group="api"
        value="ms"
        unit="ms"
        variant="box"
      />
    </ChartCard>
  );
}

Props

<BoxPlot> takes these props. Rows marked Common work the same on every chart.

28 props

Prop
dataRequiredAn array of objects. Pass CSV, REST or database rows as they areobject[]
groupRequiredGroup fieldstring | (d, i) => string
valueRequiredValue fieldstring | (d, i) => number
variantShape"box" | "violin" | "both"Default "box"
outliersShow outlier dotsbooleanDefault true
zeroInclude 0 on the axisbooleanDefault false
whiskersWhisker ends as percentiles [low, high], such as [5, 95]. Without it, whiskers reach the farthest values within 1.5 × IQRnumber[]
heightCommonHeight in px. Without it, each chart picks a default that fits its widthnumber
widthCommonFixed width in px. Without it, the chart fits its parentnumber
highlightCommonItem to highlight. An index, a name, an array, or "max" | "min" | "first" | "last" | "none"number | string | (number|string)[] | "max" …
formatCommonValue format. "number" | "integer" | "percent" (values are already percents: 42 → "42%") | "ratio" (0.42 → "42%") | "compact" | "currency" (KRW for Korean locales, otherwise USD; for another currency pass Intl options with currency) | "decimal" or Intl.NumberFormat options"number" | "percent" | "compact" | …
unitCommonUnit appended to values. For example "%" or "ms"string
localeCommonLocale for numbers, dates and the text a chart writes itself (tooltips, screen reader sentences). "ko" or "ko-*" switches to Korean. Falls back to the ThemeProvider localestringDefault "en-US"
animateCommonEntry and update animationbooleanDefault true
durationCommonAnimation length (ms)number
easingCommonMotion curve"spring" | "easeOut" | "easeInOut" | "linear"Default "spring"
staggerCommonDelay between items as they enter (ms)number
reducedMotionCommon"auto" follows the OS setting. true always turns motion offanyDefault "auto"
animateOnViewCommonPlay when the chart scrolls into viewbooleanDefault true
showLabelsCommonLabels drawn on the chart (values and names)booleanDefault true
tooltipCommonShow tooltips. { template: "{label} · {value} · owner {owner}" } writes them: {label}, {value}, {series} or any other column of the row. \n starts a new line, and a line with an empty value is left outtooltipDefault true
syncIdCommonCharts with the same syncId show the hovered x together (line, area, bar, candlestick). <ChartGrid sync> sets one for every chart inside itstring
ariaLabelCommonName for screen readersstring
descriptionCommonDescription for screen readers. Built from the data when omittedstring
onHoverCommonRuns when hover or keyboard focus moves to another item(e: ChartEvent | null) => void
onClickCommonRuns on click, Enter or Space(e: ChartEvent) => void
replayKeyCommonReplays the entry animation when it changesstring | number
themeCommonChanges theme tokens for this chart onlyPartial<ChartTheme>