Skip to content
StatisticalGenerated from the public API

DistributionChart

See the distribution, the agreement or the uncertainty in the values you supply.

@luc/ui/charts

What it shows

Combine a supplied histogram with an optional density curve and reference markers for a richer distribution reading.

Live preview

A pre-binned sample with a supplied density overlay and two reference markers — the library bins and fits nothing.

<DistributionChart
  bins={[
    { from: -3, to: -2, count: 4 },
    { from: -2, to: -1, count: 18 },
    { from: -1, to: 0, count: 46 },
    { from: 0, to: 1, count: 52 },
    { from: 1, to: 2, count: 21 },
    { from: 2, to: 3, count: 6 },
  ]}
  density={{
    x: [-2.6, -2, -1.4, -0.8, -0.2, 0.4, 1, 1.6, 2.2, 2.8],
    y: [0.02, 0.08, 0.2, 0.36, 0.46, 0.38, 0.22, 0.1, 0.04, 0.01],
    label: "Kernel estimate",
  }}
  references={[
    { value: -0.12, label: "Median", kind: "median" },
    { value: 0.04, label: "Mean", kind: "mean" },
  ]}
  xFormat={{ kind: "percent", decimals: 0 }}
  format={{ kind: "integer" }}
  height={320}
  ariaLabel="Return distribution"
/>

Controls

Height

320px

A chart measures its container, so it always needs a definite height.

State

The surface the chart is in — loading, empty and error are drawn by the component.

Accessible name

A drawing is not readable by a screen reader, so it needs a name that states what it shows.

The same fixture as the live preview above; the controls change how it is drawn, not what it measures.

Code
import { DistributionChart } from "@luc/ui/charts";

<DistributionChart
  bins={[
    { from: -3, to: -2, count: 4 },
    { from: -2, to: -1, count: 18 },
    { from: -1, to: 0, count: 46 },
    { from: 0, to: 1, count: 52 },
    { from: 1, to: 2, count: 21 },
    { from: 2, to: 3, count: 6 },
  ]}
  density={{
    x: [-2.6, -2, -1.4, -0.8, -0.2, 0.4, 1, 1.6, 2.2, 2.8],
    y: [0.02, 0.08, 0.2, 0.36, 0.46, 0.38, 0.22, 0.1, 0.04, 0.01],
    label: "Kernel estimate",
  }}
  references={[
    { value: -0.12, label: "Median", kind: "median" },
    { value: 0.04, label: "Mean", kind: "mean" },
  ]}
  xFormat={{ kind: "percent", decimals: 0 }}
  format={{ kind: "integer" }}
  height={320}
  ariaLabel="Return distribution"
  state="ready"
/>

Not controllable here

  • series / rows — The numbers are the caller's; the fixture above is the example.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `DistributionChart` from Luc UI. It is: See the distribution, the agreement or the uncertainty in the values you supply.

Import it with: import { DistributionChart } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.

Chosen configuration: `height={320}`, `state="ready"`, `ariaLabel="Return distribution"`.

Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.

Reproduce this state:
```tsx
<DistributionChart
  bins={[
    { from: -3, to: -2, count: 4 },
    { from: -2, to: -1, count: 18 },
    { from: -1, to: 0, count: 46 },
    { from: 0, to: 1, count: 52 },
    { from: 1, to: 2, count: 21 },
    { from: 2, to: 3, count: 6 },
  ]}
  density={{
    x: [-2.6, -2, -1.4, -0.8, -0.2, 0.4, 1, 1.6, 2.2, 2.8],
    y: [0.02, 0.08, 0.2, 0.36, 0.46, 0.38, 0.22, 0.1, 0.04, 0.01],
    label: "Kernel estimate",
  }}
  references={[
    { value: -0.12, label: "Median", kind: "median" },
    { value: 0.04, label: "Mean", kind: "mean" },
  ]}
  xFormat={{ kind: "percent", decimals: 0 }}
  format={{ kind: "integer" }}
  height={320}
  ariaLabel="Return distribution"
  state="ready"
/>
```

Usage

The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.

It is drawn by the ECharts engine.

Worked examples with real data are on the family overview: Statistical

import { DistributionChart } from "@luc/ui/charts";
<DistributionChart
  bins={[
    { from: -3, to: -2, count: 4 },
    { from: -2, to: -1, count: 18 },
    { from: -1, to: 0, count: 46 },
    { from: 0, to: 1, count: 52 },
    { from: 1, to: 2, count: 21 },
    { from: 2, to: 3, count: 6 },
  ]}
  density={{
    x: [-2.6, -2, -1.4, -0.8, -0.2, 0.4, 1, 1.6, 2.2, 2.8],
    y: [0.02, 0.08, 0.2, 0.36, 0.46, 0.38, 0.22, 0.1, 0.04, 0.01],
    label: "Kernel estimate",
  }}
  references={[
    { value: -0.12, label: "Median", kind: "median" },
    { value: 0.04, label: "Mean", kind: "mean" },
  ]}
  xFormat={{ kind: "percent", decimals: 0 }}
  format={{ kind: "integer" }}
  height={320}
  ariaLabel="Return distribution"
/>

Data contract

`bins` are `{ from, to, count }`; `density` is aligned `{ x, y }` points; `references` are supplied `{ value, label, kind }` markers. Nothing is fitted by the chart.

Important configuration

Use `xFormat` and `format` for the two units, label the density's source, and keep reference markers outside the curve's claim unless that relationship is intentional.

Guidelines

When not to use

Do not treat the overlay as a statistical fit or let a density curve imply observations that the binned sample did not contain.

Configuration

Exported symbols
ExportKindSignature
DistributionChart19 documented props({ bins, density, references, signed, xFormat, format, tone, annotations, title, description, state, height, className, ariaLabel, ariaDescription, onReady, onEvent, }: DistributionChartProps) => imp…

DistributionChart props

Type: DistributionChartProps

Values the compiler reads from the declaration.

DistributionChart props
PropTypeDefaultNotes
annotations?AnnotationSpec | undefined—
ariaDescription?string | undefined—
ariaLabel?string | undefined—
binsreadonly HistogramBin[]—Pre-binned sample. Binning is the analytics layer's job.
className?string | undefined—
density?DensityCurve | undefined—Optional prepared density curve (a kernel estimate the caller computed).
description?string | undefined—
format?ChartFormat | undefined—
height?string | number | undefined—
onEvent?((event: EChartEvent) => void) | undefined—
onReady?((chart: EChartsInstance) => void) | undefined—
references?readonly DistributionReference[] | undefined—Median / mean / percentile markers, already computed.
signed?boolean | undefined—Split the bars by sign (returns above/below zero, PnL, surprise). Bars take the semantic positive/negative colours; a single-signed sample stays one colour rather than pretending …
state?ChartState | undefined—
title?string | undefined—
tone?SeriesTone | undefined—
xFormat?ChartFormat | undefined—
xLabel?string | undefined—Display name of the value axis ("Return", "Observations"). An unlabelled pair of numbers leaves the reader to guess which axis is the bin and which is the count. The name is prese…
yLabel?string | undefined—

Accessibility

A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.

What happens on the server, and when hydration changes it.

Luc UI v1.0DistributionChartdark theme