@@ -5,7 +5,7 @@ import Html.Attributes exposing (style)
5
5
import Svg.Attributes exposing (stroke )
6
6
import Task
7
7
import Window exposing (Size )
8
- import Device.Motion exposing (Motion )
8
+ import Device.Motion exposing (Motion , Acceleration )
9
9
import Plot exposing (defaultSeriesPlotCustomizations )
10
10
import SlidingBuffer exposing (SlidingBuffer )
11
11
@@ -93,27 +93,26 @@ plotMotion model =
93
93
, toDomainHighest = \ y -> y + 0.1
94
94
}
95
95
96
- convertIndexAndMotionToCoordinate index motion =
97
- { x = toFloat index, acceleration = motion. acceleration }
98
-
99
- coordinates =
100
- List . indexedMap
101
- convertIndexAndMotionToCoordinate
102
- ( SlidingBuffer . toList model. history)
103
-
104
96
seriesAlong getter color =
105
- { axis = Plot . normalAxis
106
- , interpolation = Plot . Linear ( Just color) [ stroke " " ]
107
- , toDataPoints = List . map ( \ { x, acceleration } -> Plot . clear x ( getter acceleration))
108
- }
97
+ let
98
+ toCoordinates =
99
+ SlidingBuffer . toList >> ( List . indexedMap convertIndexAndMotionToCoordinate)
100
+
101
+ convertIndexAndMotionToCoordinate index motion =
102
+ Plot . clear ( toFloat index) ( getter motion)
103
+ in
104
+ { axis = Plot . normalAxis
105
+ , interpolation = Plot . Linear ( Just color) [ stroke " " ]
106
+ , toDataPoints = toCoordinates
107
+ }
109
108
110
109
series =
111
- [ seriesAlong . x " cyan"
112
- , seriesAlong . y " magenta"
113
- , seriesAlong . z " yellow"
110
+ [ seriesAlong ( . acceleration >> . x ) " cyan"
111
+ , seriesAlong ( . acceleration >> . y ) " magenta"
112
+ , seriesAlong ( . acceleration >> . z ) " yellow"
114
113
]
115
114
in
116
- Plot . viewSeriesCustom configuration series coordinates
115
+ Plot . viewSeriesCustom configuration series model . history
117
116
118
117
119
118
center : Html Msg -> Html Msg
0 commit comments