Module

DataViz.Layout.Hierarchy.Placed

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

DataViz.Layout.Hierarchy.Placed

The five hierarchy layouts behind one door: describe the hierarchy once, and get, from any of the layouts, a Map from each node's key to where that layout put it.

Each layout module has its own input type (a Data.Tree of records for Tree and Cluster, Pack.HierarchyData, Partition.HierarchyData, a ValuedNode for Treemap) and its own output tree. That is right for a caller that draws one layout. A caller that wants several layouts of the same data, to compare them or to move between them, would otherwise write a converter in and a flattener out for each.

flare :: Hierarchy Node String
flare = { root, children: _.children, value: _.size, key: _.path }

packed  = Placed.pack (Pack.defaultPackConfig { size = size }) flare
squared = Placed.treemap (Treemap.defaultTreemapConfig { size = size }) flare
-- Map.lookup "flare.vis.Legend" packed :: Maybe Placement

Nothing is computed differently: each function calls the layout module's own function with the configuration given, and reads the result off.

#Hierarchy Source

type Hierarchy node key = { children :: node -> Array node, key :: node -> key, root :: node, value :: node -> Number }

A hierarchy, described by how to walk it. children is empty for a leaf. value is asked of leaves only (an internal node's value is the sum of its leaves'); a hierarchy with no natural sizes can say const 1.0. key must be different for every node.

#Placement Source

type Placement = { depth :: Int, extent :: Extent, height :: Int, leaf :: Boolean, value :: Number, x :: Number, y :: Number }

Where a layout put a node. (x, y) is the node's point for Tree and Cluster, the centre of its circle for Pack, and the centre of its rectangle for Treemap and Partition. depth counts from the root (0), height from the deepest leaf below (0 for a leaf), and value is the sum of the values of the leaves at or below the node. These three are the same in every layout of the same hierarchy.

#Extent Source

data Extent

The room a layout gave a node, beyond a point.

Constructors

Instances

#TreeNode Source

type TreeNode key = { depth :: Int, height :: Int, key :: key, leaf :: Boolean, value :: Number, x :: Number, y :: Number }

The record the Tree and Cluster layouts work on, and so the type their configuration's separation function is given.

#Node Source

newtype Node key

The hierarchy as every layout here is given it: keys, with what is true of a node whatever the layout.

#tree Source

tree :: forall node key. Ord key => TreeConfig (TreeNode key) -> Hierarchy node key -> Map key Placement

DataViz.Layout.Hierarchy.Tree.tree: x across the configured width, y down the configured height by depth.

#cluster Source

cluster :: forall node key. Ord key => ClusterConfig -> Hierarchy node key -> Map key Placement

DataViz.Layout.Hierarchy.Cluster.cluster: as tree, with every leaf at the full height.

#pack Source

pack :: forall node key. Ord key => PackConfig key -> Hierarchy node key -> Map key Placement

DataViz.Layout.Hierarchy.Pack.pack. The configuration's radius function, if any, is given a node's key.

#treemap Source

treemap :: forall node key. Ord key => TreemapConfig (Node key) -> Hierarchy node key -> Map key Placement

DataViz.Layout.Hierarchy.Treemap.treemap.

#partition Source

partition :: forall node key. Ord key => PartitionConfig key -> Hierarchy node key -> Map key Placement

DataViz.Layout.Hierarchy.Partition.partition: x along the configured width by value, y down the configured height by depth. (For a sunburst, read x as an angle and y as a radius.)