terezka / elm-charts

Create SVG charts in Elm.
https://www.elm-charts.org
BSD 3-Clause "New" or "Revised" License
711 stars 67 forks source link

Plot crashes on constant data and no defined domain #32

Closed krlu closed 7 years ago

krlu commented 7 years ago

Behavior

For a plot with only one series whose y value does not change, the plot crashes.

Expected Behavior

Should plot a straight horizontal line

Example

e.g. the following crashes

let
    test =
      List.range 1 60
      |> List.map (\value -> (toFloat value, 10))
in
    plot
      [ 
      ]
      [ line
        [ 
        ]
        test
      , xAxis
        [ Axis.line [ ]
        ]
      ]

Other notes

This is caused by the getRange function on line 21 in the package Internal.Stuff

terezka commented 7 years ago

Hey you! I realise that adding that crash was a terrible idea :woman_facepalming:. Instead, I now default the range to 1 when your range is zero or less and will just make a note about this in the docs somewhere. Again, thanks for notifying me!

terezka commented 7 years ago

Fixed with https://github.com/terezka/elm-plot/pull/34