Module

DataViz.Layout.Sankey.Lanes

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

Lanes for long links. A link that spans more than one column is, in plain Sankey layout, drawn straight across the columns between, through whatever nodes stand there. The standard remedy (Sugiyama's dummy nodes) is to give such a link a waypoint in every column it passes: the layout then keeps room for it in each, as for any node, and the link is drawn as one ribbon through its waypoints.

computeLayoutWithLanes does this for the links the caller chooses. It lays the graph out once to learn each node's column, adds the waypoints, and lays it out again with every column held, so the chart keeps the columns it would have had. Back-edges get no lane.

A waypoint's name is private (laneOf reads it). A caller with its own nodeSort sees waypoints in the comparisons and can place a lane, for example with the node its link comes from: laneOf says which link and which column.

Built for Triggerfish's signal-flow chart (2026-10-04), where a machine upstream of another sends notes through that machine's column.

#Route Source

type Route = { index :: Int, segments :: Array SankeyLink }

One input link, as drawn: its segments in order, from its source through its waypoints (if any) to its target. index is its place in the input.

#LaneLayout Source

type LaneLayout = { cycleAnalysis :: CycleAnalysis, nodes :: Array SankeyNode, routes :: Array Route, waypoints :: Array SankeyNode }

nodes: the graph's own nodes, without waypoints. waypoints: the lane nodes, for drawing routes (pass nodes <> waypoints to generateRoutePath). routes: one per input link, in input order.

#computeLayoutWithLanes Source

computeLayoutWithLanes :: (Int -> LinkCSVRow -> Boolean) -> Array LinkCSVRow -> SankeyConfig -> LaneLayout

The layout, with a lane for every input link that spans more than one column and that wants (given its input index and row).

#laneOf Source

laneOf :: String -> Maybe { layer :: Int, link :: Int }

Whether a node name is a waypoint, and if so of which input link, in which column.

#generateRoutePath Source

generateRoutePath :: Array SankeyNode -> Route -> String

A route as one closed ribbon: the top edge forward through each segment and across each waypoint, the bottom edge back. nodes must include the waypoints.