DataViz.Layout.Hierarchy.Core
- Package
- purescript-hylograph-layout
- Repository
- afcondon/purescript-hylograph-layout
DataViz.Layout.Hierarchy.Core
Pure PureScript implementation of D3 hierarchy core functions. Matches D3's algorithms exactly but using pure functional style.
#hierarchy Source
hierarchy :: forall a. a -> (a -> Maybe (Array a)) -> HierarchyNode aConstruct a hierarchy from user data Matches D3's hierarchy() function
Simplified implementation using recursion instead of D3's iterative approach This is more idiomatic for PureScript while producing identical results
#getHeight Source
getHeight :: forall a. HierarchyNode a -> Int#sum Source
sum :: forall a. HierarchyNode a -> (a -> Number) -> ValuedNode aCompute aggregate values bottom-up Matches D3's .sum() method
Formula: node.value = value(node.data) + Σ(child.value)
#count Source
count :: forall a. HierarchyNode a -> ValuedNode aCount descendants Matches D3's .count() method
Formula:
- Leaf: value = 1
- Internal: value = Σ(child.value)
#eachBefore Source
eachBefore :: forall a b. (HierarchyNode a -> b) -> HierarchyNode a -> Array bPre-order traversal (visit parent before children) Matches D3's .eachBefore() method
Order: root → A → A1 → A2 → B → B1 → B2
#eachAfter Source
eachAfter :: forall a b. (HierarchyNode a -> b) -> HierarchyNode a -> Array bPost-order traversal (visit children before parent) Matches D3's .eachAfter() method
Order: A1 → A2 → A → B1 → B2 → B → root
#descendants Source
descendants :: forall a. HierarchyNode a -> Array (HierarchyNode a)Get all descendant nodes (including self) Matches D3's .descendants() method
#leaves Source
leaves :: forall a. HierarchyNode a -> Array (HierarchyNode a)Get all leaf nodes (nodes with no children) Matches D3's .leaves() method
#sortHierarchy Source
sortHierarchy :: forall a. (HierarchyNode a -> HierarchyNode a -> Ordering) -> HierarchyNode a -> HierarchyNode aSort children by comparator Matches D3's .sort() method
Note: This returns a new hierarchy (pure function)
- Modules
- DataViz.
Layout. Adjacency - DataViz.
Layout. Adjacency. Layout - DataViz.
Layout. Adjacency. Types - DataViz.
Layout. Chord - DataViz.
Layout. Chord. Layout - DataViz.
Layout. Chord. Types - DataViz.
Layout. Hierarchy. Cluster - DataViz.
Layout. Hierarchy. Core - DataViz.
Layout. Hierarchy. EdgeBundle - DataViz.
Layout. Hierarchy. EdgeBundle. Bilink - DataViz.
Layout. Hierarchy. EdgeBundle. BundleCurve - DataViz.
Layout. Hierarchy. EdgeBundle. Hierarchy - DataViz.
Layout. Hierarchy. EdgeBundle. RadialCluster - DataViz.
Layout. Hierarchy. EdgeBundle. Types - DataViz.
Layout. Hierarchy. Link - DataViz.
Layout. Hierarchy. Pack - DataViz.
Layout. Hierarchy. Partition - DataViz.
Layout. Hierarchy. Tree - DataViz.
Layout. Hierarchy. TreeStyle - DataViz.
Layout. Hierarchy. Treemap - DataViz.
Layout. Hierarchy. Types - DataViz.
Layout. Pattern - DataViz.
Layout. Pattern. Types - DataViz.
Layout. Sankey. CSV - DataViz.
Layout. Sankey. Compute - DataViz.
Layout. Sankey. ComputeWithSteps - DataViz.
Layout. Sankey. Path - DataViz.
Layout. Sankey. Types - DataViz.
Layout. StateMachine - DataViz.
Layout. StateMachine. Layout - DataViz.
Layout. StateMachine. Path - DataViz.
Layout. StateMachine. Types