fix scaling for time graphs
This commit is contained in:
parent
b7344a68c6
commit
cdfc56d7fe
@ -13,6 +13,8 @@ import Point exposing(Point, Pos ,decoder)
|
|||||||
import Svg exposing (Svg, svg, rect, circle, g, polyline)
|
import Svg exposing (Svg, svg, rect, circle, g, polyline)
|
||||||
import Svg.Attributes as S exposing
|
import Svg.Attributes as S exposing
|
||||||
( viewBox
|
( viewBox
|
||||||
|
, preserveAspectRatio
|
||||||
|
, transform
|
||||||
, x, y
|
, x, y
|
||||||
, r, rx, ry
|
, r, rx, ry
|
||||||
, cx, cy
|
, cx, cy
|
||||||
@ -232,20 +234,26 @@ measureView fn allPoints =
|
|||||||
(String.fromFloat (p.time - startTime)) ++ "," ++
|
(String.fromFloat (p.time - startTime)) ++ "," ++
|
||||||
(String.fromFloat c) ++ ", "
|
(String.fromFloat c) ++ ", "
|
||||||
Nothing -> ""
|
Nothing -> ""
|
||||||
|
maxY = String.fromFloat (List.foldr max 0 (List.filterMap fn filteredPoints))
|
||||||
string = String.concat (List.map coords filteredPoints)
|
string = String.concat (List.map coords filteredPoints)
|
||||||
in
|
in
|
||||||
svg
|
svg
|
||||||
[ H.style "width" (px portalWidth)
|
[ width portalWidth
|
||||||
, viewBox ("0 0 " ++ (String.fromFloat (Point.duration allPoints)) ++ " 150")
|
, height 200
|
||||||
|
, preserveAspectRatio "none"
|
||||||
|
, viewBox ("0 0 " ++
|
||||||
|
(String.fromFloat (Point.duration allPoints)) ++
|
||||||
|
" " ++ maxY)
|
||||||
]
|
]
|
||||||
[ g
|
[ g
|
||||||
[ fill "none"
|
[ stroke "#ee4444"
|
||||||
, stroke "red"
|
, strokeWidth "2"
|
||||||
, strokeWidth "3"
|
, transform ("translate(0, " ++ maxY ++") scale(1, -1)")
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
polyline
|
polyline
|
||||||
[ fill "none"
|
[ fill "none"
|
||||||
|
, style "vector-effect" "non-scaling-stroke"
|
||||||
, S.points string
|
, S.points string
|
||||||
] []
|
] []
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user