Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Web docs
Data display

Histogram

Shows a numeric distribution using explicit bins and an accessible frequency table.

FrameworksAstro · React · Elements

Registry commandlumen add Histogram

InteractionNative markup

← All chart guides · Framework setup · Native counterparts

01

See it and copy it

Framework example

Explore the live chart, then open its code for Astro, React, or Elements.

AstroCode target · live preview uses Astro

Most requests finish in under 500 ms

1,180 requests · Response time (ms) · Last 24 hours

1 series, 10 points. Values range from 11 to 302.

Requests

View chart data
CategoryStartEndRequests
0–100010018
100–20010020096
200–300200300218
300–400300400302
400–500400500244
500–600500600146
600–70060070082
700–80070080042
800–90080090021
900–1000900100011
Equal 100 ms bins reveal a long tail beyond the 300–400 ms peak. Illustrative data; bin counts are calculated by the application.
View Histogram code

Framework usage

Switch targets to compare the adapter code. This live preview runs the Astro example. React and Elements use their own behavior APIs; complete the matching framework setup before copying an example.
astro
---
import { Histogram } from '@santi020k/lumen-astro'

const bins = [18, 96, 218, 302, 244, 146, 82, 42, 21, 11].map((count, index) => ({
  start: index * 100,
  end: (index + 1) * 100,
  count
}))
---

<Histogram
  aria-label="Request count by response time in milliseconds"
  heading="Most requests finish in under 500 ms"
  description="1,180 requests · Response time (ms) · Last 24 hours"
  caption="Equal 100 ms bins reveal a long tail beyond the 300–400 ms peak. Illustrative data; bin counts are calculated by the application."
  valueLabel="Requests"
  {bins}
/>
Edit Histogram in browser

When to use Histogram

Use for a continuous measure such as response time, order value, or duration after your application groups observations into bins.

  • In count mode, height represents observations in a bin. In density mode, area represents count, so a wider bin does not exaggerate its concentration.
  • Use formatBoundary for the measured axis and formatValue for frequency. The table retains raw counts alongside the plotted frequency.

Prepare the data

ts
import type { LumenHistogramBin } from '@santi020k/lumen-core'

const bins = [
  { start: 0, end: 100, count: 8 },
  { start: 100, end: 200, count: 24 },
  { start: 200, end: 300, count: 42 }
] satisfies readonly LumenHistogramBin[]
  • The application owns binning. Provide finite start/end boundaries with start below end and a finite, nonnegative count.
  • Bins are sorted by start. They must not overlap; gaps are allowed and keep their numeric spacing.
  • The default frequency="count" requires equal-width bins. Use frequency="density" for unequal widths; density is count divided by bin width.

Shared data and formatting guidance →

Avoid misleading comparisons

  • Bin width changes the apparent shape. Use the same boundaries when comparing populations and explain your binning convention.
  • Density here is count per unit of width, not a probability density normalized to a total area of one.

Chart accessibility and keyboard guidance →

02

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add Histogram
lumen add Histogram

API reference

Lumen-specific props and runtime attributes for the Astro primitive. Use the framework differences above and the copyable examples for React composition and Elements attributes; the public adapter types define their supported contracts.

AttributeValuesDefaultDescription
binsLumenHistogramBin[]requiredSupplies non-overlapping numeric start/end boundaries and nonnegative counts. The application owns binning.
frequency"count" | "density""count"Density divides count by bin width. Unequal-width bins require density.
formatBoundary, formatValueformatter functionsStringFormats numeric boundaries and the plotted frequency.
valueLabel, labelsstring, Partial<LumenChartLabels>localized defaultsLabels the measure and the accessible data table.
showTablebooleantrueRetains raw bin counts alongside the plotted frequency.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Web docsFull catalog