goyalarchit/elm-dagre/4.0.0

NOTE: the latest version is 4.0.1

Dagre.Attributes

Dagre Configuration Attributes

Types

type RankDir
= TB
| BT
| LR
| RL

This type represents the rank directions. T,L,B,R represent Top, Left, Bottom, Right respectively. TB represent Top to Bottom direction. Similar notation is used for other directions.

type alias Config =
{ rankDir : RankDir
, widthDict : Dict NodeId Float
, heightDict : Dict NodeId Float
, width : Float
, height : Float
, nodeSep : Float
, edgeSep : Float
, rankSep : Float
, marginX : Float
, marginY : Float
, initDummyNodeId : Maybe NodeId
}

This type represents the config for the dagre layout algorithm

Note : For complete info on default values and description of each field, please see associated attributes.

type alias Attribute =
Config -> Config

Attribute type for Dagre

Attributes

These function set the respective attributes for the algorithm

Note :

  1. All numeric attributes can not have values < 0. If a value v < 0 then absolute value of v is used.
  2. All numeric values are defined in pixels.
rankDir : RankDir -> Attribute

The rankDir defines the direction for rank nodes.

The possible values can be TB, BT, LR, or RL.

The default value is TB

widthDict : Dict NodeId Float -> Attribute

The widthDict associates nodes with a width that will be used during the layout.

-- For example you want nodes 1,2,3 with widths 50,60,70 respectively then
-- you can pass the following
let
    widths =
        Dict.fromList [ ( 1, 50 ), ( 2, 60 ), ( 3, 70 ) ]
in
runLayout [ widthDict widths ] simplegraph

The dafualt value is Dict.empty

heightDict : Dict NodeId Float -> Attribute

The heightDict associates nodes with a height that will be used during the layout.

-- For example you want nodes 1,2,3 with heights 30,50,40 respectively then
-- you can pass the following
let
    heights =
        Dict.fromList [ ( 1, 30 ), ( 2, 50 ), ( 3, 40 ) ]
in
runLayout [ heightDict heights ] simplegraph

The dafualt value is Dict.empty

width : Float -> Attribute

Defines the default width that will be used during the layout. This value will be used when no value is available in widthDict for some node.

The default value of width is 32 pixels.

height : Float -> Attribute

Defines the default height that will be used during the layout. This value will be used when no value is available in heightDict for some node.

The default value of height is 32 pixels.

nodeSep : Float -> Attribute

Defines the number of pixels that separate nodes in same rank in the layout.

The default value is 50 pixel.

edgeSep : Float -> Attribute

Defines the number of pixels that separate edges horizontally in the layout.

The default value is 10 pixel.

rankSep : Float -> Attribute

Defines number of pixels between each rank in the layout.

The default value is 75 pixel.

marginX : Float -> Attribute

Defines the number of pixels to use as a margin around the left and right of the graph.

The default value is 20 pixels.

marginY : Float -> Attribute

Defines the number of pixels to use as a margin around the top and bottom of the graph.

The default value is 20 pixel.

initDummyNodeId : NodeId -> Attribute

Defines the initial value for Dummy node id. These dummy nodes act as control/bend points for edges.

Note : You can safely assume that all the dummy nodes will have node ids greater than this value. This is attribute should only be used, when you are certain that you want to reserve node-ids till a certain range, to avoid mistakes during the drawing process.

The default value is max( G.NodeIds ) + 1 (i.e. the next available node id)