mermaid.flowchart.place.assign

mermaid.flowchart.place

assign(layered, metrics) -> placed

Size a layered flowchart's nodes and place each across the flow

layered is what mermaid.flowchart.order.sweep returns, and is returned with more in it. metrics holds flow, "down" or "right", and in cells pad, group_pad, gap, dummy_gap, node_wrap and edge_wrap.

Each layout node gains span and thick, its sizes across the flow and along it, pos, its first cell across the flow, and port, the offset of its centre port from pos. A real node gains its box's w and h, the label's offset in the box dc and dr, and side_port. A real node and an edge's text gain lines, the wrapped label, and label_cols.

A node with an edge to itself gains loop, { edge, lines, cols }, and a span that holds the loop and its text beside the box.

A border node of a subgraph gains pos alone. All the border nodes of one side of a subgraph share it: the frame's side is one line. A cluster gains title, its subgraph's title on one line, and title_cols, the title's width.

Returns nil and a reason when a subgraph's frame cannot be made a box.

placed.links lists every link between two neighbouring layers: { a, b, a_shift, b_shift, upper_marker, lower_marker, ledge }. A shift is the port's offset from the centre port, at the upper node a and the lower node b. Each edge holds its own links, first layer to last, in links. placed.breadth is the size of the whole across the flow.