# Time ranges

> Use time ranges (a Gantt chart) to show when each item started and ended, so lengths, overlaps and gaps are visible at once.

- Data type: Values over time (`time`)
- Free (MIT): install with `npx chartreuse add gantt`, or registry item `/r/gantt.json`
- Example: **Since 1990 the Pacific has spent about half its months in El Niño or La Niña** (El Niño and La Niña episodes by the Oceanic Niño Index, January 1990 to September 2026)
- How to read it: Each bar is one episode from its first to its last month; orange is El Niño, blue La Niña, and darker bars peaked stronger.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9 (best 16:9)

## Use it when
- each item has a start and an end
- durations, overlaps or gaps between items matter
- up to about 30 items

## Avoid it when
- items are single moments (use an event timeline)
- more than six kinds of item (the rest share one colour)
- hundreds of items (aggregate them)
- only the totals matter (use bars)

## Fields (data.json)
- `episodes[].type` (category): the kind of item, which sets its colour (El Niño or La Niña in the example); kinds in order of first appearance, up to six, the rest share one 'other' colour. meta.hints.<kind> adds a word to its key
- `episodes[].start` (date): when the item starts: a year, a month (YYYY-MM, as in the example: the centre month of the first season), a day or an ISO date-time
- `episodes[].end` (date): when the item ends, at any grain: a year, month or day counts through its end; a date-time is the exact end
- `episodes[].seasons` (number, unit "seasons", format count): a count shown for each item (overlapping three-month seasons in the example)
- `episodes[].peak` (number, unit "°C", format decimal): the item's peak value, which sets its shade (the strongest Oceanic Niño Index value, °C, in the example); a + sign shows only when values run both sides of zero
- `episodes[].ongoing` (category): true when the episode was still running in the latest data
- `last` (date): the latest date in the data, at any grain (the end of the timeline); without it the latest end is used

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 dates, length and peak
- Play steps through the episodes in order
- Motion: Bars grow from their start month, one episode after another down the page.
- Sound: A pop on hover, higher for El Niño than La Niña. 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": "gantt",
  "title": "Since 1990 the Pacific has spent about half its months in El Niño or La Niña",
  "subtitle": "El Niño and La Niña episodes by the Oceanic Niño Index, January 1990 to September 2026",
  "data": "/charts/gantt.data.json"
}
```

## Source
Oceanic Niño Index (ONI), 3-month running mean of ERSST.v5 Niño 3.4 anomalies, NOAA Climate Prediction Center (Public domain (NOAA data)), retrieved 2026-12-01: https://www.cpc.ncep.noaa.gov/products/analysis_monitoring/ensostuff/ONI_v5.php

Note: Episodes are found in the chart's data script with NOAA's rule: at least five overlapping seasons at or above +0.5 °C (El Niño) or at or below −0.5 °C (La Niña).

Live: /charts/gantt · Manifest: /charts/gantt.json · Tags: gantt, time ranges, durations, climate, El Niño, ocean
