Module

DataViz.Layout.Hierarchy.EdgeBundle.Hierarchy

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

DataViz.Layout.Hierarchy.EdgeBundle.Hierarchy

Build a tree hierarchy from flat dot-notation names. This implements the same algorithm as D3's Observable example: names like "flare.animate.Easing" become nested tree nodes.

#buildHierarchy Source

buildHierarchy :: forall a. { getName :: a -> String } -> Array a -> TreeNode a

Build a hierarchy from flat imported nodes Takes an array of nodes with dot-notation names and builds a tree

Algorithm:

  1. For each node, split name by "." to get path components
  2. Create/find intermediate nodes for each path component
  3. Attach leaf data at the final node

#TreeNode Source

data TreeNode a

A node in the hierarchy tree Generic over the leaf data type

Constructors

Instances

#getTreeNodeName Source

getTreeNodeName :: forall a. TreeNode a -> String

Get the short name of a node

#getTreeNodeChildren Source

getTreeNodeChildren :: forall a. TreeNode a -> Array (TreeNode a)

Get children of a node

#getTreeNodeData Source

getTreeNodeData :: forall a. TreeNode a -> Maybe a

Get the user data (if this is a leaf)

#isLeaf Source

isLeaf :: forall a. TreeNode a -> Boolean

Check if a node is a leaf (no children)

#leaves Source

leaves :: forall a. TreeNode a -> Array (TreeNode a)

Get all leaf nodes

#descendants Source

descendants :: forall a. TreeNode a -> Array (TreeNode a)

Get all descendant nodes (pre-order traversal, including self)

#findNode Source

findNode :: forall a. String -> TreeNode a -> Maybe (TreeNode a)

Find a node by its full name

#getFullName Source

getFullName :: forall a. TreeNode a -> String

Get the full name of a node

#getAncestors Source

getAncestors :: forall a. TreeNode a -> TreeNode a -> Array (TreeNode a)

Get all ancestors of a node (from root to node, inclusive) This traverses down from root to find the path

#pathBetween Source

pathBetween :: forall a. TreeNode a -> TreeNode a -> TreeNode a -> Array (TreeNode a)

Find the path between two nodes through their lowest common ancestor Returns: path from source up to LCA, then down to target D3's node.path(target) implementation