BoxPlot

Summarizes the spread of raw observations per category: quartiles, median, whiskers, and outliers.

stable

Quick Preview

Asking prices by neighbourhood

Active listings · ₦m

Usage

import { BoxPlot } from "@giddaa-housing/ui/box-plot";

<BoxPlot
  data={[
    { area: "Lekki", price: 85 },
    { area: "Lekki", price: 104 },
    { area: "Yaba", price: 42 },
    { area: "Yaba", price: 55 },
  ]}
  categoryKey="area"
  valueKey="price"
  formatValue={(value) => `₦${value}m`}
  ariaLabel="Spread of asking prices by neighbourhood"
/>

Pass raw observations, one row per observation. Each category is summarized with Tukey rules: the box spans Q1–Q3, the line is the median, and whiskers reach the furthest observations within 1.5 × IQR. Points beyond are outlier dots with their own tooltip. outliers={false} stretches whiskers to the minimum and maximum instead. Categories appear in first-seen order unless categories sets it.

Examples

Default

Asking prices by neighbourhood

Active listings · ₦m

Horizontal, ordered categories

orientation="horizontal" suits long category names; categories fixes the order and drops observations in other categories.

Days on market

Sold properties · last 12 months

Props

Prop/APITypeDefaultDescription
datareadonly T[]requiredRaw observations, one row per observation.
categoryKeystring or number field of TrequiredGroup of each observation; rows without one are omitted.
valueKeynumeric field of TrequiredValue summarized per group; missing values are omitted.
ariaLabelstringrequiredAccessible chart name.
categories(string | number)[]first-seen orderExplicit order; other categories are omitted.
orientation"vertical" | "horizontal""vertical"Box direction.
size"sm" | "md" | "lg"inherited, otherwise "md"Plot height and type.
colorCSS colorchart-1Box, median, and outlier color.
colorByCategorybooleanfalseA palette slot per category instead of one color.
outliersbooleantrueOutlier dots beyond 1.5 × IQR; false spans whiskers to min and max.
tooltipbooleantrueHover and keyboard tooltip with the five-number summary.
gridbooleantrueValue grid lines.
valueDomain[number, number]fitted to the observationsFixed value-axis extent.
valueTicksnumber[]roundedExact value-axis ticks.
formatValue(value: number) => stringgrouped numberValue axis and every tooltip value.
formatCategory(value: string | number) => stringStringCategory labels.
emptyMessageReactNode"No data to display"Shown when no valid observations exist.
Chart host propssee Chart-height, initialWidth, ariaDescription, tooltipFooter, renderTooltipBody, callbacks, className, style.
createBoxPlotDefinition(options)function-Same options; returns an extensible TanStack definition.
BoxPlotSummary, BoxPlotOutlier, BoxPlotDatum, BoxPlotDefinitiontypes-Exported for typed builders.

Accessibility

  • Provide a meaningful ariaLabel; focus the chart and use arrow keys to move between boxes and outliers.
  • Box plots assume a statistical reader; say what the box and whiskers mean in the description for a general audience.
  • Show the sample size per category nearby when groups are small; a box from five points reads as more certain than it is.

On this page