Skip to content

Allow for distance-based x-axis for elevation charts - #41

Merged
walkersutton merged 2 commits into
walkersutton:mainfrom
KristianKarl:feat/elevation-distance-x-axis
Aug 31, 2026
Merged

walkersutton merged 2 commits into
walkersutton:mainfrom
KristianKarl:feat/elevation-distance-x-axis

Conversation

@KristianKarl

@KristianKarl KristianKarl commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Add an optional x_axis: "distance" setting on plot elements so the elevation chart (and other non-course scalar plots) can plot against distance travelled instead of evenly spaced samples (time at constant frame rate). Exposed as a toggle under the chart's Advanced panel.

Default remains the time/sample-index axis; course and distance plots are unaffected.

The problem I wanted to solve was that using a "time based", or evenly spaced samples, climbs looks very steep on the descents as opposed to the ascents. It not a problem per se, but I wanted an alternative that was distance-based.

This PR might not be the optimal implementation (it was co-authored by open-code), but I test it byrendering an activity, which looked okay.

I wanted to at least showcase that it worked.

@vercel

vercel Bot commented Aug 3, 2026

Copy link
Copy Markdown

@KristianKarl is attempting to deploy a commit to the Walker Sutton's projects Team on Vercel.

A member of the Team first needs to authorize it.

@KristianKarl

Copy link
Copy Markdown
Contributor Author

I noticed now that I built my PR against release 0.3, not main. I guess that's why The PR has conflicts.
I'll fix that tomorrow.

Add an optional `x_axis: "distance"` setting on plot elements so the
elevation chart (and other non-course scalar plots) can plot against
distance travelled instead of evenly spaced samples (time at constant
frame rate). Exposed as a toggle under the chart's Advanced panel.

Default remains the time/sample-index axis; course and distance plots
are unaffected.
@KristianKarl
KristianKarl force-pushed the feat/elevation-distance-x-axis branch from b73f6fc to 32f6dca Compare August 4, 2026 15:58
@KristianKarl

Copy link
Copy Markdown
Contributor Author

I uploaded 2 screenshots of distance and time based elevation profile at https://gist.github.com/KristianKarl/3fa6bd98658e46ad929a033b6dafdb45

Follow-ups on the distance-based x-axis:

- Sample the banded fill across the x range rather than the sample index
  when x is monotonic. Under a distance axis the two diverge: index
  stepping spends most columns on the dense slow sections and leaves the
  wide fast ones with a handful of vertices, quantising band edges to
  ~100px. Course plots keep index stepping — their x is longitude and
  doubles back.
- Fall back to sample indices when the distance array has no span
  (indoor rides, tracks with repeated coords), which would otherwise
  collapse every point onto the left edge of the plot.
- Offer the toggle on every non-course, non-distance plot instead of
  elevation alone. The backend already applied x_axis to any scalar, so
  switching an elevation plot to speed left the setting applied with no
  UI to see or clear it.
- Match the established switch-row tokens, and document x_axis on the
  PlotElement typedef.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@walkersutton
walkersutton merged commit ff84d8c into walkersutton:main Aug 31, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants