lauber00/line-charts/1.0.2

NOTE: the latest version is 1.0.3

Renamed to volgariver6/line-charts. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as lauber00/line-charts still install under that name. 4 versions of 4 come from the new location (see their notes).

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/volgariver6/line-charts.

What we checked: The repo moved to github.com/volgariver6/line-charts. Rebuilt with git archive from commit 1767f18f9fd0 of https://github.com/volgariver6/line-charts (zip prefix lauber00-line-charts-8808ae7/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 5881948ccc6b0a273f283741d4b711667795ab55.

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/lauber00/line-charts/zipball/1.0.2/

LineChart.Legends

type alias Config data msg =
Config data msg

Use in the LineChart.Config passed to LineChart.viewCustom.

chartConfig : LineChart.Config Data msg
chartConfig =
  { ...
  , legends = Legends.default
  , ...
  }
default : Config data msg

Produces legends in the top right corner.

none : Config data msg

Removes the legends.

Free legends

Where the title is hanging by its respective line.

byEnding : (String -> Svg msg) -> Config data msg

Places the legend by the end of its line.

chartConfig : LineChart.Config Data msg
chartConfig =
  { ...
  , legends = Legends.byEnding (Junk.label Colors.black)
  , ...
  }

See the full example here.

byBeginning : (String -> Svg msg) -> Config data msg

Same as byEnding, except by the beginning of the line!

Grouped legends

Where the titles are gathered in one spot.

grouped : (Range -> Float) -> (Range -> Float) -> Float -> Float -> Config data msg

Draws some legends. You desicde where. Arguments:

  1. Given the x-axis range, you produce the x-coordinate in data-space of the legends.
  2. Given the y-axis range, you produce the y-coordinate of data-space the legends.
  3. Move the legends horizontally in SVG-space.
  4. Move the legends vertically in SVG-space.
chartConfig : LineChart.Config Data msg
chartConfig =
  { ...
  , legends = Legends.grouped .max .min 0 -60 -- Bottom right corner
  , ...
  }

Makes this:

See the full example here.

groupedCustom : Float -> (System -> List (Legend msg) -> Svg msg) -> Config data msg

Customize your grouped legends. Arguments:

  1. The width of the line samples.
  2. Your view function for the legends.
legends : Legends data msg
legends =
  Legends.groupedCustom 30 viewLegends




viewLegends : Coordinate.System -> List (Legends.Legend msg) -> Svg.Svg msg
viewLegends system legends =
  Svg.g
    [ Junk.transform
        [ Junk.move system system.x.min system.y.min
        , Junk.offset 20 20
        ]
    ]
    (List.indexedMap viewLegend legends)




viewLegend : Int -> Legends.Legend msg -> Svg.Svg msg
viewLegend index { sample, label } =
   Svg.g
    [ Junk.transform [ Junk.offset (toFloat index * 100) 20 ] ]
    [ sample, viewLabel label ]




viewLabel : String -> Svg.Svg msg
viewLabel label =
  Svg.g
    [ Junk.transform [ Junk.offset 40 4 ] ]
    [ Junk.label Colors.black label ]

Makes this:

See the full example here.

type alias Legend msg =
{ sample : Svg msg
, label : String
}

Stuff that's helpful when you're drawing your legends. A sample of your line as well your line's label.