The last step of a flowchart's layout: the layers' places along the flow, and each edge's route. It turns a placed graph into a frame.
The step is written as for a flow that runs down, and names its two directions so: a link has an upper and a lower end, a column and a row. With the flow to the right a column here is a row of the frame.
Between two layers lies a channel. A link whose two ports share a column runs straight down it. Any other link runs down from its upper port, along a row of the channel, and down to its lower port. That row is a track.
The links that leave one port are a net and share a track, as one trunk with a branch to each target. Nets get tracks by the left-edge rule: a net takes the first track where it overlaps no net already there.
One rule keeps two edges from reading as one. Where a net's trunk comes down a column and another net arrives at a port in that same column, the trunk's net takes the higher track. The trunk has then left the column before the other net enters it. Two nets that each want the higher track cannot both have it. One link of the pair then stops a column short of its port and steps over on a lower track of its own, a dogleg.
When no dogleg is left to give, the nets take tracks without that rule. Two lines may then cross, and a reader may take the crossing for a join.
| Name | Signature |
|---|---|
| frame | frame(placed, metrics) -> frame |
frame(
placed,metrics) ->frame
Turn a placed flowchart into a frame
placed is what mermaid.flowchart.place.assign returns. metrics
holds flow, "down" or "right", and flip, true when the diagram
runs against that: up, or to the left. In cells it holds lead, the
cells between a box and the first track after it, tail, the cells
between the last track and a box, pitch, the cells a track takes, and
group_pad, the cells between a subgraph's frame and a box in it.
The frame holds a box and its label's texts for each node, a knockout
text for each edge's text, a route for each edge, and a group with its
title for each subgraph that holds a node. A route runs from
the edge's from to its to, whichever way it was laid out, so a marker
names the end the source gave it.
A layer and a channel are laid along the flow, and a track runs across it. The frame's cells come last: a place across the flow and one along it become a column and a row by the diagram's direction. A box, a label and a marker are placed after that, so none is ever turned or mirrored.
A channel after a box starts with lead cells, and a channel before a
box ends with tail, where the arrowheads stand. A link with a marker
at its upper end has one lead cell at least: the marker needs a straight
cell beside its port. A link with a marker at each end has two.