brainrape/elm-arc-diagram/1.0.0

NOTE: the latest version is 2.0.0

Renamed to brainrake/elm-arc-diagram. It is published under that name, and new versions come out there.

Versions published as brainrape/elm-arc-diagram still install under that name. 1 version of 2 come from the new location (see their notes). 1 version could not be recovered and cannot be installed.

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/brainrake/elm-arc-diagram.

What we checked: The repo moved to github.com/brainrake/elm-arc-diagram. Rebuilt with git archive from commit 39d251a5a3ba of https://github.com/brainrake/elm-arc-diagram (zip prefix brainrape-elm-arc-diagram-39d251a/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 140e0db274cfc1a962cc8e2bed6fcc49a661bc64.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/brainrape/elm-arc-diagram/zipball/1.0.0/

ArcDiagram

Visualize an acyclic digraph as an arc diagram.

view : Layout -> Paint -> AcyclicDigraph -> Html Node

Create an arc diagram with the specified layout and paint options. The view produces Node messages when a node or its label are clicked by the user.

type Msg
  = ToggleNode Node
  | ...




view : AcyclicDigraph -> Html Msg
view graph =
  graph
    |> ArcDiagram.view
        ArcDiagram.defaultLayout
        ArcDiagram.defaultPaint
    |> Html.map ToggleNode

Layout

Represents values, in pixels, used to layout the diagram.

type alias Layout =
{ nodePadding : Int
, edgeSpacing : Int
, edgeRadius : Int
, labelWidth : Int
, labelMinHeight : Int
}
  • nodePadding: Nodes are drawn as rectangles tall enough to fit their incoming connections and wide enough to fit their outgoing connections. This determines how much padding to give nodes in addition to the minimum dimensions required to fit their edge connections.
  • edgeSpacing: Edges are drawn as 1px lines, and they do not overlap when connecting to a node. This determines the spacing between each edge connection.
  • edgeRadius: Edges are drawn as L-shaped connections with rounded corners. This determines the corner radius. It can be set to a high number to give the look of a more traditional arc diagram.
  • labelWidth: The width for each label.
  • labelMinHeight: The minimum height for each label. This ensures space for labels when their node heights are otherwise too small.
defaultLayout : Layout
{ nodePadding = 4
, edgeSpacing = 2
, edgeRadius = 4
, labelWidth = 100
, labelMinHeight = 20
}

Paint

Represents functions used to draw labels and set the color for each node and edge.

type alias Paint =
{ viewLabel : Node -> Svg Node
, colorNode : Node -> String
, colorEdge : Edge -> String
}

Color is represented as a string, and should be a CSS color value.

defaultPaint : Paint

The defaultPaint will color nodes black, edges gray, and draw labels displaying the integer represention of each node.

basicPaint : (Node -> String) -> Paint

Get a Paint value that uses the default colors and your own label text, by providing a toLabel function that determines the label text for each node.

view : (Node -> String) -> AcyclicDigraph -> Html Node
view toLabel =
    ArcDiagram.view
        ArcDiagram.defaultLayout
        (ArcDiagram.basicPaint toLabel)