Hylograph.Flow.Render.Layout
- Package
- purescript-hylograph-flow-render
- Repository
- afcondon/purescript-hylograph-flow-render
Where a projection's nodes and edges go. Pure, so it runs in node.
One layout serves both pictures. Every edge has a width, in units; a
node is as tall as the wider of what enters it and what leaves it, and
its edges stack along its sides. A Sankey takes the widths from the
wires' payloads and draws each edge as wide as it is. A plain DAG gives
every edge one unit and draws each as a hairline down the middle of its
place. The positions come from the same code either way: the Sankey
layout in hylograph-layout, with its lanes for edges that span more
than one layer. The flow runs left to right.
That layout does all of the placing (DataViz.Layout.Sankey.Whole): the
scale is fixed (unit pixels to one unit of width, the layers a fixed
distance apart) and the picture is as large as that makes it; a node no
edge touches stands on a shelf under the picture; and an edge that
closes a cycle, an edge from a node to itself among them, leaves its
source below the edges that go forward, runs back under the picture in a
channel of its own, and enters its target likewise. What is left here is
the translation: from a projection to rows and names, and from the
layout's boxes and routes to placed nodes and centre lines, set in from
the left by a margin with room for an edge to turn.
#Widths Source
data Widths wireHow wide an edge is. Plain: every edge one unit, drawn as a hairline.
Sankey: the caller reads the width from the edge, which carries what
its wires carry (wires: one for a wire, more where the edge crosses
undrawn elements, and which of them is the quantity is the domain's to
say). A width that is not a positive number is drawn as nothing.
Constructors
#Metrics Source
type Metrics = { hairline :: Number, layerGap :: Number, nodeBreadth :: Number, nodeGap :: Number, restHeight :: Number, unit :: Number }unit: pixels to one unit of width. hairline: the stroke of a plain
edge. nodeBreadth: a node's extent along the flow. layerGap: between
one layer and the next. nodeGap: between two nodes of a layer.
restHeight: how tall a node is that no edge gives a height.
#PlacedEdge Source
type PlacedEdge wire = { course :: Course, edge :: Edge wire, end :: Point, index :: Int, path :: String, start :: Point, stroke :: Number, width :: Number }index: the edge's place in the projection. width: the room it takes
on the side of each node it touches, in pixels. stroke: how wide it is
drawn, along path, which runs from start to end.
#Layout Source
type Layout wire = { edges :: Array (PlacedEdge wire), height :: Number, nodes :: Array PlacedNode, width :: Number }Nodes and edges in the projection's order. An edge with an end that is
no node of the projection has no place and is left out (project makes
none).