Components / Charts

Histogram

Binned distributions with drag-to-brush range selection.

@ruckc/truss-chart Charts

Import

import { Histogram } from '@ruckc/truss-chart';
import '@ruckc/truss-chart/charts.css'; // series palette

Playground

bins
data

API

PropTypeDefaultDescription
values required number[]—The numbers to plot.
bins number | 'auto''auto'Approximate bin count, or 'auto' (Sturges). Edges snap to nice numbers.
domain [number, number]—Fixed `[min, max]` for the value axis (defaults to the data extent).
title string—Heading text.
subtitle string—Secondary text under the title.
height number240Height in pixels (or any CSS length).
color stringseriesColor(0)Series colour (a CSS colour or `var(--trc-sN)` token).
xFormat (n: number) => stringfmtValueFormats x-axis numbers.
range bindable [number, number] | nullnullBrushed selection [from, to] on the value axis (snaps to bin edges). Drag to select, click to clear.
onbrush event(range: [number, number] | null) => void—Called when the brushed range changes.
/docs/histogram Truss UI · MIT