# Bar list

> Show a ranked list of labelled values as compact rows with inline bars, grouped, limited and sized to fit a card or a dense layout.

A bar list is a ranked list where each row is a label, a thin proportional bar and its value. It has no axes, so it takes less room than a [bar chart](/docs/comparison/bar/) and fits cards and dashboards. It is its own spec type, `type: "barlist"`, with `label` and `value` channels instead of `x` and `y`.

Use a bar chart instead when the reader needs an axis to read values against.

## A basic bar list

Set `type` to `"barlist"` and map `label` and `value`. The list sorts descending by default. `format` on the value channel is a d3-format string, and `color` colors each row by a category.

```json
{
  "type": "barlist",
  "data": [
    {
      "language": "Python",
      "pct": 23.4,
      "category": "general"
    },
    {
      "language": "Java",
      "pct": 17.1,
      "category": "general"
    },
    {
      "language": "JavaScript",
      "pct": 14.9,
      "category": "web"
    },
    {
      "language": "C/C++",
      "pct": 11.2,
      "category": "systems"
    },
    {
      "language": "C#",
      "pct": 8.6,
      "category": "general"
    },
    {
      "language": "Go",
      "pct": 5.8,
      "category": "systems"
    },
    {
      "language": "TypeScript",
      "pct": 5.3,
      "category": "web"
    },
    {
      "language": "Rust",
      "pct": 4.1,
      "category": "systems"
    },
    {
      "language": "PHP",
      "pct": 3.7,
      "category": "web"
    },
    {
      "language": "Swift",
      "pct": 2.6,
      "category": "mobile"
    },
    {
      "language": "Kotlin",
      "pct": 2.1,
      "category": "mobile"
    },
    {
      "language": "Ruby",
      "pct": 1.2,
      "category": "web"
    }
  ],
  "encoding": {
    "label": {
      "field": "language",
      "type": "nominal"
    },
    "value": {
      "field": "pct",
      "type": "quantitative",
      "format": ".1f"
    },
    "color": {
      "field": "category",
      "type": "nominal"
    }
  },
  "chrome": {
    "title": "Python has the largest share of the index",
    "subtitle": "Programming-language popularity index, % share, 2025"
  }
}
```

## Grouped rows

`encoding.group` adds a header for each group, in the order the groups first appear in the data. The rows inside each group are sorted, so the order across the whole list follows the group order, not the values.

```json
{
  "type": "barlist",
  "data": [
    {
      "language": "Python",
      "pct": 23.4,
      "category": "general"
    },
    {
      "language": "Java",
      "pct": 17.1,
      "category": "general"
    },
    {
      "language": "JavaScript",
      "pct": 14.9,
      "category": "web"
    },
    {
      "language": "C/C++",
      "pct": 11.2,
      "category": "systems"
    },
    {
      "language": "C#",
      "pct": 8.6,
      "category": "general"
    },
    {
      "language": "Go",
      "pct": 5.8,
      "category": "systems"
    },
    {
      "language": "TypeScript",
      "pct": 5.3,
      "category": "web"
    },
    {
      "language": "Rust",
      "pct": 4.1,
      "category": "systems"
    },
    {
      "language": "PHP",
      "pct": 3.7,
      "category": "web"
    },
    {
      "language": "Swift",
      "pct": 2.6,
      "category": "mobile"
    },
    {
      "language": "Kotlin",
      "pct": 2.1,
      "category": "mobile"
    },
    {
      "language": "Ruby",
      "pct": 1.2,
      "category": "web"
    }
  ],
  "encoding": {
    "group": {
      "field": "category",
      "type": "nominal"
    },
    "label": {
      "field": "language",
      "type": "nominal"
    },
    "value": {
      "field": "pct",
      "type": "quantitative",
      "format": ".1f"
    }
  },
  "chrome": {
    "title": "Python, JavaScript, C/C++ and Swift lead their categories",
    "subtitle": "Programming-language popularity index by category, % share, 2025"
  }
}
```

## A compact list

`maxItems` limits how many rows show, `barHeight` sets the bar thickness in pixels and `cornerRadius` rounds its ends. This one shows six rows with 8px bars and a one-line title, a form that suits a dashboard tile.

```json
{
  "type": "barlist",
  "data": [
    {
      "language": "Python",
      "pct": 23.4,
      "category": "general"
    },
    {
      "language": "Java",
      "pct": 17.1,
      "category": "general"
    },
    {
      "language": "JavaScript",
      "pct": 14.9,
      "category": "web"
    },
    {
      "language": "C/C++",
      "pct": 11.2,
      "category": "systems"
    },
    {
      "language": "C#",
      "pct": 8.6,
      "category": "general"
    },
    {
      "language": "Go",
      "pct": 5.8,
      "category": "systems"
    },
    {
      "language": "TypeScript",
      "pct": 5.3,
      "category": "web"
    },
    {
      "language": "Rust",
      "pct": 4.1,
      "category": "systems"
    },
    {
      "language": "PHP",
      "pct": 3.7,
      "category": "web"
    },
    {
      "language": "Swift",
      "pct": 2.6,
      "category": "mobile"
    },
    {
      "language": "Kotlin",
      "pct": 2.1,
      "category": "mobile"
    },
    {
      "language": "Ruby",
      "pct": 1.2,
      "category": "web"
    }
  ],
  "encoding": {
    "label": {
      "field": "language",
      "type": "nominal"
    },
    "value": {
      "field": "pct",
      "type": "quantitative",
      "format": ".1f"
    }
  },
  "maxItems": 6,
  "barHeight": 8,
  "cornerRadius": 2,
  "chrome": {
    "title": "Top six languages"
  }
}
```

## Reference line and label format

`annotations` takes vertical `refline` entries in value units. `labels` formats the printed value with `format`, `prefix` and `suffix`; here it adds a percent sign. The reference line marks the rows that pass a threshold.

```json
{
  "type": "barlist",
  "data": [
    {
      "language": "Python",
      "pct": 23.4,
      "category": "general"
    },
    {
      "language": "Java",
      "pct": 17.1,
      "category": "general"
    },
    {
      "language": "JavaScript",
      "pct": 14.9,
      "category": "web"
    },
    {
      "language": "C/C++",
      "pct": 11.2,
      "category": "systems"
    },
    {
      "language": "C#",
      "pct": 8.6,
      "category": "general"
    },
    {
      "language": "Go",
      "pct": 5.8,
      "category": "systems"
    },
    {
      "language": "TypeScript",
      "pct": 5.3,
      "category": "web"
    },
    {
      "language": "Rust",
      "pct": 4.1,
      "category": "systems"
    },
    {
      "language": "PHP",
      "pct": 3.7,
      "category": "web"
    },
    {
      "language": "Swift",
      "pct": 2.6,
      "category": "mobile"
    },
    {
      "language": "Kotlin",
      "pct": 2.1,
      "category": "mobile"
    },
    {
      "language": "Ruby",
      "pct": 1.2,
      "category": "web"
    }
  ],
  "encoding": {
    "label": {
      "field": "language",
      "type": "nominal"
    },
    "value": {
      "field": "pct",
      "type": "quantitative"
    }
  },
  "labels": {
    "format": ".1f",
    "suffix": "%"
  },
  "annotations": [
    {
      "type": "refline",
      "x": 10,
      "label": "10% share",
      "style": "dashed"
    }
  ],
  "chrome": {
    "title": "Four languages hold more than a tenth of the index each",
    "subtitle": "Programming-language popularity index, % share, 2025"
  }
}
```

## Fields that matter

| Field | What it does |
| --- | --- |
| `type: "barlist"` | Selects the bar list spec. |
| `encoding.label` | The row name. Required, `type: "nominal"`. |
| `encoding.value` | The number that sets bar length. Required, `type: "quantitative"`, with `format` for the printed value. |
| `encoding.color` | Colors rows by a category field. |
| `encoding.group` | Starts a new header for each distinct value. |
| `sort` | `"descending"` by default, `"ascending"`, or `null` to keep the input order. |
| `maxItems` | The most rows to show. The default is 20. |
| `barHeight`, `cornerRadius` | Bar thickness in pixels, and corner rounding in pixels or `"pill"`. |
| `annotations`, `labels` | Value reference lines, and `format`, `prefix` and `suffix` for the printed value. |

## Related

- [Bar](/docs/comparison/bar/) for a chart with axes.
- [Dashboard tiles](/docs/composition/dashboard-tiles/) for the compact forms around a bar list.
- [Data table](/docs/tables/data-table/) when each row needs more than one value.
- [BarListSpec reference](/docs/spec/barlist-spec/) lists every bar list field.
