downsample the points once, not again for each graph
This commit is contained in:
parent
9fd3620d9b
commit
8c187fe3c9
@ -303,23 +303,20 @@ tileImg zoom tilenumber = img [ width 256,
|
|||||||
type alias Colour = String
|
type alias Colour = String
|
||||||
|
|
||||||
measureView : String -> Colour -> (Point -> Maybe Float) -> List Point -> Svg Msg
|
measureView : String -> Colour -> (Point -> Maybe Float) -> List Point -> Svg Msg
|
||||||
measureView title colour fn allPoints =
|
measureView title colour fn points =
|
||||||
let filteredPoints = Point.downsample 300 allPoints
|
let graphHeight = 180
|
||||||
graphHeight = 180
|
startTime = Maybe.withDefault 0 (Point.startTime points)
|
||||||
startTime = case allPoints of
|
|
||||||
(p::_) -> p.time
|
|
||||||
_ -> 0
|
|
||||||
coords p = case (fn p) of
|
coords p = case (fn p) of
|
||||||
Just c ->
|
Just c ->
|
||||||
(String.fromFloat (p.time - startTime)) ++ "," ++
|
(String.fromFloat (p.time - startTime)) ++ "," ++
|
||||||
(String.fromFloat c) ++ ", "
|
(String.fromFloat c) ++ ", "
|
||||||
Nothing -> ""
|
Nothing -> ""
|
||||||
maxY = List.foldr max 0 (List.filterMap fn filteredPoints)
|
maxY = List.foldr max 0 (List.filterMap fn points)
|
||||||
minY = List.foldr min maxY (List.filterMap fn filteredPoints)
|
minY = List.foldr min maxY (List.filterMap fn points)
|
||||||
(minYaxis, maxYaxis, tickY) = looseLabels 4 minY maxY
|
(minYaxis, maxYaxis, tickY) = looseLabels 4 minY maxY
|
||||||
rangeYaxis = maxYaxis - minYaxis
|
rangeYaxis = maxYaxis - minYaxis
|
||||||
maxX = Point.duration allPoints
|
maxX = Point.duration points
|
||||||
string = String.concat (List.map coords filteredPoints)
|
string = String.concat (List.map coords points)
|
||||||
ttick = timeTick maxX
|
ttick = timeTick maxX
|
||||||
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
|
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
|
||||||
ybar n = line
|
ybar n = line
|
||||||
@ -409,13 +406,10 @@ measureView title colour fn allPoints =
|
|||||||
timeClickDecoder =
|
timeClickDecoder =
|
||||||
D.map Dribble (D.at ["target", "id"] D.string)
|
D.map Dribble (D.at ["target", "id"] D.string)
|
||||||
|
|
||||||
timeAxis allPoints =
|
timeAxis points =
|
||||||
let filteredPoints = Point.downsample 300 allPoints
|
let graphHeight = 30
|
||||||
graphHeight = 30
|
startTime = Maybe.withDefault 0 (Point.startTime points)
|
||||||
startTime = case allPoints of
|
maxX = Point.duration points
|
||||||
(p::_) -> p.time
|
|
||||||
_ -> 0
|
|
||||||
maxX = Point.duration allPoints
|
|
||||||
ttick = timeTick maxX
|
ttick = timeTick maxX
|
||||||
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
|
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
|
||||||
xtick n =
|
xtick n =
|
||||||
@ -532,7 +526,8 @@ ifTrack model content =
|
|||||||
let (dt, _) = dragDelta Graph model.drag
|
let (dt, _) = dragDelta Graph model.drag
|
||||||
dpix = dt * model.duration // portalWidth
|
dpix = dt * model.duration // portalWidth
|
||||||
start = toFloat (model.startTime + dpix)
|
start = toFloat (model.startTime + dpix)
|
||||||
points = Point.subseq t start (toFloat model.duration)
|
points = Point.subseq t start (toFloat model.duration) |>
|
||||||
|
Point.downsample 300
|
||||||
in content points
|
in content points
|
||||||
Failure f -> Debug.log f (div [] [ Html.text "failure", Html.text f])
|
Failure f -> Debug.log f (div [] [ Html.text "failure", Html.text f])
|
||||||
Loading -> div [] [Html.text "loading"]
|
Loading -> div [] [Html.text "loading"]
|
||||||
|
Loading…
Reference in New Issue
Block a user