# Range Bar Chart

Range bar chart for a span per category — minimum to maximum, planned against actual, as dumbbells or as gradient bars.

- Category: Charts
- Page: https://wunderui.com/components/range-bar-chart
- Tier: Core and Pro

## Install

Range Bar Chart ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { RangeBarChart, RangeBarChartProps, RangeBarChartVariant } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
import { RangeBarChart } from "@wunderui/react/charts"

const data = [
  { month: "Jan", min: 0, max: 7 },
  { month: "Feb", min: 1, max: 9 },
  { month: "Mar", min: 4, max: 13 },
]

export function TemperatureRange() {
  return <RangeBarChart data={data} index="month" label="Temperature range per month" />
}
```

Expected result: You should see one floating bar per month, from its lowest to its highest value, on an axis that does not start at 0.

## When to use

### Use Range Bar Chart for

- A minimum and a maximum per category (temperatures, price ranges)
- Planned against actual spans (schedules, ranges of weeks)
- A dumbbell or a gradient span for a range between two measures

### Use something else

- [Bar Chart](https://wunderui.com/components/bar-chart) for one value per category
- [Timeline Chart](https://wunderui.com/components/timeline-chart) for tasks and milestones on a time axis
- [Distribution Chart](https://wunderui.com/components/distribution-chart) for the spread of raw observations
- [Waterfall Chart](https://wunderui.com/components/waterfall-chart) for changes that add up to a total

## Keyboard

The plot is focusable: Arrow keys walk the categories, and the tooltip and live region give both ends of every range.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge. |
| `ArrowRight` or `ArrowLeft` | Moves to the next or previous category. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one). |
| `Home` or `End` | Jumps to the first or last category. |
| `Escape` | Clears the active point. |
| `Enter` or `Space` | On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on. |

## Behavior

What the chart does on its own and what the page decides.

- **Ranges:** Ranges is a list of low, high, label and colour field names (default min to max). Several ranges per category show planned against actual, and without a colour they take the standard pair, indigo and pink.
- **Domain:** The value axis is fitted to the lows and highs and does not include zero by default, so a short span in a high range stays readable. Horizontal range bars put the category on the left.
- **No change chip:** The tooltip shows each range as low to high with its colour and no change chip, since a span has no previous value.
- **Loading, empty and error:** The chart keeps its size while loading, empty or failed, so the card never changes height. Add a retry handler to show a Try again button on error.
- **Legend:** In a ChartCard, each series badge is a button that switches its series off, but the last visible series stays on. A legend of roles can be made static.
- **Size:** The chart fills the width of its container and you set the plot height. Text never scales, so labels keep their size at every width.

## Motion

The enter sequence and the hover follow the motion tokens of the library.

- **Enter:** Range bars and dumbbell stems open from their middle, left to right, and the dumbbell dots pop in as their stem lands. Horizontal ranges grow from their start.
- **Hover:** The hovered category keeps its strength and the others dim.
- **Reduced motion:** With reduced motion on, the chart appears at once without the enter sequence. The tooltip and every state still work.

## Anatomy

- `RangeBarChart`: Pass data with the field for the category name and a list of ranges, each with low and high fields, a label and a colour. Several ranges per category show planned against actual.
- `Plot`: The focusable region. Arrow keys walk the categories, and the tooltip and live region give both ends of every range, such as Jan: Range 4 °C to 12 °C.
- `Grid and axes`: The domain is fitted to the lows and highs, so a short span in a high range stays readable. Horizontal range bars put the category on the left.
- `Spans`: One rounded bar from low to high per range, a dumbbell (two dots joined by a stem) on the dots variant, or a fill that fades from low to high on the gradient variant.
- `Tooltip`: Each range as low to high with its colour, and no change chip, since a span has no previous value.
- `Loading, empty and error`: Muted columns on the vertical variants and muted rows on the horizontal one, under the shimmer.
- `Data table and live region`: A screen-reader table with a Low and a High column per range, plus the live region for the active category. The description names the overall low and high.

## Best practices

### When to use

- Use RangeBarChart for spans: temperature or price ranges, planned against actual dates, score bands per team. Use BarChart when the bar length itself is the value.

### Do

- Say what the ends mean in the label, such as Min to max or Planned, because a bare span has no scale to explain itself.
- Use the dots variant when the exact ends matter more than the span, and a plain bar when the length is the point.
- Limit the horizontal variant to two ranges per row, in two colours. Three overlapping spans on one row are hard to read.

### Don't

- Don't mix the cropped axis with zero-based charts on the same dashboard without saying so. A range axis that starts at 40 next to a bar chart from 0 looks like the same scale.
- Don't use it when only a midpoint exists. A single value belongs in LineChart or BarChart.

## API reference

### RangeBarChart

| Prop | Type | Default | Description |
|---|---|---|---|
| data* | readonly ChartDatum[] |  | One object per category / point. |
| index* | string |  | Field holding the category label (x axis; y axis for horizontal bars). |
| activeIndex | number \| null |  | The active point (hovered or focused) as an index into `data`, to control it yourself. `null` shows none. |
| animate | boolean |  | Enter sequence (draw, wipe, grow) on scroll into view, after loading and on new data. Default true; off with reduced motion. |
| animationKey | string \| number |  | Change it to play the enter sequence again (e.g. `useChartReload().version`). New `data` replays it by itself. |
| aspectRatio | number |  | Width ÷ height when `height` is not set. Default 2.6. |
| axisFormatter | ChartValueFormatter |  | Value-axis labels; defaults to `valueFormatter`. |
| categoryAxis | boolean |  | Category-axis labels (default true). |
| categoryFormatter | (label: string) => string |  | Shortens category labels on the axis, e.g. "Mar 12" → "Mar"; tooltip and pill keep the full label. |
| categoryTicks | readonly string[] |  | Only these category labels are shown on the axis (the rest stay hoverable). |
| className | string |  | Extra classes for the root element of the chart. |
| defaultActiveIndex | number \| null |  | The point that is active at first, for an uncontrolled chart. It shows the tooltip without a pointer. |
| defaultSelectedRange | ChartRange \| null |  | The range that is selected at first, for an uncontrolled chart. |
| description | string |  | Screen-reader summary; generated from the data when omitted. |
| emptyDescription | string |  | Text under the title in the empty state. |
| emptyTitle | string |  | Title of the message in the empty state. |
| errorDescription | string |  | Text under the title in the error state. |
| errorTitle | string |  | Title of the message in the error state. |
| grid | boolean |  | Grid lines (default true). |
| gridFade | boolean |  | The grid fades out towards both ends (default true). |
| gridIntervals | number |  | Number of equal grid intervals. Default: one per 44 px of plot height, capped by the size class (xs 2, sm 3, md 3, lg 4, xl 5). |
| gridStyle | "solid" \| "dashed" |  | Grid lines are dashed 4 / 4 by default; `solid` draws them through. |
| height | number |  | Fixed height of the plot frame in px. Without it the height follows the width (`aspectRatio`, `minHeight`, `maxHeight`): 220 px on a phone, up to 434 px (the plot of the Figma large card) from about 1130 px wide. |
| hiddenSeries | readonly string[] |  | Series keys that are switched off (legend toggle): drawn faded, dimmed in the tooltip. |
| includeZero | boolean |  | The value axis starts at 0 (owner rule, default). `false` fits the data (prices, temperatures). |
| label | string |  | Accessible name, e.g. the card title. |
| maxHeight | number |  | Highest height from `aspectRatio`. Default 434. |
| minHeight | number |  | Lowest height from `aspectRatio`. Default 220. |
| onActiveIndexChange | (index: number \| null) => void |  | Called with the index when the pointer or the arrow keys move to another point, and with `null` when they leave. Use it to show the hovered value in a headline. |
| onRetry | () => void |  | Shows a Try again button in the error state and calls this when it is pressed. |
| onSelectedRangeChange | (range: ChartRange \| null) => void |  | Called when a drag across the plot or Shift with an arrow key changes the range, and with `null` when Escape or a click clears it. |
| ranges | readonly RangeBarRange[] | [{ low: "min", high: "max", label: "Range" }] | One or more ranges per category, each from two fields (default: min → max). Without `color` they take the standard order (indigo, pink, …). |
| rangeSelectable | boolean |  | Allow selecting a range by dragging or Shift + arrow keys. On when `onSelectedRangeChange` is set. |
| resolution | "auto" \| "full" |  | `auto` (default): lines and areas draw at most 1.5 points per pixel (LTTB; hover and tooltip keep every point), and bars on a time axis that would get thinner than they may are gathered into weeks, months … `full` draws every point and eve… |
| selectedRange | ChartRange \| null |  | The selected range as inclusive indices `[from, to]` into `data`, to control it yourself. `null` selects nothing. |
| state | "ready" \| "loading" \| "empty" \| "error" |  | `loading` shows the chart-shaped skeleton, `empty` and `error` a message in the plot. |
| tooltip | boolean |  | Tooltip on hover / keyboard focus. Default true. |
| tooltipTitle | (datum: ChartDatum, index: number) => React.ReactNode |  | Title line of the tooltip; defaults to the category label. |
| valueAxis | boolean |  | Value-axis labels (default true). Off for compact cards and sparkline-like plots. |
| valueAxisPlacement | "auto" \| "outside" \| "inside" |  | Where the value labels go: `outside` left of the plot, `inside` in the plot above their grid lines (saves the label column on narrow charts). `auto` (default) puts them left of the plot at every size; `inside` is opt-in. |
| valueAxisSide | "left" \| "right" |  | Side of the value axis (vertical charts). `right` is the price axis of trading charts. |
| valueDomain | readonly [number, number] |  | Fix the value domain instead of fitting it to the data (still rounded to nice steps). |
| valueFormatter | ChartValueFormatter |  | Values in tooltip, labels, table and live region. Default: 42000 → "42k". |
| valueTicks | readonly number[] |  | Exact value-axis ticks (ascending), e.g. [0, 10000, … 70000]; replaces the nice-step domain. |
| variant | "vertical-range-bar" \| "horizontal-range-bar" \| "range-bar-dots" \| "gradient-range-bar" | "vertical-range-bar" | Figma variant. Default `vertical-range-bar`. |
| width | number |  | Fixed width instead of filling and measuring the container. |
| xScale | "band" \| "time" |  | `band` (default): the categories sit side by side in equal bands. `time`: the `index` field holds dates (Date, ms or a string such as "2026-03-01"); points sit at their real distance, the axis picks its tick level (hours → days → weeks → m… |

## Examples

### States

## In context

### Release Plan

Planned against actual weeks per stage.

## For AI agents

`get_component("range-bar-chart")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
