<t-flow>

Live elements laid out as a graph of what feeds what. Each child is a node. An arrow runs from one node to another when the second reads a variable the first defines, so the arrows come from the page itself.

Range noise ± 4 m

95% within m

Nobody wrote down the arrows. The code cell (folded, open it with its arrow) reads the beacons, your position and the noise, and the chart and the sentence read its fixes. The spec only adds captions, widths and the fold.

Nodes and ids

Every child element is a node, apart from <script>, <style> and the elements that show nothing (<t-var>, <t-let>, <t-fetch>). A node can be anything: a paragraph, a chart, a code cell, or a whole <div> of them. Even another <t-flow> works as a single node.

The spec names a node by its id. That's its id attribute if it has one. Otherwise it's the one variable it defines, so above the paragraph with <t-num name="noise"> is noise, and the <div> with eight <t-var>s needs id="map". Failing both, it's n0, n1, … by position.

Arrows

An arrow runs from A to B when something in B reads a variable that something in A defines. It also looks through formulas that no node defines, so a <t-let> between the two still links them. When a longer path already connects two nodes, the direct arrow between them is left out. edgeLabels: true writes the variables each arrow carries next to it:

Length 1 m

Gravity 9.8 m/s²

Period

Frequency

edges changes the arrows. An entry for an arrow that's already there restyles it, and any other entry adds one:

EntryDoes
["a", "b"]Adds an arrow from a to b.
["a", "b", "label"]Adds one with a label, or labels the one that's there.
["a", "b", { … }]Adds or restyles one: label, color, dashed, exit, enter.
["a", "b", false]Drops the inferred arrow.

infer: false turns inference off, and then only the arrows in edges are drawn. If the arrows go round in a circle, an error says which nodes are involved, and you can break the circle with false.

Ports

An arrow leaves the far side of a node and lands on the near side of the next one, spread out with the arrows that share that side. exit and enter pick the sides yourself: "top", "bottom", "left" or "right", or a side and a position along it from 0 to 1, like ["right", 0.25]. An arrow with ports is routed around the other nodes.

Layout

Nodes sit in rows, one below the deepest node that feeds them. direction: "right" lays the rows out as columns, left to right. A few keys move nodes around:

Mass 2 kg

Spring 50 N/m

ω =

Amplitude 0.1 m

top speed

Captions, notes and widths

label puts a caption under a node. note puts text beside it with a short arrow, and the text can have bold and $math$. width sets how wide the node is, in pixels or any CSS length. Charts and code cells take whatever width they get, so give them one.

Folding

fold: true gives a node a small button in its corner, which shows when you hover over it. The button folds the node into a pill with just its caption, and the rest of the diagram moves up to fill the gap. fold: "closed" starts it folded.

groups draws a dashed frame around several nodes, with a tab that folds them all into one pill. Arrows in and out of the group land on the pill. A group has to include every node on a path between two of its own nodes, since the pill replaces all of them.

Length 1 m

Gravity 9.8 m/s²

Period

Frequency

From JavaScript

el.edges lists the arrows as [from, to] pairs of node ids. el.upstream(id) and el.downstream(id) list the nodes that feed id and that id feeds, directly or not.

Spec keys

The spec goes in a <script type="text/plain"> inside the element. It's one JavaScript expression, written like JSON, and every key is optional.

KeyDescription
direction"down" (the default) or "right".
align"center" (the default), "left" or "right"; going right, "top" or "bottom". See Layout.
nodesOptions per node, by id: label, note, width, fold, row, beside. A string is short for { label }.
edgesArrows to add, restyle or drop. See Arrows.
groupsA list of { label, nodes, collapsed }. See Folding.
inferfalse draws only the arrows in edges.
edgeLabelstrue labels the inferred arrows with the variables they carry.

The look comes from custom properties on .tangle-flow: --tangle-flow-edge (the arrows), --tangle-flow-note, --tangle-flow-bg (behind crossings and pills), --tangle-flow-layer-gap and --tangle-flow-node-gap.