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.Distance

This module provides convenience functions for creating ArcDiagram.Paint values that will color nodes and edges based on distance from a given node. This is useful for highlighting the subgraph which is reachable from a given node.

Distance

type alias Distance =
Maybe Int

Represents the distance between two nodes. A value of Just number indicates the number of edges in a shortest path connecting the nodes. A value of Nothing means there is no path connecting the nodes.

Unconventionally, the number may be negative, which indicates there is a path in the reverse direction. This way Distance can represent both forward and backward connections.

Paint

basicPaint : (Node -> String) -> AcyclicDigraph -> Node -> Paint

Get a Paint value that uses the defaultDistancePaint coloring and your own label text, by providing a toLabel function, a graph, and a node.

ArcDiagram.view
    ArcDiagram.defaultLayout
    (ArcDiagram.Distance.basicPaint toLabel graph node)
    graph

See the Selectable Node example for more detail.

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

Similar to Paint, but each function also takes a Distance argument.

defaultDistancePaint : DistancePaint

The defaultDistancePaint will color connected nodes and edges blue or red (for forward or backward connections), and color unconnected nodes, edges, and labels light gray.

paint : DistancePaint -> AcyclicDigraph -> Node -> Paint

Get a Paint value from a DistancePaint value, a graph, and a node.

colorFromDistance : Distance -> String
colorFromDistance distance =
    case distance of
        Just _ ->
            "black"


        Nothing ->
            "lightgray"


view : AcyclicDigraph -> Node -> Html Node
view graph node =
    ArcDiagram.view
        ArcDiagram.defaultLayout
        (ArcDiagram.Distance.paint
            { viewLabel = \n d -> viewColorLabel (colorFromDistance d) (toLabel n)
            , colorNode = always colorFromDistance
            , colorEdge = always colorFromDistance
            }
            graph
            node
        )
        graph