# Diverging bars

> Use diverging bars when values can be positive or negative, so gains and losses push away from zero in opposite directions.

- Data type: Values per item (`compare`)
- Free (MIT): install with `npx chartreuse add diverging-bars`, or registry item `/r/diverging-bars.json`
- Example: **Brazil loses twice as much forest each year as China gains** (Net change in forest area, hectares a year, FAO's 2025 estimate; the eight biggest gains and the eight biggest losses)
- How to read it: Bars to the right are countries whose forests grew; bars to the left are countries whose forests shrank, net of any regrowth.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9, 9:16 (best 9:16)

## Use it when
- values have a meaningful zero and can go either way: gains and losses, above and below a target, for and against
- you want to see which side dominates
- up to about 20 items

## Avoid it when
- all values are positive (use sorted bars)
- the zero point is arbitrary
- you need the parts of each change, not just the net (use a waterfall)

## Fields (data.json)
- `year` (year): the FAO estimate's year
- `rows` (id): list of { country, ha }
- `country` (place): the country
- `ha` (number, unit "hectares", format count): net change in forest area, hectares a year (negative is loss)

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 the change
- Motion: Bars grow out of the zero line, gains to the right and losses to the left, the largest changes first.
- Sound: A pop pitched by row on hover. 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": "diverging-bars",
  "title": "Brazil loses twice as much forest each year as China gains",
  "subtitle": "Net change in forest area, hectares a year, FAO's 2025 estimate; the eight biggest gains and the eight biggest losses",
  "data": "/charts/diverging-bars.data.json"
}
```

## Source
Annual change in forest area (FAO Global Forest Resources Assessment), Our World in Data (CC BY 4.0), retrieved 2026-12-01: https://ourworldindata.org/grapher/annual-change-forest-area

Note: Net change is new forest minus forest lost, so a country can clear old forest and still show a gain from plantations.

Live: /charts/diverging-bars · Manifest: /charts/diverging-bars.json · Tags: diverging bars, gains and losses, positive and negative, forests, deforestation, nature, climate
