Bar

Bar charts compare values across categories, with one bar per item or several side by side or stacked.

LLMs

Basic

Pass barY the rows and the x and y fields to draw one bar per month, with rounded tops from radius.

Multiple series

Set z and color to a series field and layout to group() to place each month's series side by side.

Stacked

Set layout to stack() to pile the series into one bar per month, rounding only the end of the top segment.

Horizontal

Use barX with the band scale on y to lay the bars out sideways, with the category labels on the left.

Value labels

Add a text mark on the same x and y and lift it with dy to print each bar's value above it.

Labels inside bars

Anchor one text mark at zero for the name inside the bar and another at the bar's end for its value.

Colored by category

Set color to the category field to give every bar its own color from the theme palette.

Highlighted bar

Pass functions to fill, stroke and strokeDasharray to draw one bar with a dashed outline and a lighter fill.

Negative values

Return a color from fill by sign to paint gains and losses, with labels above or below each bar through dy.

Series toggle

Rebuild the definition when a Segmented changes, to switch three months of daily bars between desktop and mobile.

Sorted

Pass rows already sorted by value to keep the band scale in that order, with the most frequent letter first.

Grouped counts

Count fetched rows with groupBy, then place female and male counts side by side with group() for each species.

Stacked over time

Unpivot three cause columns with fold, then stack() them on a time scale to show monthly totals by cause.

Horizontal ranking

Sort the rows and draw them with barX to rank metro areas by population while keeping long labels readable.

Mean by group

Reduce raw rows to one mean per species with groupBy and a mean output, then label each bar with its value.

Stacked and grouped

Give group() two slots and use y1 and y2 to stack two measures in one slot beside a third bar each day.

Pyramid

Negate one group and pass stack({ offset: "diverging" }) to grow the two sides away from a shared zero line.

Lollipop

Combine a link stem from zero with a dot at the value to draw a lighter bar chart that marks each endpoint.

Dumbbell

Join two dot marks with a link on each row to compare a 1980 value with its 2015 value for every city.

Waterfall

Turn yearly prices into changes with rollingWindow, then let waterfall stack them into floating bars and a net total.

Funnel

Draw each stage as an areaX band from its own width to the next stage's width, with a label beside the funnel.

Active bar

Use states to dim the other bars on focus and a crosshair band to ring the active one, switching between iOS and Android from a Segmented.