bar

barNode

Rectangles standing on one axis at the names of the other: bar(x: North, South; y: 42, 31) rules the x axis in those names and stands a bar at each. A series mark like scatterx and y are read the same way and paired by position — and it is the categorical axis (x-format/y-format, or the auto rule) that makes it a bar chart. Exactly one axis must be categorical; the other is the value axis, which always reaches the baseline. Which axis is which is the orientation. Several bars at one name split the band in source order; stack stands a bar on the one before it. Not a histogram: a histogram’s width is data (its bins are edges), a bar’s is a share of a band.

#Attributes

xRequiredImplicitAnimatable
The readings’ x values: names, numbers, or a dataset column (#sales.region). Paired with y by position; a pair either axis cannot read is dropped whole.Can be written as shorthand: bar:value
yRequiredAnimatable
The readings’ y values, paired with x by position.
period
Also written: atLong-format data: one row per name per period, this naming the period column (period: #sales.year). The bars then show the slice at whatever the environment's parameter.time holds, gliding between the two periods that bracket it. Periods may be years, ISO dates, month or weekday names, HH:MM hours or YYYY-Www weeks.
coloursAnimatable
Also written: colors, colour, colorColour for each bar, cycled in order — one colour colours the lot. If fewer colours than bars are given, the list starts again from the first.
Defaultblue
opacityAnimatable
Opacity.
Default1
widthAnimatable
The share of the band at each name that the bars fill, 0–1. Several bars at one name divide it between them.
Default0.8
stack
Also written: stackedStand on top of the bar written before this one, in its share of the band, instead of beside it.
Defaultfalse
show-labelsAnimatable
Also written: labelsWrite each bar’s value at its end.
Defaultfalse
Text drawn beside the element — rich text, so $maths$ and inline formatting render. Fades and draws with the element.
hiddenAnimatable
Declared but not drawn. Animatable — hidden: true !cue.to{false}(at: 2) reveals it — and unlike a cue, a hidden element still frames the plot, so the axes do not jump when it appears.
Defaultfalse
Also written: lockedKeeps the reader from editing this element on an editable: graph. Nothing at all on a graph that is not editable.
Defaultfalse
text-sizeAnimatable
Text size.
Default20
Stacking order. Higher z renders on top; when omitted or equal, elements stack in document order (later on top).

#Allowed in