goyalarchit / elm-dagre / Render

This module provides a minimalistic general graph renderer for some use cases. There are many possible ways of using the this package

  1. You can directly use existing drawers as a plug and play solution.
  2. You can modify the existing drawers using Dagre.Rander.Attributes for changing some aesthetics.
  3. If you want more control you can write your own drawers and use it with draw function. For more details please view the source code for Render and Render.StandardDrawers

Note : This module uses elm-community/typed-svg, so don't confuse Svg as elm/svg.

API

draw : List Dagre.Attributes.Attribute -> List (StandardDrawers.Attributes.Attribute (DrawConfig n e msg)) -> Graph n e -> Html msg

This function is draws a graph as a SVG using the Elm-Dagre module. The first argument takes a list of Dagre attributes, and the second argument sets the drawers and styles. The StandardDrawers are used as the default drawers.

-- The simplest usage is
draw [] [] sampleGraph

You can configure the standard drawers. Please see Render.StandardDrawers for more information.

You can also use a custom drawer by setting draw function attributes. See the next subsection for more information.

-- Example of custom Drawer

Drawers

This type represents a function that translates NodeAttributes / EdgeAttributes to Svg. If the standard drawers are not fulfilling your usecase, you can use these types to define custom drawers. For more details you can look at Render.Types .

Configuration Attributes

edgeDrawer : Types.EdgeDrawer e msg -> StandardDrawers.Attributes.Attribute (DrawConfig n e msg)

This attribute sets the edge drawer for draw function Update the standard drawer configs using this attribute

nodeDrawer : Types.NodeDrawer n msg -> StandardDrawers.Attributes.Attribute (DrawConfig n e msg)

This attribute sets the node drawer for draw function Update the drawer config using this attribute

id : String -> StandardDrawers.Attributes.Attribute (DrawConfig n e msg)

Set id attribute for the svg graph

style : String -> StandardDrawers.Attributes.Attribute (DrawConfig n e msg)

To set inline css style for the generated graph SVG