mermaid.sequence.layout

index · mermaid.sequence

Overview

The sequence diagram layout: a script in, a frame out.

A sequence diagram needs no graph layout. Its participants stand in a row in the order the script gives, each with a lifeline down from its box. Its events follow down the page in the order the script gives, each taking the rows it needs.

So the columns come from one pass, left to right: a lifeline stands as far from each lifeline before it as the widest thing between the two asks. The rows come from one pass over the events.

A lifeline is not one line. A note over a participant takes the cells its lifeline would run through, so the lifeline is drawn in pieces, each ending on the note's border.

Functions

NameSignature
frameframe(script, metrics) -> frame

frame(script, metrics) -> frame

Lay a sequence diagram's script out into a frame

script is what mermaid.sequence.parser.parse returns. metrics holds, in cells, pad, the blank columns each side of a participant's name, gap, the least blank between two participants' boxes, and text_wrap and note_wrap, the columns a message's text and a note's text wrap at.

The frame holds:

ElementDrawn as
a participanta box of style actor, round for an actor, with texts of style actor.label
a lifelineroutes of style lifeline, from the box down, broken where a note lies over them
a messagea route of style edge between two lifelines on one row, and knockout texts of style message.label on the rows above it
a message to oneselfa route that loops off the lifeline's right, with its text beside it
an activationa box of shape bar and style activation on the lifeline
a notea box of style note with texts of style note.label
a blocka group of style group, its tag and text on the top side, and a dotted divider for each else, and or option

A rect block draws no group. A numbered script puts each message's number before its text.