Skip to content

Layouts & Collapsing

Tree, radial and force layouts beside the layered and grid ones, applied with LayoutAsync to the whole graph or - with nodes selected - to the selection alone, each run one undo step. The Services group folds away with SetCollapsedAsync: its children hide, and the edges that ran into them are drawn to the group instead.

Layouts arrange the whole graph; select some nodes to arrange just those
Pick a layout to arrange the graph and tune it here.
Web app
Mobile app
API gateway
Services
Database
Queue
Orders
Billing
Stock
Mail
Arrow keys move the view, plus and minus zoom, Home shows the whole flow.
bit Blow

Try it

  • Press Layered, Tree, Radial, Force or Grid to arrange the graph; the Services group is placed as one block, by what its children connect to.
  • On the second row of the toolbar, tune the chosen layout and let go of a slider to apply it: the tree's Direction and gaps, the radial layout's Ring gap, Start angle and Node gap, the force layout's Edge length and Iterations (0 leaves the nodes on the spiral they start from).
  • Move a few nodes, tick Start from where they are and press Force again: it tidies your arrangement instead of replacing it. Tick Pin the API gateway and the gateway stays put while the rest settle around it.
  • Shift+drag a box round two or more nodes (or Shift+click them) and press a layout: only the selection is arranged, where it stands. Select children inside the group to arrange them among themselves.
  • Press Collapse group, or double-click the group: its four children disappear, the edges into them now end on the group, and its border turns dashed. Press Expand group to bring them back.
  • Press Undo to step back through layouts and collapses, one at a time; the button names what it will undo.

How it works

  • LayoutAsync(layout, nodes) arranges nodes on the canvas with any IBlowLayout. Given no nodes it takes the selection when there is one, else every top-level node; only nodes sharing one parent are arranged together, and hidden ones stay put.
  • The arrangement keeps its top-left corner where the nodes' was, so a selection is tidied in place. An edge into a group's child counts as an edge into the group, and the canvas's NodeOrigin is handed to the layout for you.
  • Every built-in options class is an IBlowLayout: BlowTreeLayoutOptions (Direction, LevelGap 60, NodeGap 30), BlowRadialLayoutOptions (RingGap 60, StartAngle 0 degrees clockwise from twelve o'clock, NodeGap 20), BlowForceLayoutOptions, BlowLayeredLayoutOptions and BlowGridLayoutOptions.
  • Radial's IsRoot chooses the roots; left null it takes the nodes nothing leads to. One root goes in the centre and several share the first ring - here Web app and Mobile app share it round an empty centre.
  • BlowForceLayoutOptions: IdealEdgeLength (180) is how far apart connected nodes settle, Iterations (300) the simulation steps, StartFromCurrentPositions (off) starts from the current positions instead of a spiral, and IsPinned names nodes that must not move - with any pinned, the result stays where the pins hold it. Theta (0.9) only matters past 500 nodes, where far-off groups push as one, so it has nothing to do on this page.
  • HistoryEnabled records each layout as one undo step labelled "layout"; OnHistoryChanged hands the page a BlowHistoryState for the Undo button, and UndoAsync() steps back.
  • SetCollapsedAsync(node) toggles a node with children: it sets Collapsed, hides everything nested in it and redraws edges from outside to the node itself. One undo step either way, and the node gets the collapsed class, which this page styles with a dashed border. OnNodeDoubleClick calls it for the group.
  • OnSelectionChange counts the selected nodes for the hint, and UpdateNodeInternals() re-measures the handles after a layout turns them to face its direction.
An unhandled error has occurred. Reload 🗙