Vega-Lite Sorted Bar with Labels

A horizontal bar chart with bars sorted descending by value and per-bar value labels rendered as a layered text mark — the canonical 'top N' ranking visual that any newsroom or product analytics page needs. The Vega-Lite spec is just two layered marks (bar + text) with `sort: '-x

Template details

  • chart
  • bar
  • sorted
  • labels
  • vega
  • vega-lite

When to use this template

This visualization makes it immediately obvious which items rank highest or lowest within a single category based on a specific quantitative measure. An analyst would reach for it to quickly identify top performers, compare magnitudes across a set of discrete items, and understand their relative order without needing to scan a table.

  • Datasets with one categorical dimension and one quantitative dimension.
  • Categorical dimensions with low to medium cardinality (e.g., 5-50 distinct items).
  • Quantitative values that allow for clear sorting and magnitude comparison.
  • When the primary goal is to rank items by a single metric.
  • Data where precise values for each category are important to display.
  • Comparing magnitudes across distinct, independent categories.

Browse all Koan templates