TanStack
Examples

Bars and Rankings

Bars answer categorical magnitude questions through length from a shared baseline. Sort them when rank is part of the question, keep a semantic order when sequence matters, and use a lighter comparison mark when a filled bar would overstate the data.

Choose the comparison

Reader questionStart with
Which category has the largest or smallest value?Sorted bars
Which categories have notable endpoints without emphasizing area?Lollipops
How far apart are two values for each category?Dumbbells
How do signed contributions bridge from a start to a total?A waterfall
How do subgroups contribute to each category?Grouped or stacked bars in Stacked and Composed Charts

Use horizontal bars when labels are long or when the rank itself should read top to bottom. Layout, Axes, and Coordinates shows how categorical orientation and automatic guide margins fit together.

Rank categories with bars

Sorting the scale domain makes the intended ranking explicit. Sorting only the input rows is insufficient when several layers or prepared datasets share the same categorical axis.

Bar charts normally include zero on the quantitative domain. Truncating that baseline turns small differences into large apparent changes.

Reduce visual weight with lollipops

A lollipop keeps the common baseline and precise endpoint while replacing the filled rectangle with a thin link. It is useful for many categories or when the endpoint matters more than area.

Compose the stem and endpoint as separate marks. The Rules, Links, Arrows, Vectors, and Ticks reference defines the link channels; Dot and Hexagon Marks defines the endpoint layer.

Compare two values per category

Dumbbells emphasize the distance and direction between two endpoints without implying the combined area of grouped bars.

Label the endpoint semantics in a legend or surrounding text. If chronological order between two periods is the message, a slopegraph may be more direct; if absolute magnitudes must remain independently comparable, use grouped bars.

Explain a bridge to a total

A waterfall requires cumulative preparation. Each contribution becomes an explicit lower and upper interval; the renderer should not guess whether a row is a delta, subtotal, or total.

Keep the cumulative calculation in application data preparation and pass the prepared interval channels to a ranged bar or rectangle. The ownership boundary is described in Scales and D3, and the geometry contracts are in Bar and Rect Marks.

Production checks

  • Preserve a semantic category order unless rank is the question.
  • Include zero for ordinary bar magnitudes; use explicit interval endpoints for floating and waterfall bars.
  • Avoid encoding the same distinction only by color. Labels, position, and shape can carry the essential comparison.
  • Verify long labels and rotated ticks with Responsive Charts.
  • Use stable category keys when values reorder or animate. See Dynamic Data and Animation.