# Histogram

> Use a histogram to show the shape of one distribution: how many items fall in each equal-width bin, with the median marked.

- Data type: Many values of one measure (`spread`)
- Free (MIT): install with `npx chartreuse add histogram`, or registry item `/r/histogram.json`
- Example: **Half of last month's recorded earthquakes were weaker than magnitude 3.9** (Earthquakes of magnitude 2.5 or more recorded by USGS, 1 November to 1 December 2026)
- How to read it: Each bar counts the quakes in a 0.1 band of magnitude; the dashed line is the median and the darker bars on the right are magnitude 5 or more.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9 (best 16:9)

## Use it when
- one measure across many items (a hundred or more)
- the shape matters: peaks, skew, gaps, long tails
- you want to mark a centre such as the median

## Avoid it when
- fewer than about 30 items (use a strip plot or dot histogram)
- you need to compare several groups (use a box plot, violin or ridgeline)
- the values are categories, not numbers (use bars)

## Fields (data.json)
- `from` (date): first day of the period
- `to` (date): last day of the period
- `magnitudes` (number, unit "magnitude", format decimal): one magnitude per earthquake, to 0.1

Units are the example's: with your own data, set each number field's `unit` and `format` (percent, count, decimal, currency, compact) in the meta you pass to mount, or `chartreuse render --unit field=text --format field=count`. Scales and labels follow your data.

## Interactions, motion, sound
- hover or tap a bar to read its count and share
- Motion: Bars rise from the baseline left to right, then the median line fades in.
- Sound: A soft pop on hover, pitched by magnitude. Quiet while it draws and between steps; mute it from its card. (sound is off until the viewer turns it on)

## Example spec
```json
{
  "chart": "histogram",
  "title": "Half of last month's recorded earthquakes were weaker than magnitude 3.9",
  "subtitle": "Earthquakes of magnitude 2.5 or more recorded by USGS, 1 November to 1 December 2026",
  "data": "/charts/histogram.data.json"
}
```

## Source
Earthquake Hazards Program: magnitude 2.5+ earthquakes, past 30 days, U.S. Geological Survey (Public domain (U.S. Government)), retrieved 2026-12-01: https://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php

Note: The feed records small quakes completely in the United States but few below magnitude 4 elsewhere, so the left side undercounts the world's small quakes.

Live: /charts/histogram · Manifest: /charts/histogram.json · Tags: distribution, bins, earthquakes, median, skew, frequency
