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 d68ee83c9316 of https://github.com/volgariver6/line-charts (zip prefix lauber00-line-charts-ec0c8ea/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 1d2d5061fac32e0920f5c86bf94648f2ee5bd718.
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.3/
Junk is a way to draw whatever you like in the chart. The name comes from Edward Tufte's concept of "chart junk". If you want to add tooltips, sections for emphasis, or kittens on your chart, this is where it's at.
For the junk-free chart.
Draws the default tooltip.
customJunk : Maybe Data -> Junk.Junk msg
customJunk hovered =
Junk.hoverOne model.hovered
[ ( "Age", toString << .age )
, ( "Weight", toString << .weight )
]See the full example here.
Draws the default tooltip for multiple hovered points.
customJunk : List Data -> Junk.Junk msg
customJunk hovered =
Junk.hoverMany model.hovered formatX formatY
formatX : Data -> String
formatX =
.date >> Date.fromTime >> Date.Format.format "%e. %b, %Y"
formatY : Data -> String
formatY data =
toString data.weight ++ "kg"See the full example here.
Draw whatever junk you'd like. You're given the Coordinate.System to help
you place your junk on the intended spot in the chart, because it allows you
to translate from data-space into SVG-space and vice versa.
To learn more about the Coordinate.System and how to use it, see the
Coordinate module.
junk : Maybe Coordinate.Point -> Coordinate.System -> Junk.Layers msg
junk hovered system =
{ below =
case hovered of
Just hovered -> [ sectionBand hovered system ]
Nothing -> []
, above = []
, html = []
}
sectionBand : Coordinate.Point -> Coordinate.System -> Svg.Svg msg
sectionBand hovered system =
Junk.rectangle system
[ Svg.Attributes.fill "#b6b6b61a" ]
(hovered.x - 5) (hovered.x + 5)
system.y.min system.y.maxSee the full example here.
The layers where you can put your junk.
A good thing to know before reading this section is what I mean by "chart area". It is basically the rectangle which covers your entire x and y axis-range. Below is an illustration.
What is an axis-range? See the Axis.Range module.
An attribute which when added, truncates the rendered element if it extends outside the chart area.
Draws a vertical line, which is the full length of the y-range.
Pass the x-coordinate.
Note: The line is truncated off if outside the chart area.
Draws a horizontal line which is the full length of the x-range.
Pass the y-coordinate.
Note: The line is truncated off if outside the chart area.
Draws a vertical line.
Pass the x-, y1- and y2-coordinates, respectively.
Note: The line is truncated off if outside the chart area.
Draws a horizontal line.
Pass the y-, x1- and x2-coordinates, respectively.
Note: The line is truncated off if outside the chart area.
Draws a rectangle. This can be used for grid bands and highlighting a range e.g. for selection.
xSelectionArea : Coordinate.System -> Float -> Float -> Svg msg
xSelectionArea system startX endX =
Junk.rectangle system
[ Attributes.fill "rgba(255,0,0,0.1)" ]
startX endX system.y.min system.y.maxNote: The rectangle is truncated off if outside the chart area.
Draws a circle. Pass the system, radius, color and x- and y-coordinates respectively.
Given a color, it draws the text in the second argument.
A label, but you get to place it too.
Arguments:
text-anchor css value.customJunk : Junk.Config Data msg
customJunk =
Junk.custom <| \system ->
{ below = []
, above =
[ Junk.labelAt system 2 1.5 0 -10 "middle" Colors.black "← axis range →"
, Junk.labelAt system 2 -1.5 0 18 "middle" Colors.black "← data range →"
-- Try changing the numbers!
]
, html = []
}Place a list of elements on a given spot.
Arguments:
The coordinate system.
The x-coordinate in data-space.
The y-coordinate in data-space.
The x-offset in SVG-space.
The y-offset in SVG-space.
The list of elements
Produces a SVG transform attributes. Useful to move elements around.
movedStuff : Coordinate.System -> Svg.Svg msg
movedStuff system =
Svg.g
[ Junk.transform
[ Junk.move system someDataPoint.age someDataPoint.weight
, Junk.offset 20 10
-- Try changing the offset!
]
]
[ Junk.label Colors.blue "stuff" ]See the full example here.
Moves in data-space.
Moves in SVG-space.
This is just regular html views! Nothing fancy - you can also make your own! Notice that you can override all the styles.
Make the markup for a hover placed in the middle of the y-axis and at a given x-coordinate.
Pass the hint x-coordinate, your styles and your internal view.
customJunk : Maybe Data -> Junk.Config Data msg
customJunk hovered =
Junk.custom <| \system ->
{ below = []
, above = []
, html =
[ Junk.hover system hovered.x
[ ( "border-color", "red" ) ]
[ Html.text (toString hovered.y) ]
]
}Make the markup for a hover placed at a given x- and y-coordinate.
Pass the hint x- and y-coordinate, your styles and your internal view.
customJunk : Maybe Data -> Junk.Config Data msg
customJunk hovered =
Junk.custom <| \system ->
{ below = []
, above = []
, html =
[ Junk.hoverAt system hovered.x system.y.max
[ ( "border-color", "red" ) ]
[ Html.text (toString hovered.y) ]
]
}
Use in the
LineChart.Configpassed toLineChart.viewCustom.