Module

Hylograph.Flow.Render.Columns

Package
purescript-hylograph-flow-render
Repository
afcondon/purescript-hylograph-flow-render

The columns engine (0.4): nodes as big as the caller says, in columns by layer, with ribbons from port to port. Pure, so it runs in node.

WHY A SECOND ENGINE OF ITS OWN, AND NOT THE SANKEY ENGINE TAUGHT PORTS. The Sankey layout's whole method is that a node is as tall as what passes through it, and that a node's edges stack along its side by where they go. A table drawn with its rows is the opposite case on both counts: it is as tall as its rows, which only the caller knows, and an edge belongs beside the row it governs, which only the caller knows. A table does not conserve width either (240 rows in, one total out). So the Sankey engine keeps its promises and this engine makes others: it keeps the sizes and ports the picture fixes (Picture.fixed), and draws every edge as a ribbon at one stated scale, with a least breadth so that a single unit still shows.

WHAT IT DOES.

  • Layers. The core's layers (longest path from a node nothing enters), and then a node nothing enters is moved as late as it can go: to the layer before the first of the nodes it feeds. A parameter then stands beside the table it feeds, not in the first column with every other source.
  • Columns. One column for each layer, as wide as its widest node, the columns layerGap apart; a node is centred in its column, so the nodes of one layer have their middles in one line (LayersAligned).
  • Down the page. Each node is pulled towards the places of the nodes at the other ends of its edges, each edge weighing as much as it is broad, and measured from where the edge meets the node (its port where the port is placed, else the middle of the side): a sweep with the flow (by what enters a node) and one against it (by what leaves), passes times. After each pull a column is put in the order its nodes want, pushed apart to nodeGap, and moved as a whole by the mean of what the push cost, so that it does not creep down the page.
  • No deeper than deepest. A table drawn with every row is some thousands of pixels tall, and a small node that feeds its middle is pulled level with that middle, a long way under the first screenful. Where the spacing says deepest: Just limit, no node begins more than limit under the top of the picture, unless the nodes above it in its own column leave it no room: after the pulling, each column is taken from the top down, and a node below the limit is raised to it or to nodeGap under the node above, whichever is lower. The order of a column's nodes is kept. The ribbon then runs down to the row it governs. Nothing (the default) raises nothing.
  • Routes. A ribbon from where an edge leaves its source to where it enters its target: at a placed port where the edge names one the node has placed, and otherwise stacked on the node's right side (leaving) or left (entering), centred on the side's middle, in the order of the other ends down the page. One cubic piece, level at both ends. An edge into a layer no later than its source's is turned back (Backward) and loops out and back by a layer's gap.

WHAT IT PROMISES, AND WHAT IT DOES NOT. FlowsForward, LayersAligned, KeepsFixed and WidthsScaled at the scaling it is made with. Not WidthsConserved: a node is not as tall as what passes through it. Not RoutesOrthogonal: its routes are curves. It draws no outlines: told of open groups it outlines none, and the general law Outlined says so. Ribbons that meet one port, or that are stacked at a side, stand beside one another; ribbons that meet different ports stand where the caller put the ports, and whether those overlap is the caller's to say.

#Spacing Source

type Spacing = { deepest :: Maybe Number, layerGap :: Number, margin :: Number, nodeGap :: Number, nodeHeight :: Number, nodeWidth :: Number, passes :: Int }

layerGap: between one column and the next. nodeGap: between two nodes of a column. margin: round the picture. nodeWidth, nodeHeight: the size of a node the picture does not fix (taller where its words need it). passes: how many times the nodes are pulled down the page, each time with the flow and against it. deepest: how far under the top of the picture a node may begin, where its column has room (the header says how); Nothing for as far as it is pulled.

#defaultSpacing Source

#columns Source

columns :: forall wire. Spacing -> Scaling wire -> Engine wire

The columns engine at a spacing and a scaling of widths.