commit 8c187fe3c947a4c6263914753cece0790f2c57c6
parent 9fd3620d9b57b218ef2160b7a5bb6b91ffc92c3b
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 21 Nov 2024 14:32:03 +0000
downsample the points once, not again for each graph
Diffstat:
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -303,23 +303,20 @@ tileImg zoom tilenumber = img [ width 256,
type alias Colour = String
measureView : String -> Colour -> (Point -> Maybe Float) -> List Point -> Svg Msg
-measureView title colour fn allPoints =
- let filteredPoints = Point.downsample 300 allPoints
- graphHeight = 180
- startTime = case allPoints of
- (p::_) -> p.time
- _ -> 0
+measureView title colour fn points =
+ let graphHeight = 180
+ startTime = Maybe.withDefault 0 (Point.startTime points)
coords p = case (fn p) of
Just c ->
(String.fromFloat (p.time - startTime)) ++ "," ++
(String.fromFloat c) ++ ", "
Nothing -> ""
- maxY = List.foldr max 0 (List.filterMap fn filteredPoints)
- minY = List.foldr min maxY (List.filterMap fn filteredPoints)
+ maxY = List.foldr max 0 (List.filterMap fn points)
+ minY = List.foldr min maxY (List.filterMap fn points)
(minYaxis, maxYaxis, tickY) = looseLabels 4 minY maxY
rangeYaxis = maxYaxis - minYaxis
- maxX = Point.duration allPoints
- string = String.concat (List.map coords filteredPoints)
+ maxX = Point.duration points
+ string = String.concat (List.map coords points)
ttick = timeTick maxX
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
ybar n = line
@@ -409,13 +406,10 @@ measureView title colour fn allPoints =
timeClickDecoder =
D.map Dribble (D.at ["target", "id"] D.string)
-timeAxis allPoints =
- let filteredPoints = Point.downsample 300 allPoints
- graphHeight = 30
- startTime = case allPoints of
- (p::_) -> p.time
- _ -> 0
- maxX = Point.duration allPoints
+timeAxis points =
+ let graphHeight = 30
+ startTime = Maybe.withDefault 0 (Point.startTime points)
+ maxX = Point.duration points
ttick = timeTick maxX
firstTimeTick = (toFloat (floor(startTime / ttick))) * ttick - startTime
xtick n =
@@ -532,7 +526,8 @@ ifTrack model content =
let (dt, _) = dragDelta Graph model.drag
dpix = dt * model.duration // portalWidth
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
Failure f -> Debug.log f (div [] [ Html.text "failure", Html.text f])
Loading -> div [] [Html.text "loading"]