Module

DataViz.Layout.Adjacency

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

DataViz.Layout.Adjacency

Pure PureScript adjacency matrix layout algorithm.

An adjacency matrix is a square grid where:

  • Each row and column represents a node
  • Each cell (i,j) represents the connection from node i to node j
  • Non-zero values indicate connections, zero indicates no connection

This module provides pure layout computation that can be used with any rendering backend (D3, Canvas, SVG, etc.)

Example usage:

let matrix = { matrix: [[0,1,0],[1,0,1],[0,1,0]], names: ["A","B","C"] }
    layoutResult = layout matrix
-- layoutResult.cells contains positioned cells ready for rendering

Re-exports from DataViz.Layout.Adjacency.Layout

#LayoutConfig Source

type LayoutConfig = { cellSize :: Number, labelHeight :: Number, labelMargin :: Number, labelWidth :: Number }

Configuration for matrix layout

#shortenName Source

shortenName :: String -> String

Shorten a module name for display (last component only)

#layoutWithConfig Source

layoutWithConfig :: LayoutConfig -> AdjacencyMatrix -> MatrixLayout

Layout a matrix with custom configuration

#layout Source

layout :: AdjacencyMatrix -> MatrixLayout

Layout a matrix with default configuration

#defaultConfig Source

defaultConfig :: LayoutConfig

Default layout configuration

Re-exports from DataViz.Layout.Adjacency.Types

#MatrixLayout Source

type MatrixLayout = { cells :: Array MatrixCell, colLabels :: Array MatrixLabel, gridHeight :: Number, gridWidth :: Number, rowLabels :: Array MatrixLabel, totalHeight :: Number, totalWidth :: Number }

Complete layout output ready for rendering

#MatrixLabel Source

type MatrixLabel = { displayName :: String, index :: Int, isRow :: Boolean, name :: String, position :: LabelPosition }

A label for row or column

#MatrixCell Source

type MatrixCell = { col :: Int, colName :: String, position :: CellPosition, row :: Int, rowName :: String, value :: Number }

A cell in the laid out matrix Contains both the data and computed position

#LabelPosition Source

type LabelPosition = { anchor :: String, rotation :: Number, x :: Number, y :: Number }

Position of a label

#CellPosition Source

type CellPosition = { height :: Number, width :: Number, x :: Number, y :: Number }

Position of a cell in the grid

#AdjacencyMatrix Source

type AdjacencyMatrix = { matrix :: Array (Array Number), names :: Array String }

The adjacency matrix data structure Contains raw matrix values and associated node names