Skip to content

Plot

<Plot name={names} value={values} order={sortBy("value", "desc")}>
  {Slat}
</Plot>

A Plot’s child is the slat: a function of d that returns one DOM root, often made with slat(). A Plot adds no row wrapper of its own. For single-block roots in overlap Plots, see a slat’s element.

A Plot is a stack of slats and a Chart is the frame around it, which is not the everyday sense of the two words: see Chart and Plot are two different components.

Data

Every prop that isn’t a setting below is data, read in the slat as d.<prop>:

  • a list gives item i to slat i, and the longest list sets the number of slats,
  • a single value is shared by every slat,
  • a function of d is worked out per slat, and again when what it reads changes.

d.index is the row’s place in the data (from 0), and d.position the slat’s place on screen.

Settings

PropDefaultWhat it does
rowsa list of objects: each field becomes d.<field>. A prop with the same name wins.
keya field name or a function of d that names each row, so a slat follows its row when rows are added or removed
orderdata ordera list of positions (null hides a row), or a function such as sortBy("value")
reorder"slide"how slats change places: "slide", "move" (the slats move in the page) or "refill" (slats swap contents)
overlapfalseevery slat shares one band instead of stacking: stacked bars, layers, strips of dots
orientationthe Chart’s"horizontal", "vertical", or "across" (the other way from the Plot around it)
slatsa fixed number of slats, instead of the longest list
animatethe Chart’strue, a list of data names that move (["value"]), or { groups, duration, ease, slide }
thick1inside a slat: the share of the slat’s band the Plot uses, such as 0.5
staticthe Chart’sdraw the slats once (see the Chart’s static); lets one Plot be still while another one moves
keyboardoffthe slats take focus: Tab stops at one slat, and the arrow keys, Home and End go through them in the order shown. See keyboard.
class, style, refthe Plot’s element

In a slat

A Plot inside a slat draws in that slat’s band, on the same scale: see charts inside slats.