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; they are returned in backEdges, by the caller's names, with where each stands on its nodes (see DataViz.Layout.Sankey.BackEdge for drawing them).

computeLayoutWithLanesAtScale is the same layout at a scale the caller fixes, where config.extent would otherwise fit it to a box.

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 = { backEdges :: Array BackEdge, 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; a back-edge's route has no segments. backEdges: the links set aside, in input order, index being the link's place in the input and source and target its row's names.

#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).

#computeLayoutWithLanesAtScale Source

computeLayoutWithLanesAtScale :: Scale -> (Int -> LinkCSVRow -> Boolean) -> Array LinkCSVRow -> SankeyConfig -> LaneLayout

The same, at a scale the caller fixes: config.extent gives only the top left corner, and the chart is as wide and as tall as the scale makes it (see configAtScale).

#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.