goyalarchit / elm-dagre / 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 Graph.NodeId Basics.Float
, heightDict : Dict Graph.NodeId Basics.Float
, width : Basics.Float
, height : Basics.Float
, nodeSep : Basics.Float
, edgeSep : Basics.Float
, rankSep : Basics.Float
, marginX : Basics.Float
, marginY : Basics.Float 
}

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 Graph.NodeId Basics.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 Graph.NodeId Basics.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 : Basics.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 : Basics.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 : Basics.Float -> Attribute

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

The default value is 50 pixel.

edgeSep : Basics.Float -> Attribute

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

The default value is 10 pixel.

rankSep : Basics.Float -> Attribute

Defines number of pixels between each rank in the layout.

The default value is 75 pixel.

marginX : Basics.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 : Basics.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.