set viewBox for graphs to show full time range
todo: also scale the y axis correctly
This commit is contained in:
parent
6ddd374a94
commit
b7344a68c6
@ -235,7 +235,9 @@ measureView fn allPoints =
|
|||||||
string = String.concat (List.map coords filteredPoints)
|
string = String.concat (List.map coords filteredPoints)
|
||||||
in
|
in
|
||||||
svg
|
svg
|
||||||
[ ]
|
[ H.style "width" (px portalWidth)
|
||||||
|
, viewBox ("0 0 " ++ (String.fromFloat (Point.duration allPoints)) ++ " 150")
|
||||||
|
]
|
||||||
[ g
|
[ g
|
||||||
[ fill "none"
|
[ fill "none"
|
||||||
, stroke "red"
|
, stroke "red"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Point exposing(Pos, Point, decoder, downsample)
|
module Point exposing(Pos, Point, decoder, downsample, duration)
|
||||||
|
|
||||||
import Json.Decode as D
|
import Json.Decode as D
|
||||||
|
|
||||||
@ -33,10 +33,10 @@ decoder = D.map5 Point
|
|||||||
(D.field "heartRate" (D.maybe D.int))
|
(D.field "heartRate" (D.maybe D.int))
|
||||||
|
|
||||||
|
|
||||||
llast x xs =
|
last x xs =
|
||||||
case xs of
|
case xs of
|
||||||
[] -> x
|
[] -> x
|
||||||
(x_::xs_) -> llast x_ xs_
|
(x_::xs_) -> last x_ xs_
|
||||||
|
|
||||||
tracef x = Debug.log (String.fromFloat x) x
|
tracef x = Debug.log (String.fromFloat x) x
|
||||||
|
|
||||||
@ -54,8 +54,11 @@ downsample n points =
|
|||||||
in
|
in
|
||||||
case points of
|
case points of
|
||||||
(first::rest) ->
|
(first::rest) ->
|
||||||
let last = llast first rest
|
let step = (duration points) / (toFloat n)
|
||||||
duration = last.time - first.time
|
|
||||||
step = duration / (toFloat n)
|
|
||||||
in nextpoint step first rest
|
in nextpoint step first rest
|
||||||
[] -> []
|
[] -> []
|
||||||
|
|
||||||
|
duration points =
|
||||||
|
case points of
|
||||||
|
(p::ps) -> (last p ps).time - p.time
|
||||||
|
_ -> 0
|
||||||
|
Loading…
Reference in New Issue
Block a user