Module

DataViz.Layout.Sankey.Types

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

DataViz.Layout.Sankey.Types

Pure PureScript implementation of Sankey diagram layout types. This replaces the FFI-based approach with first-class PureScript types that integrate naturally with the phantom type system.

#LinkCSVRow Source

type LinkCSVRow = { s :: String, t :: String, v :: Number }

Input format for links from CSV (user-provided flow data with named nodes)

#NodeID Source

newtype NodeID

Constructors

Instances

#LinkID Source

newtype LinkID

Constructors

Instances

#NodeNameMap Source

#SankeyNodeInput Source

type SankeyNodeInput = { name :: String }

Input format for nodes (minimal user-provided data) - for backward compatibility

#SankeyNode Source

type SankeyNode = { color :: String, depth :: Int, index :: NodeID, layer :: Int, name :: String, nodeHeight :: Int, sourceLinks :: Set NodeID, targetLinks :: Set NodeID, value :: Number, x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }

Internal node representation after layout computation This has all computed properties needed for rendering

#SankeyLayoutResult Source

type SankeyLayoutResult = { cycleAnalysis :: CycleAnalysis, links :: Array SankeyLink, nodes :: Array SankeyNode }

Result of Sankey layout computation

#SankeyConfig Source

type SankeyConfig = { alignment :: Alignment, extent :: { x0 :: Number, x1 :: Number, y0 :: Number, y1 :: Number }, iterations :: Int, linkColorMode :: LinkColorMode, nodePadding :: Number, nodeValueStrategy :: NodeValueStrategy, nodeWidth :: Number }

Configuration for Sankey layout algorithm

#SankeyStep Source

type SankeyStep = { iteration :: Int, label :: String, links :: Array SankeyLink, nodes :: Array SankeyNode }

A captured step for debugging/visualization

#Alignment Source

data Alignment

Node alignment strategy

Constructors

Instances

#CycleTopology Source

data CycleTopology

Classification of cycle topology in a flow graph. Determined after layer assignment by examining back-edge endpoints.

Constructors

Instances

#CycleAnalysis Source

type CycleAnalysis = { endCycles :: Array SankeyLink, interiorCycles :: Array SankeyLink, topology :: CycleTopology }

Analysis of back-edges in a flow graph, computed after layout.

#RibbonLayout Source

data RibbonLayout

Classified layout result. Each constructor carries exactly the data its rendering strategy needs. Pattern match to select the right renderer.

Constructors

#classifyLayout Source

classifyLayout :: SankeyLayoutResult -> RibbonLayout

Classify a layout result into the appropriate rendering variant.

#FlowContext Source

type FlowContext = { incoming :: Array Number, outgoing :: Array Number }

The flows incident on a node, separated by direction

#NodeValueStrategy Source

newtype NodeValueStrategy

Strategy for computing a node's value from its incident flows. This is the primary parameterization point for generalizing beyond Sankey diagrams to arbitrary ribbon layouts.

Constructors

#sankeyNodeValue Source

sankeyNodeValue :: NodeValueStrategy

Sankey: node value = max(sum inflows, sum outflows). The conservation-of-flow constraint that defines a Sankey diagram.

#constantNodeValue Source

constantNodeValue :: Number -> NodeValueStrategy

Constant node size, ignoring flow values entirely. Useful for pure topology/routing diagrams.

#bottleneckNodeValue Source

bottleneckNodeValue :: NodeValueStrategy

Bottleneck: node value = min(sum inflows, sum outflows). Highlights capacity constraints — nodes are only as tall as their tightest side.

#maxNodeValue Source

maxNodeValue :: NodeValueStrategy

Maximum single flow: node value = max of all incident flow values. Useful for time/latency metrics where parallel inputs don't sum — the node waits for the slowest input.

#defaultSankeyConfig Source

defaultSankeyConfig :: Number -> Number -> SankeyConfig

Default configuration matching D3 defaults

#SankeyGraphModel Source

type SankeyGraphModel = { backEdgeLinks :: Array SankeyLink, capturedSteps :: Array SankeyStep, config :: SankeyConfig, graph :: WeightedDigraph NodeID Number, linkCount :: Int, nodeCount :: Int, nodeIDToName :: NodeNameMap, nodeNameToID :: NodeIDMap, nodeOrder :: Array NodeID, sankeyLinks :: Array SankeyLink, sankeyNodes :: Array SankeyNode }

Graph model for State monad - contains all intermediate computation state SankeyGraphModel is created by folding rows of CSV