# Range (dumbbell)

> Show the span between two values per category as a dumbbell, an arrow or a floating bar, for change between two periods or a low to high range.

A range chart draws one row per category with a start and an end value. The reader sees where each category began, where it ended and how big the move was. It answers "who moved, and by how much?" for one pair of periods, or shows a low to high span such as a monthly temperature range.

For a trajectory over many periods, use a [line chart](/docs/change-over-time/line/) or a [slope chart](/docs/change-over-time/slope-bump/). For one value per category, use a [bar chart](/docs/comparison/bar/).

## A dumbbell

Set `mark` to `"range"` with the start value on `x` and the end value on `x2`. Each row has a dot at both values. `title` on each channel names the endpoint, and the `sort` object on the category channel orders the rows by one of the fields.

```json
{
  "mark": "range",
  "data": [
    {
      "country": "Japan",
      "y2000": 81.1,
      "y2023": 84.7
    },
    {
      "country": "South Korea",
      "y2000": 76,
      "y2023": 84.3
    },
    {
      "country": "USA",
      "y2000": 76.7,
      "y2023": 79.3
    },
    {
      "country": "China",
      "y2000": 71.6,
      "y2023": 78.6
    },
    {
      "country": "Brazil",
      "y2000": 70.1,
      "y2023": 75.8
    },
    {
      "country": "Russia",
      "y2000": 65.5,
      "y2023": 73
    },
    {
      "country": "India",
      "y2000": 62.7,
      "y2023": 72
    },
    {
      "country": "Nigeria",
      "y2000": 46.5,
      "y2023": 54.6
    }
  ],
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "Life expectancy rose in all eight countries from 2000 to 2023",
    "subtitle": "Life expectancy at birth, 2000 (gray) vs. 2023 (accent), selected countries"
  }
}
```

## An arrow plot

`style: "arrow"` puts an arrowhead at the end value, so direction reads at a glance. `colorByDirection: true` colors each arrow by whether its value grew or shrank. The data holds one row per source with a value in 2010 and a value in 2024.

```json
{
  "mark": {
    "type": "range",
    "style": "arrow",
    "colorByDirection": true
  },
  "data": [
    {
      "source": "Coal",
      "y2010": 44.8,
      "y2024": 15
    },
    {
      "source": "Natural gas",
      "y2010": 23.9,
      "y2024": 43.2
    },
    {
      "source": "Nuclear",
      "y2010": 19.6,
      "y2024": 18.2
    },
    {
      "source": "Wind",
      "y2010": 2.3,
      "y2024": 10.3
    },
    {
      "source": "Hydro",
      "y2010": 6.3,
      "y2024": 5.6
    },
    {
      "source": "Solar",
      "y2010": 0.1,
      "y2024": 6.9
    }
  ],
  "encoding": {
    "y": {
      "field": "source",
      "type": "nominal",
      "sort": {
        "field": "y2024",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2010",
      "type": "quantitative",
      "title": "2010",
      "axis": {
        "title": "Share of US electricity generation (%)"
      }
    },
    "x2": {
      "field": "y2024",
      "type": "quantitative",
      "title": "2024"
    }
  },
  "chrome": {
    "title": "Coal's share fell from 45% to 15% as gas, wind and solar grew",
    "subtitle": "Share of US electricity generation by source, 2010 to 2024. Green arrows grew, red shrank."
  }
}
```

## A floating bar

`style: "bar"` draws a plain bar from the start to the end value. Swap the channels to run it vertically: the category on `x`, the low value on `y` and the high value on `y2` give a column for each month.

```json
{
  "mark": {
    "type": "range",
    "style": "bar",
    "fill": "#0e7490"
  },
  "data": [
    {
      "month": "Jan",
      "low": 3.5,
      "high": 9.3
    },
    {
      "month": "Feb",
      "low": 0.9,
      "high": 9.2
    },
    {
      "month": "Mar",
      "low": 3.2,
      "high": 10.8
    },
    {
      "month": "Apr",
      "low": 9.4,
      "high": 19
    },
    {
      "month": "May",
      "low": 12,
      "high": 22.1
    },
    {
      "month": "Jun",
      "low": 16.8,
      "high": 25.4
    },
    {
      "month": "Jul",
      "low": 22.1,
      "high": 30.2
    },
    {
      "month": "Aug",
      "low": 20.2,
      "high": 27.6
    },
    {
      "month": "Sep",
      "low": 17.3,
      "high": 24.3
    },
    {
      "month": "Oct",
      "low": 12.4,
      "high": 19.3
    },
    {
      "month": "Nov",
      "low": 4.5,
      "high": 11.8
    },
    {
      "month": "Dec",
      "low": 4.2,
      "high": 9.8
    }
  ],
  "encoding": {
    "x": {
      "field": "month",
      "type": "nominal"
    },
    "y": {
      "field": "low",
      "type": "quantitative",
      "title": "Avg low",
      "axis": {
        "title": "Temperature (°C)"
      }
    },
    "y2": {
      "field": "high",
      "type": "quantitative",
      "title": "Avg high"
    }
  },
  "chrome": {
    "title": "New York's monthly averages run from about 1°C to 30°C",
    "subtitle": "Average daily low to high temperature by month, Central Park, 2023"
  }
}
```

## A horizontal floating bar

The same style with `x` and `x2` gives horizontal bars. Use it when category names are long or when you want the bar form with the same data as the dumbbell. `fill` sets the bar color.

```json
{
  "mark": {
    "type": "range",
    "style": "bar",
    "fill": "#0e7490"
  },
  "data": [
    {
      "country": "Japan",
      "y2000": 81.1,
      "y2023": 84.7
    },
    {
      "country": "South Korea",
      "y2000": 76,
      "y2023": 84.3
    },
    {
      "country": "USA",
      "y2000": 76.7,
      "y2023": 79.3
    },
    {
      "country": "China",
      "y2000": 71.6,
      "y2023": 78.6
    },
    {
      "country": "Brazil",
      "y2000": 70.1,
      "y2023": 75.8
    },
    {
      "country": "Russia",
      "y2000": 65.5,
      "y2023": 73
    },
    {
      "country": "India",
      "y2000": 62.7,
      "y2023": 72
    },
    {
      "country": "Nigeria",
      "y2000": 46.5,
      "y2023": 54.6
    }
  ],
  "encoding": {
    "y": {
      "field": "country",
      "type": "nominal",
      "sort": {
        "field": "y2023",
        "order": "ascending"
      }
    },
    "x": {
      "field": "y2000",
      "type": "quantitative",
      "title": "2000",
      "axis": {
        "title": "Life expectancy at birth (years)"
      }
    },
    "x2": {
      "field": "y2023",
      "type": "quantitative",
      "title": "2023"
    }
  },
  "chrome": {
    "title": "Each bar spans a country's gain since 2000",
    "subtitle": "Life expectancy at birth, 2000 to 2023, selected countries"
  }
}
```

## Fields that matter

| Field | What it does |
| --- | --- |
| `mark` | `"range"`, or an object with `type: "range"` and a `style` of `"dumbbell"`, `"arrow"` or `"bar"`. |
| `encoding.x`, `encoding.x2` | The start and end values of a horizontal range. |
| `encoding.y`, `encoding.y2` | The start and end values of a vertical range, with the category on `x`. |
| `encoding.*.title` | Names an endpoint, such as "2000" and "2023". |
| `encoding.y.sort` | Orders the categories by another field, with `order` set to `"ascending"` or `"descending"`. |
| `colorByDirection` | On the mark, colors each range by whether it rose or fell. |
| `fill` | On the mark, sets the bar color. |

## Related

- [Slope and bump](/docs/change-over-time/slope-bump/) for the same before and after question across many series.
- [Lollipop](/docs/comparison/lollipop/) for one value per category, and for dumbbells built from long-format data.
- [Error bars](/docs/distribution/error-bars/) for an interval around an estimate.
- [Marks reference](/docs/spec/marks/) lists the channels and options each mark type takes.
