Module

DataViz.Layout.Abacus.Types

Package
purescript-hylograph-layout
Repository
afcondon/purescript-hylograph-layout

DataViz.Layout.Abacus.Types

The types of the abacus diagram: a flow drawn with counted units inside each node where a Sankey has ribbons of a width. See DataViz.Layout.Abacus for the layout and its laws.

#kindedBy Source

kindedBy :: forall kind. (LinkCSVRow -> kind) -> Array LinkCSVRow -> Array (AbacusLink kind)

A Sankey's rows, each given a kind.

#ofOneKind Source

ofOneKind :: Array LinkCSVRow -> Array (AbacusLink Unit)

A Sankey's rows where nothing tells one flow from another.

#UnitWorth Source

newtype UnitWorth

What one unit is worth, in the measure of the links' quantities. It is the reader's choice, as a map's scale is; niceWorth gives a default.

Constructors

Instances

#Tally Source

data Tally

Whether units are set in groups, so that many can still be counted. TalliedBy { every, gap }: after every every units, across and down, gap more is left than between two units of one group.

Constructors

Instances

#Composition Source

data Composition

Which kinds a node's units are, and which of them were carried in and which arose in the node, where what comes in and what goes out differ. The node's total is the larger of the two whichever is chosen.

  • IncomingAndArising (the default): what comes in, by kind, at its own amounts, Carried; if more goes out than comes in, the rest is what arises in the node: it is shared among the kinds of what goes out, in their proportions, and is Arising. So a node that nothing comes into (a source) is all Arising.
  • IncomingScaled: the kinds of what comes in, each scaled by total / incoming so that they sum to the total, all Carried; a node that nothing comes into has the kinds of what goes out, Arising.
  • LargerSide: the kinds of whichever side is larger (what comes in, when they are equal): Carried, but Arising where nothing comes in.

Constructors

Instances

#Lanes Source

data Lanes

Whether a wire that passes over one or more columns is given a lane: a place kept for it in each column it passes, between the nodes there, so that it runs through no node and no name. gap is the room a lane takes in a column, top to bottom; the wire runs along its middle.

Constructors

Instances

#LabelRoom Source

type LabelRoom = { above :: Number, below :: Number }

Room kept clear around a node's units for what the caller writes there (a name, a sign): above the first line of units and below the last.

#AbacusConfig Source

type AbacusConfig = { backWireDip :: Number, backWireGap :: Number, composition :: Composition, labelRoom :: LabelRoom, lanes :: Lanes, layerGap :: Number, nodeGap :: Number, nodeMinWidth :: String -> Number, origin :: Point, sankey :: SankeyConfig, tally :: Tally, unitGap :: Number, unitSize :: Number, unitsPerLine :: Int, worth :: UnitWorth }

worth: what one unit is worth. unitsPerLine: how many units to a line before the next line starts. unitSize: a unit's side. unitGap: between one unit and the next, across and down. tally: grouping.

composition: see Composition. lanes: see Lanes.

nodeGap: between one node and the next below it (beyond the label room). layerGap: between the widest node of one column and the left of the next column. labelRoom: see LabelRoom. nodeMinWidth: a node's least width in its column, by name (room for its label); the units keep to the left of it. backWireDip: from the bottom of the lowest node (its label room counted) to the channel of the first wire that turns back, and the most a wire's turns are rounded by. backWireGap: from one such channel to the next.

origin: the top left corner of the picture.

sankey: the Sankey layout that says which column a node is in, the order of the nodes (and of the lanes) down a column, and which links turn back. Its alignment, nodeLayer and nodeSort mean here what they mean there. Its sizes (extent, nodeWidth, nodePadding) reach the abacus only through the order that the Sankey's relaxation settles on.

#defaultAbacusConfig Source

defaultAbacusConfig :: UnitWorth -> AbacusConfig

Ten units to a line, each 4 square and 1 apart, in no groups; kinds by what comes in and what arises; lanes, each 6 deep; columns 20 apart, nodes 12 apart with no room kept for labels; the Sankey's own defaults for a chart 960 by 600.

#Origin Source

data Origin

Whether an amount came into a node (Carried) or first appears in it (Arising): see Composition.

Constructors

Instances

#KindQuantity Source

type KindQuantity kind = { kind :: kind, origin :: Origin, quantity :: Number }

#Throughput Source

type Throughput kind = { byKind :: Array (KindQuantity kind), name :: String, total :: Number }

What passes through a node: total is the larger of what comes in and what goes out, and byKind is the total by kind and origin as the Composition shares it out, the largest first (of equal quantities, kinds in the order the links first name them, and carried before arising). The quantities of byKind sum to total.

#UnitMark Source

data UnitMark kind

What a unit says. Whole: one unit's worth of a kind, carried into the node or arising in it. Part: an amount of that kind which is more than nothing and less than one unit; drawn smaller. Empty: nothing; drawn open.

Constructors

Instances

#AbacusUnit Source

type AbacusUnit kind = { mark :: UnitMark kind, size :: Number, x :: Number, y :: Number }

A unit's place: its top left corner and its side. A Part and an Empty have the same place as a Whole; drawing them smaller or open is the caller's.

#AbacusNode Source

type AbacusNode kind = { layer :: Int, name :: String, returnsToItself :: Boolean, total :: Number, units :: Array (AbacusUnit kind), x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }

A node. Its box (x0, y0, x1, y1) is exactly the box around its units. layer: its column, as the Sankey numbers them. total: see Throughput. returnsToItself: some link of a quantity runs from this node to itself; it is drawn as a mark on the node and has no wire.

#Point Source

type Point = { x :: Number, y :: Number }

#LaneSlot Source

type LaneSlot = { layer :: Int, x0 :: Number, x1 :: Number, y :: Number }

A lane's place in one column: the wire enters at (x0, y), the column's left side, and leaves at (x1, y), its right side.

#WireCourse Source

data WireCourse

How a wire runs. Every wire leaves the right side of its source at from and enters the left side of its target at to, and first runs level to the right side of its source's column.

Onward: from leaves, the right side of its source's column, across to its target, which is in the next column (or, with WithoutLanes, in any later one). Laned: its target is two or more columns on; from leaves it goes through a lane in each column it passes, in order, crossing from one column to the next in the space between them. TurningBack: it closes a cycle (the Sankey set it aside as a back-edge); it goes down at down, in the space after its source's column, back along a channel at under, below every node, and up at up, in the space before its target's column. turn: how far its four turns are rounded.

Constructors

Instances

#WireSegment Source

data WireSegment

A piece of a wire's line: straight from one point to another, or a cubic curve from the first point to the last by two control points.

Constructors

Instances

#AbacusWire Source

type AbacusWire kind = { course :: WireCourse, from :: Point, kind :: kind, links :: Array Int, source :: String, target :: String, to :: Point }

A wire says only that two nodes are joined, and which way: there is one for each pair of different nodes that links of a quantity join in one direction, however many such links there are. links: their places in the input. kind: the kind of the largest of them. from, to: its two ends.

#turnsBack Source

turnsBack :: forall kind. AbacusWire kind -> Boolean

#Extent Source

type Extent = { x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }

#AbacusLayout Source

type AbacusLayout kind = { extent :: Extent, nodes :: Array (AbacusNode kind), wires :: Array (AbacusWire kind), worth :: UnitWorth }

nodes: in the order of the Sankey's own nodes for the same rows, so that what is given by a node's place there (a colour, say) is the same in both pictures. wires: in the order the links first join each pair. worth: what a unit is worth, to be said beside the picture. extent: the box around everything, label room, lanes and the wires that turn back included; such a wire may run to the left of origin or to the right of the last column.