# Sorted bars

> Use sorted bars to rank items by one value so the order and the gaps read at a glance.

- Data type: Values per item (`compare`)
- Free (MIT): install with `npx chartreuse add sorted-bars`, or registry item `/r/sorted-bars.json`
- Example: **Five G20 countries already make most of their electricity from renewables** (Share of electricity generated from renewables, G20 countries and the world, 2024, %)
- How to read it: Each bar is one country's share of electricity from renewables; the orange bar is the world average.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9 (best 9:16)

## Use it when
- one value per item and the ranking is the point
- 5 to 25 items with readable names
- you want one reference bar (an average or a target) among them

## Avoid it when
- the order of items is meaningful in itself, like months (keep that order)
- values change over time (use a line or a bump chart)
- two values per item (use a dumbbell or grouped bars)

## Fields (data.json)
- `country` (category): the item; "World" is drawn as the reference bar
- `share` (number, unit "%", format percent): share of electricity from renewables, %

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 share against the world average
- Motion: Bars grow from the axis one after another, top first, while their labels count up, so the ranking builds in order.
- Sound: A pop pitched by rank 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": "sorted-bars",
  "title": "Five G20 countries already make most of their electricity from renewables",
  "subtitle": "Share of electricity generated from renewables, G20 countries and the world, 2024, %",
  "data": "/charts/sorted-bars.data.json"
}
```

## Source
Energy dataset (renewables_share_elec), from Ember and the Energy Institute, Our World in Data (CC BY 4.0), retrieved 2026-12-01: https://github.com/owid/energy-data

Note: Renewables include hydro, wind, solar, bioenergy and other renewables; nuclear is not counted.

Live: /charts/sorted-bars · Manifest: /charts/sorted-bars.json · Tags: ranking, bar chart, sorted, energy, renewables, electricity, climate
