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
| Prop | Type | Default | Description |
|---|---|---|---|
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 | number | 240 | Height in pixels (or any CSS length). |
color | string | seriesColor(0) | Series colour (a CSS colour or `var(--trc-sN)` token). |
xFormat | (n: number) => string | fmtValue | Formats x-axis numbers. |
range bindable | [number, number] | null | null | Brushed 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. |