Created
December 17, 2015 16:03
-
-
Save cjwebb/403c5b33a3c5b4d62ee3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Color exposing (..) | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
main : Element | |
main = | |
collage 300 300 | |
[ blueLine | |
, xAxis | |
, yAxis | |
] | |
xAxis : Form | |
xAxis = | |
traced (solid black) (path [(0,0),(0, 300)]) | |
yAxis : Form | |
yAxis = | |
traced (solid black) (path [(0,0),(300, 0)]) | |
blueLine : Form | |
blueLine = | |
traced (solid blue) line | |
transform : GraphData -> (Float, Float) | |
transform graphData = | |
(graphData.time * 10, graphData.value) | |
line : Path | |
line = | |
path (List.map transform data) | |
type alias GraphData = | |
{ time: Float | |
, value: Float | |
} | |
data: List GraphData | |
data = | |
[ { time = 1, value = 10 } | |
, { time = 2, value = 20 } | |
, { time = 3, value = 50 } | |
, { time = 4, value = 100 } | |
, { time = 5, value = 50 } | |
, { time = 6, value = 70 } | |
, { time = 7, value = 90 } | |
, { time = 8, value = 50 } | |
, { time = 9, value = 40 } | |
, { time = 10, value = 40 } | |
, { time = 11, value = 40 } | |
, { time = 12, value = 40 } | |
, { time = 13, value = 40 } | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment