Thanks again to David and the forum for all of the good work that is done here!
I was trying to look at time spent altitude training and I figured that it would be great to have an easy to see way to check minimum, maximum and average altitude for activities.
I guess the easiest way would be to have them as columns in the list view so, for example, I could download them to an excel sheet and count how many sessions/hours I spent above a certain altitude.
It would be great to have some more complex analysis, such as graphs in the totals tabs that showed accumulated time above a certain altitude in a given period of time, or having those altitude variables as possible variables for the “compare” graphs, but I think what I said above about the columns in the totals would be a good start that would already allow for some basic analysis.
Afraid I don’t have time to do this fully but this is possible through custom activity fields (Custom activity fields).
The code will be like this, you need to make one for each. I assume the default unit is metres but there’s an option to convert to feet if you prefer.
// get data streams
AltStr = streams.get("fixed_altitude").data //could try altitude;
minAlt = Infinity;
maxAlt = -Infinity;
sumAlt = 0;
count = 0;
for (let value of AltStr) {
// Update minimum value
if (value < minAlt) {
minAlt = value;
}
// Update maximum value
if (value > maxAlt) {
maxAlt = value;
}
// Calculate sum
sumAlt += value;
// Increment count
count++;
}
avgAlt = sumAlt / count;
console.log("Minimum:", minAlt );
console.log("Maximum:", maxAlt);
console.log("Average:", avgAlt);
maxAlt