Module

DataViz.Layout.Hierarchy.TreeStyle

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

Type-Safe Tree Styles

Bundles tree layout orientation with matching link path generators. This prevents mismatches like using horizontal beziers with vertical trees.

Usage:

-- Get a bundled style with matching link generator
let style = verticalTree { width: 800.0, height: 600.0 }

-- Use the bundled link generator
let pathD = style.linkPath x1 y1 x2 y2

-- Or create a custom style
let custom = customTree myConfig myLinkFn

#TreeStyle Source

type TreeStyle = { linkPath :: LinkPathFn, orientation :: TreeOrientation }

A tree style bundles orientation with its matching link path generator. The orientation is a phantom type that enables type-safe composition.

#LinkPathFn Source

type LinkPathFn = Number -> Number -> Number -> Number -> String

Type alias for link path generator functions Takes source (x1, y1) and target (x2, y2), returns SVG path string

#verticalTree Source

verticalTree :: TreeStyle

Vertical tree: root at top, children below Uses vertical bezier curves (control points at midpoint Y)

#horizontalTree Source

horizontalTree :: TreeStyle

Horizontal tree: root at left, children to the right Uses horizontal bezier curves (control points at midpoint X)

#radialTree Source

radialTree :: TreeStyle

Radial tree: root at center, children radiate outward Uses radial bezier curves (control points follow arc)

#linkPath Source

linkPath :: TreeStyle -> LinkPathFn

Get the link path generator from a tree style

#orientation Source

orientation :: TreeStyle -> TreeOrientation

Get the orientation from a tree style

#customTree Source

customTree :: LinkPathFn -> TreeStyle

Custom tree style with user-provided link generator Use this when you need a non-standard pairing

#TreeOrientation Source

data TreeOrientation

Tree orientation (used as phantom type marker)

Constructors

Instances