downsample the points once, not again for each graph

This commit is contained in:
Daniel Barlow 2024-11-21 14:32:03 +00:00
parent 9fd3620d9b
commit 8c187fe3c9

View File

@ -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"]