From 9c1921d69ff904b29dbed0f2247a63a3ca912c80 Mon Sep 17 00:00:00 2001 From: Miles Frain Date: Thu, 29 Aug 2019 15:16:07 -0700 Subject: [PATCH] Update examples in subdirectories for Elm 0.19 To check if everything builds, use the following bash command: shopt -s globstar elm make **/*.elm --- examples/Docs/Axis/Example3.elm | 30 +++++++++---------- examples/Docs/Axis/Example4.elm | 25 +++++++++------- examples/Docs/Axis/Example5.elm | 26 +++++++++------- examples/Docs/Axis/Example6.elm | 28 +++++++++-------- examples/Docs/AxisLine/Example1.elm | 25 +++++++++------- examples/Docs/Colors/Example1.elm | 2 +- examples/Docs/Container/Example3.elm | 2 +- examples/Docs/Dots/Example3.elm | 3 +- examples/Docs/Dots/Example4.elm | 3 +- examples/Docs/Dots/Example5.elm | 5 ++-- examples/Docs/Dots/Example6.elm | 5 ++-- examples/Docs/Events/Example1.elm | 3 +- examples/Docs/Events/Example2.elm | 3 +- examples/Docs/Events/Example3.elm | 3 +- examples/Docs/Events/Example4.elm | 3 +- examples/Docs/Junk/Example1.elm | 7 +++-- examples/Docs/Junk/Example2.elm | 7 +++-- examples/Docs/Junk/Example4.elm | 38 +++++++++++++----------- examples/Docs/Line/Example2.elm | 3 +- examples/Docs/Line/Example3.elm | 3 +- examples/Docs/Line/Example4.elm | 3 +- examples/Docs/Range/Example1.elm | 24 ++++++++------- examples/Docs/Tick/Example1.elm | 28 +++++++++-------- examples/Docs/Ticks/Example1.elm | 26 +++++++++------- examples/Docs/Ticks/Example2.elm | 27 ++++++++++------- examples/Docs/Title/Example1.elm | 24 ++++++++------- examples/Docs/Values/Example1.elm | 24 ++++++++------- examples/Docs/Values/Example2.elm | 28 +++++++++-------- examples/Docs/Values/Example3.elm | 27 +++++++++-------- examples/Explanation/Ranges.elm | 2 +- examples/Explanation/SvgAndDataSpace.elm | 4 +-- 31 files changed, 252 insertions(+), 189 deletions(-) diff --git a/examples/Docs/Axis/Example3.elm b/examples/Docs/Axis/Example3.elm index 6a0249e..8d4dc00 100644 --- a/examples/Docs/Axis/Example3.elm +++ b/examples/Docs/Axis/Example3.elm @@ -51,27 +51,27 @@ chart = xAxisConfig : Axis.Config Data msg xAxisConfig = - Axis.time 650 "Date" .date + Axis.time Time.utc 650 "Date" (toFloat << Time.posixToMillis << .date) -- Change the `dateInterval` function to change the dates! -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - -- 4 * year + toFloat i * 21 * year - -- 20 * day + toFloat i * 8 * day - 4 * Time.hour + toFloat i * 21 * Time.hour + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour - - -year : Time.Time -year = - 356 * day - +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round +millisPerHour = + 60 * 60 * 1000 -- DATA @@ -81,7 +81,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } diff --git a/examples/Docs/Axis/Example4.elm b/examples/Docs/Axis/Example4.elm index 48e0ccf..e14f47b 100644 --- a/examples/Docs/Axis/Example4.elm +++ b/examples/Docs/Axis/Example4.elm @@ -63,7 +63,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -98,17 +98,20 @@ average = , Data 46 85 1.82 70667 (dateInterval 2) ] - -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Axis/Example5.elm b/examples/Docs/Axis/Example5.elm index 10bcf2e..5de81e2 100644 --- a/examples/Docs/Axis/Example5.elm +++ b/examples/Docs/Axis/Example5.elm @@ -30,7 +30,7 @@ main = chart : Html.Html msg chart = LineChart.viewCustom - { x = Axis.time 650 "Date" .date + { x = Axis.time Time.utc 650 "Date" (toFloat << Time.posixToMillis << .date) , y = yAxisConfig , container = Container.default "line-chart-1" , interpolation = Interpolation.default @@ -63,7 +63,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -99,16 +99,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Axis/Example6.elm b/examples/Docs/Axis/Example6.elm index b1a6159..fdc862b 100644 --- a/examples/Docs/Axis/Example6.elm +++ b/examples/Docs/Axis/Example6.elm @@ -57,11 +57,11 @@ xAxisConfig : Axis.Config Data msg xAxisConfig = Axis.custom { title = Title.default "Year" - , variable = Just << .date + , variable = Just << (toFloat << Time.posixToMillis << .date) , pixels = 700 , range = Range.padded 20 20 , axisLine = AxisLine.full Colors.black - , ticks = Ticks.time 5 + , ticks = Ticks.time Time.utc 5 } @@ -74,7 +74,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -110,16 +110,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/AxisLine/Example1.elm b/examples/Docs/AxisLine/Example1.elm index 1bef94a..7ceb058 100644 --- a/examples/Docs/AxisLine/Example1.elm +++ b/examples/Docs/AxisLine/Example1.elm @@ -94,7 +94,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -129,17 +129,20 @@ average = , Data 46 85 1.82 70667 (dateInterval 2) ] - -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Colors/Example1.elm b/examples/Docs/Colors/Example1.elm index d97f6eb..86f6e62 100644 --- a/examples/Docs/Colors/Example1.elm +++ b/examples/Docs/Colors/Example1.elm @@ -1,4 +1,4 @@ -module Docs.LineChart.Example6 exposing (main) +module Docs.Colors.Example1 exposing (main) import Html diff --git a/examples/Docs/Container/Example3.elm b/examples/Docs/Container/Example3.elm index 0e7c5bd..6c8491b 100644 --- a/examples/Docs/Container/Example3.elm +++ b/examples/Docs/Container/Example3.elm @@ -52,7 +52,7 @@ chart = containerConfig : Container.Config msg containerConfig = Container.custom - { attributesHtml = [ Html.Attributes.style [ ( "font-family", "monospace" ) ] ] + { attributesHtml = [ Html.Attributes.style "font-family" "monospace" ] , attributesSvg = [] , size = Container.static , margin = Container.Margin 30 100 60 80 diff --git a/examples/Docs/Dots/Example3.elm b/examples/Docs/Dots/Example3.elm index df39e40..accd5f9 100644 --- a/examples/Docs/Dots/Example3.elm +++ b/examples/Docs/Dots/Example3.elm @@ -1,5 +1,6 @@ module Docs.Dots.Example3 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Dots/Example4.elm b/examples/Docs/Dots/Example4.elm index 1fcb3a1..111340b 100644 --- a/examples/Docs/Dots/Example4.elm +++ b/examples/Docs/Dots/Example4.elm @@ -1,5 +1,6 @@ module Docs.Dots.Example4 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Dots/Example5.elm b/examples/Docs/Dots/Example5.elm index 4dcd1f0..ac9266b 100644 --- a/examples/Docs/Dots/Example5.elm +++ b/examples/Docs/Dots/Example5.elm @@ -1,5 +1,6 @@ -module Docs.Dots.Example3 exposing (main) +module Docs.Dots.Example5 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Dots/Example6.elm b/examples/Docs/Dots/Example6.elm index e3e7623..b579f25 100644 --- a/examples/Docs/Dots/Example6.elm +++ b/examples/Docs/Dots/Example6.elm @@ -1,5 +1,6 @@ -module Docs.Dots.Example3 exposing (main) +module Docs.Dots.Example6 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Events/Example1.elm b/examples/Docs/Events/Example1.elm index a10b6dd..aa0340b 100644 --- a/examples/Docs/Events/Example1.elm +++ b/examples/Docs/Events/Example1.elm @@ -1,5 +1,6 @@ module Docs.Events.Example1 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Events/Example2.elm b/examples/Docs/Events/Example2.elm index e9546bc..84ae123 100644 --- a/examples/Docs/Events/Example2.elm +++ b/examples/Docs/Events/Example2.elm @@ -1,5 +1,6 @@ module Docs.Events.Example2 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Events/Example3.elm b/examples/Docs/Events/Example3.elm index 6244592..d5fa399 100644 --- a/examples/Docs/Events/Example3.elm +++ b/examples/Docs/Events/Example3.elm @@ -1,5 +1,6 @@ module Docs.Events.Example3 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Events/Example4.elm b/examples/Docs/Events/Example4.elm index 3bbc7ea..1cee0a8 100644 --- a/examples/Docs/Events/Example4.elm +++ b/examples/Docs/Events/Example4.elm @@ -1,5 +1,6 @@ module Docs.Events.Example4 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Junk/Example1.elm b/examples/Docs/Junk/Example1.elm index 82ba133..c75ac5c 100644 --- a/examples/Docs/Junk/Example1.elm +++ b/examples/Docs/Junk/Example1.elm @@ -1,5 +1,6 @@ module Docs.Junk.Example1 exposing (main) +import Browser import Html import LineChart import LineChart.Junk as Junk @@ -19,7 +20,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init @@ -77,8 +78,8 @@ chart model = , events = Events.hoverOne Hover , junk = Junk.hoverOne model.hovered - [ ( "Age", toString << .age ) - , ( "Weight", toString << .weight ) + [ ( "Age", String.fromFloat << .age ) + , ( "Weight", String.fromFloat << .weight ) ] , grid = Grid.default , area = Area.default diff --git a/examples/Docs/Junk/Example2.elm b/examples/Docs/Junk/Example2.elm index a90ce9a..f9d4946 100644 --- a/examples/Docs/Junk/Example2.elm +++ b/examples/Docs/Junk/Example2.elm @@ -1,5 +1,6 @@ module Docs.Junk.Example2 exposing (main) +import Browser import Html import Svg import Svg.Attributes @@ -22,7 +23,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init @@ -99,9 +100,9 @@ chart model = junk : Maybe Coordinate.Point -> Coordinate.System -> Junk.Layers msg -junk hovered system = +junk maybeHovered system = { below = - case hovered of + case maybeHovered of Just hovered -> [ sectionBand hovered system ] Nothing -> [] , above = [] diff --git a/examples/Docs/Junk/Example4.elm b/examples/Docs/Junk/Example4.elm index 0042bc3..dd213a1 100644 --- a/examples/Docs/Junk/Example4.elm +++ b/examples/Docs/Junk/Example4.elm @@ -1,9 +1,9 @@ module Docs.Junk.Example4 exposing (main) +import Browser import Html import Time -import Date -import Date.Format +import DateFormat import LineChart import LineChart.Junk as Junk import LineChart.Area as Area @@ -22,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init @@ -72,7 +72,7 @@ chart : Model -> Html.Html Msg chart model = LineChart.viewCustom { y = Axis.default 450 "Weight" .weight - , x = Axis.time 700 "Time" .date + , x = Axis.time Time.utc 700 "Time" (toFloat << Time.posixToMillis << .date) , container = Container.default "line-chart-1" , interpolation = Interpolation.default , intersection = Intersection.default @@ -93,12 +93,13 @@ chart model = formatX : Data -> String formatX = - .date >> Date.fromTime >> Date.Format.format "%e. %b, %Y" + --.date >> Date.fromTime >> DateFormat.format "%e. %b, %Y" + .date >> DateFormat.format [DateFormat.dayOfMonthSuffix, DateFormat.text ". ", DateFormat.monthNameAbbreviated, DateFormat.text ", ", DateFormat.yearNumber] Time.utc formatY : Data -> String formatY data = - toString data.weight ++ "kg" + String.fromFloat data.weight ++ "kg" @@ -110,7 +111,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -145,17 +146,20 @@ average = , Data 46 85 1.82 70667 (dateInterval 2) ] - -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Line/Example2.elm b/examples/Docs/Line/Example2.elm index 4290840..a44f32a 100644 --- a/examples/Docs/Line/Example2.elm +++ b/examples/Docs/Line/Example2.elm @@ -1,5 +1,6 @@ module Docs.Line.Example2 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Line/Example3.elm b/examples/Docs/Line/Example3.elm index 75c2fc1..5d7ecf5 100644 --- a/examples/Docs/Line/Example3.elm +++ b/examples/Docs/Line/Example3.elm @@ -1,5 +1,6 @@ module Docs.Line.Example3 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection import Color.Manipulate as Manipulate -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Line/Example4.elm b/examples/Docs/Line/Example4.elm index 2af7472..75fc226 100644 --- a/examples/Docs/Line/Example4.elm +++ b/examples/Docs/Line/Example4.elm @@ -1,5 +1,6 @@ module Docs.Line.Example4 exposing (main) +import Browser import Html import Html.Attributes exposing (class) import LineChart @@ -21,7 +22,7 @@ import LineChart.Axis.Intersection as Intersection import Color.Manipulate as Manipulate -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init diff --git a/examples/Docs/Range/Example1.elm b/examples/Docs/Range/Example1.elm index 9d970e4..8f20883 100644 --- a/examples/Docs/Range/Example1.elm +++ b/examples/Docs/Range/Example1.elm @@ -88,7 +88,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -124,16 +124,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Tick/Example1.elm b/examples/Docs/Tick/Example1.elm index 9fb0406..8ed2000 100644 --- a/examples/Docs/Tick/Example1.elm +++ b/examples/Docs/Tick/Example1.elm @@ -83,8 +83,8 @@ customTick number = else if number < 80 then Colors.green else Colors.pinkLight - label = Junk.label color (toString number) - even = number % 20 == 0 + label = Junk.label color (String.fromInt number) + even = modBy 20 number == 0 -- Todo, should this be mod 2? in Tick.custom { position = toFloat number @@ -106,7 +106,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -142,16 +142,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Ticks/Example1.elm b/examples/Docs/Ticks/Example1.elm index 4bd94d4..10c6c97 100644 --- a/examples/Docs/Ticks/Example1.elm +++ b/examples/Docs/Ticks/Example1.elm @@ -84,7 +84,7 @@ someCustomTick number = , length = 2 , grid = True , direction = Tick.negative - , label = Just (Junk.label Colors.black (toString number)) + , label = Just (Junk.label Colors.black (String.fromInt number)) } @@ -97,7 +97,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -133,16 +133,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Ticks/Example2.elm b/examples/Docs/Ticks/Example2.elm index 8889497..54ec935 100644 --- a/examples/Docs/Ticks/Example2.elm +++ b/examples/Docs/Ticks/Example2.elm @@ -1,6 +1,7 @@ module Docs.Ticks.Example2 exposing (main) +import Browser import Time import Html import LineChart @@ -26,7 +27,7 @@ import LineChart.Interpolation as Interpolation import LineChart.Axis.Intersection as Intersection -main : Program Never Model Msg +main : Program () Model Msg main = Browser.sandbox { init = init @@ -130,7 +131,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -166,16 +167,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Title/Example1.elm b/examples/Docs/Title/Example1.elm index fede3c2..8c18622 100644 --- a/examples/Docs/Title/Example1.elm +++ b/examples/Docs/Title/Example1.elm @@ -110,7 +110,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -146,16 +146,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Values/Example1.elm b/examples/Docs/Values/Example1.elm index 5716ce4..5f533ab 100644 --- a/examples/Docs/Values/Example1.elm +++ b/examples/Docs/Values/Example1.elm @@ -88,7 +88,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -124,16 +124,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Values/Example2.elm b/examples/Docs/Values/Example2.elm index 8e161df..b334917 100644 --- a/examples/Docs/Values/Example2.elm +++ b/examples/Docs/Values/Example2.elm @@ -60,7 +60,7 @@ xAxisConfig : Axis.Config Data msg xAxisConfig = Axis.custom { title = Title.default "Time" - , variable = Just << .date + , variable = Just << (toFloat << Time.posixToMillis << .date) , pixels = 700 , range = Range.default , axisLine = AxisLine.rangeFrame Colors.gray @@ -76,7 +76,7 @@ ticksConfig = valuesWithin : Coordinate.Range -> List Tick.Time valuesWithin = - Values.time 5 + Values.time Time.utc 5 @@ -88,7 +88,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -124,16 +124,20 @@ average = ] -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round - -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Docs/Values/Example3.elm b/examples/Docs/Values/Example3.elm index d62f80c..0ba2640 100644 --- a/examples/Docs/Values/Example3.elm +++ b/examples/Docs/Values/Example3.elm @@ -1,4 +1,4 @@ -module Docs.Values.Example1 exposing (main) +module Docs.Values.Example3 exposing (main) import Time @@ -83,7 +83,7 @@ type alias Data = , weight : Float , height : Float , income : Float - , date : Time.Time + , date : Time.Posix } @@ -118,17 +118,20 @@ average = , Data 46 85 1.82 70667 (dateInterval 2) ] - -dateInterval : Int -> Time.Time +-- Creates a magic time interval +dateInterval : Float -> Time.Posix dateInterval i = - 4 * year + toFloat i * 21 * year - + let + magicHoursInterval = + 4 + i * 21 -- Feel free to change this + in + magicHoursInterval |> hoursToMillis |> Time.millisToPosix -day : Time.Time -day = - 24 * Time.hour +-- Converts hours to miliseconds +hoursToMillis : Float -> Int +hoursToMillis h = + h * millisPerHour |> round -year : Time.Time -year = - 356 * day +millisPerHour = + 60 * 60 * 1000 diff --git a/examples/Explanation/Ranges.elm b/examples/Explanation/Ranges.elm index ac11485..b3bb581 100644 --- a/examples/Explanation/Ranges.elm +++ b/examples/Explanation/Ranges.elm @@ -84,7 +84,7 @@ customTick direction n = , length = 10 , grid = True , direction = direction - , label = Just <| Junk.label Color.black (toString labelNumber) + , label = Just <| Junk.label Color.black (String.fromFloat labelNumber) } diff --git a/examples/Explanation/SvgAndDataSpace.elm b/examples/Explanation/SvgAndDataSpace.elm index 3aef7a6..9a59866 100644 --- a/examples/Explanation/SvgAndDataSpace.elm +++ b/examples/Explanation/SvgAndDataSpace.elm @@ -1,4 +1,4 @@ -module Explanation.Ranges exposing (main) +module Explanation.SvgAndDataSpace exposing (main) import Html @@ -98,7 +98,7 @@ customJunk system = pointToString : Coordinate.Point -> String pointToString { x, y } = let round10 n = toFloat (round (n * 10)) / 10 in - "( " ++ toString (round10 x) ++ ", " ++ toString (round10 y) ++ " )" + "( " ++ String.fromFloat (round10 x) ++ ", " ++ String.fromFloat (round10 y) ++ " )"