Distribution Chart
Distribution chart for raw observations: histograms, box plot, violin, density, ridgeline, strip plot and error bars.
Playground
Installation
Distribution Chart comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
DistributionChart,
DistributionChartProps,
DistributionChartVariant,
} from "@wunderui/react/charts"Then use it:
import { DistributionChart } from "@wunderui/react/charts"
const groups = [{ label: "API", values: [82, 91, 88, 120, 95, 140, 87, 99, 210, 101] }]
export function ResponseTime() {
return <DistributionChart groups={groups} label="Response time" />
}Expected result: You see a histogram of the ten response times, with most of them in the left bars and one slow value to the right.
When to use
Use Distribution Chart for
- How raw observations spread: latencies, durations, sizes
- Comparing the spread of two or three groups (boxplot, violin, ridgeline)
- Percentiles marked on a histogram
Use something else for
- Bar Chart for values that are already summed per category
- Range Bar Chart for a known minimum and maximum per category
- Bubble Chart for the relation between two measures
- Heatmap for values across two dimensions
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable: arrow keys walk the bins, or the groups on box, violin, strip and error-bar variants, and the live region reads each one.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous bin. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last bin.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Raw values in
- Groups take a label, a colour and the raw numbers, not summaries. Bins, quartiles and densities are computed inside the chart, and the bin count sets the histogram resolution (24 by default).
- Markers
- Markers draw labelled vertical lines at values such as p50 and p95, or a service-level target.
- Box plot
- The box runs from Q1 to Q3 with the median inside. Whiskers reach 1.5 times the interquartile range, and points beyond are drawn as outlier dots.
- Axis
- The count axis of histograms and densities starts at 0, the cumulative one runs 0 to 100 percent, and the other variants fit the axis to the data. Ridgeline drops the value axis.
- Loading, empty and error
- Loading shows a shimmering skeleton, empty and error show a centred message, and error adds a Try again button when a retry handler is set. The card never changes height.
- Legend
- A ChartCard shows the series as badges. With two or more, each badge toggles its series off (the last visible one stays on), and a static legend works for roles.
- Size
- The chart fills the width of its container, and a height setting controls the plot. Text never scales, so labels keep their size at every width.
Motion
The enter sequence and the hover follow the motion tokens of the library.
- Enter
- The marks play an enter sequence the first time the chart is in view, and again after loading or when the data changes. It can be turned off.
- Reduced motion
- With reduced motion the enter sequence is off and the chart appears at once. The tooltip, the crosshair and every state still work.
Anatomy
DistributionChart shows how raw observations spread, as histograms, boxplot, violin, density, ridgeline, strip plot or error bars. It computes bins, quartiles and densities itself.
Response time
| bin | API |
|---|---|
| 80 ms | 9 ms |
| 88 ms | 3 ms |
| 96 ms | 3 ms |
| 103 ms | 1 ms |
| 111 ms | 2 ms |
| 119 ms | 2 ms |
| 127 ms | 1 ms |
| 135 ms | 2 ms |
| 142 ms | 4 ms |
| 150 ms | 1 ms |
| 158 ms | 2 ms |
| 166 ms | 0 ms |
| 174 ms | 0 ms |
| 181 ms | 0 ms |
| 189 ms | 1 ms |
| 197 ms | 2 ms |
| 205 ms | 0 ms |
| 212 ms | 1 ms |
| 220 ms | 0 ms |
| 228 ms | 0 ms |
| 236 ms | 0 ms |
| 244 ms | 0 ms |
| 251 ms | 1 ms |
| 259 ms | 1 ms |
Takes groups, each with a label, a colour and the raw numbers, not summaries. The bin count sets the histogram resolution (24 by default) and markers draw lines such as p50 and p95.
- data-slot="chart-plot"
The focusable region. Arrow keys walk the bins, or the groups on box, violin, strip and error-bar variants, and the live region reads each one.
- data-slot="chart-grid"
The count axis of histograms and densities starts at 0, the cumulative one runs 0 to 100 percent, and the other variants fit the axis to the data. Ridgeline drops the value axis.
- data-slot="chart-marks"
Bars for histograms, a box with whiskers and outlier dots for boxplot, a mirrored curve for violin, a smoothed line for density and ridgeline, and jittered dots for strip plot.
Vertical reference lines with a label, for percentiles or a service-level target.
- data-slot="chart-tooltip"
The bin with its count, or on box variants the median, Q1 to Q3 and range, and on error bars the mean and one standard deviation.
- data-slot="chart-message"
Muted columns, or rows on ridgeline, under the shimmer; density loads as a muted area. Empty and error use the shared message and Try again button.
Bins or summary statistics as a table for screen readers.
Best practices
- Do
Pass the raw observations. Pre-aggregated bins break the quartiles and the density, because the chart aggregates once and the same way everywhere.
- Do
Pick bins for the story. Around 20 to 30 shows the shape of a few thousand points, fewer than 10 hides it, and charts you compare should share one bin width.
- Do
Mark the percentiles people act on, such as p50 and p95. A long tail looks harmless until a line shows where most requests end.
- Don’t
Don't use density or violin curves for fewer than about 30 points. The smoothing invents a shape, so show a strip plot of the points instead.
- Don’t
Don't compare groups with histograms of different bin widths. Use a layered histogram or boxplot, which share one scale.
API reference
One table covers DistributionChart and lists every prop. The ChartCard around it has its own props, and the chart works without one.
Takes groups, each with a label, a colour and the raw numbers, not summaries. The bin count sets the histogram resolution (24 by default) and markers draw lines such as p50 and p95.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("distribution-chart")The full library index for assistants is at /llms.txt.