diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-07 14:58:02 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-07 14:58:02 +0200 |
| commit | 22a58e96dddd326f4c331c2a1bdea46f808ae3ad (patch) | |
| tree | 08222960e60a9e6db843a0efe37e93b7f67913da /chart | |
| parent | 4b90740c41afb43d11e4dd2c0c9ed91654b7ce43 (diff) | |
refactor: Store rides in columns
Diffstat (limited to 'chart')
| -rw-r--r-- | chart/chart.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/chart/chart.go b/chart/chart.go index a185378..7f5a4c7 100644 --- a/chart/chart.go +++ b/chart/chart.go @@ -19,18 +19,18 @@ func Render(r ride.Ride, climbs []ride.Climb, crossings []mountain_pass.Crossing p.Y.Label.Text = "Elevation (m)" maxElev := 0.0 - elevation := make(plotter.XYs, len(r.Points())) - for i, point := range r.Points() { - elevation[i].X = point.DistanceM / 1000 - elevation[i].Y = point.ElevationM - if point.ElevationM > maxElev { - maxElev = point.ElevationM + elevation := make(plotter.XYs, r.Len()) + for i := 0; i < r.Len(); i++ { + elevation[i].X = r.DistanceM(i) / 1000 + elevation[i].Y = r.ElevationM(i) + if r.ElevationM(i) > maxElev { + maxElev = r.ElevationM(i) } } for _, climb := range climbs { - x0 := climb.Start().DistanceM / 1000 - x1 := climb.End().DistanceM / 1000 + x0 := climb.StartDistanceM() / 1000 + x1 := climb.EndDistanceM() / 1000 fill, err := plotter.NewPolygon(plotter.XYs{ {X: x0, Y: 0}, {X: x1, Y: 0}, @@ -41,7 +41,7 @@ func Render(r ride.Ride, climbs []ride.Climb, crossings []mountain_pass.Crossing fill.Color = color.RGBA{R: 230, G: 160, B: 0, A: 70} fill.LineStyle.Width = 0 p.Add(fill) - p.Add(plotLabels(plotter.XY{X: (x0 + x1) / 2, Y: climb.Top().ElevationM * 1.01}, climbLabel(climb))) + p.Add(plotLabels(plotter.XY{X: (x0 + x1) / 2, Y: climb.TopElevationM() * 1.01}, climbLabel(climb))) } for _, crossing := range crossings { |