Skip to main content

Annotations

warning

Annotations are in alpha and may change. If you have feedback, open a GitHub issue.

An annotation draws a pen mark and a note over a shape or a connection. It never changes the layout. With animation, marks are drawn and erased as steps change.

A write reaches a primary database and is copied to two replicas. Pen marks and captions follow the story: a highlight, two traces, an arrow to the slow replica, a loop round the two copies that have the write, and a cross on the slow connection.
View D2 source

Syntax​

The value is the note, in Markdown. Every key inside is optional.

Marks​

shape picks the mark. Without it, D2 picks one that suits the target.

Circle​

The default for a shape.

A hand-drawn ring round a shape, with a note beside it.
View D2 source

Box​

A hand-drawn frame round a shape, with a note beside it.
View D2 source

Underline​

The default for shape: text. On other shapes it goes under the label.

A scribbled underline beneath a line of text, with a note below it, and another beneath the label inside a shape.
View D2 source

Brace​

The default for a container.

A curly brace under a container, with a note at its point.
View D2 source

Cross​

Two strokes cross out a shape and run past its corners.
View D2 source

Highlight​

A yellow highlighter stroke over a shape's label, with a note beside the shape.
View D2 source

Arrow​

The note goes where there is room. An arrow joins it to the target.

A note stands off from a shape, and a hand-drawn arrow points from the note to the shape.
View D2 source

Lasso​

One loop round every shape that a class or a glob gives it to.

One hand-drawn loop holds three of five shapes. It bends inward to leave out a shape that is not in the class.
View D2 source

Connections​

A connection takes trace, cross, highlight or arrow. trace is the default. highlight runs over the connection's label.

Four connections. One is traced with a translucent stroke, one is crossed out, one has its label highlighted, and one has an arrow pointing at it.
View D2 source

Notes​

Markdown​

A note with bold text and inline code beside a ringed shape.
View D2 source

Position​

near takes top-center, bottom-center, center-left or center-right. Without it, the note goes where it covers the least.

Four ringed shapes, each with its note on a different side: left, above, below and right.
View D2 source

No note​

A frame drawn round a shape, with no note.
View D2 source

Color​

style.stroke is the pen. style.font-color colors the note alone.

A purple ring, a green frame with a green note, and a blue trace with a black note.
View D2 source

Captions​

An annotation on the board is its caption. A link to a shape marks that shape. Put a key that has a space in it in angle brackets: [the balancer](<load balancer>).

A caption under a diagram. The three shapes it names are set in bold in the sentence and ringed in the diagram.
View D2 source

Globs​

A glob with a filter marks every shape that matches.

Two cylinders are each ringed and noted as stateful. The other shapes are not marked.
View D2 source

Steps​

An annotation lasts for one board. A step inherits shapes and connections, not annotations. One that a class or a glob gives a shape holds on every board.

Three boards in turn. Each has one mark and one note, on a different shape each time.
View D2 source

Animation​

With animate-duration, a step's marks are drawn and the previous step's are erased. Each step is held long enough to read its text.

A binary search over ten sorted numbers. A yellow pen rings each middle element in turn and the half that is ruled out dims, until the answer is boxed.
View D2 source

Sketch​

A sketch-mode diagram of DNS resolution with a box round the resolver, a note, and three crossed-out connections above a caption.
View D2 source