Temperature from FIT/GPX in the profile chart, splits and summary
This commit is contained in:
1 parent
e3f08f2267
commit
ebd4852e98
5 files changed
+27
-12
No files matched your search
@@ -24,6 +24,7 @@ const SERIES = [
|
||||
{ key: "cadence_rpm", label: "Cadence", unit: "rpm", color: "#eda100", height: 70, area: false },
|
||||
{ key: "heart_rate_bpm", label: "Heart rate", unit: "bpm", color: "#e34948", height: 70, area: false },
|
||||
{ key: "power_w", label: "Power", unit: "W", color: "#7b4fd6", height: 70, area: false },
|
||||
{ key: "temperature_c", label: "Temperature", unit: "°C", color: "#d9730d", height: 70, area: false },
|
||||
];
|
||||
const BEST_DISTANCES_KM = [1, 5, 10, 21.0975, 42.195, 100];
|
||||
const BEST_POWER_SECS = [5, 60, 300, 1200, 3600];
|
||||
@@ -53,6 +54,11 @@ export class TrackProfilePanel {
|
||||
|
||||
this._title.textContent = properties.name || "Track";
|
||||
this._stats.textContent = statsText(properties);
|
||||
const temperatures = this._profile.map((p) => p.temperature_c).filter((t) => typeof t === "number");
|
||||
if (temperatures.length) {
|
||||
const avg = temperatures.reduce((a, b) => a + b, 0) / temperatures.length;
|
||||
this._stats.textContent += ` · ${Math.round(avg)} °C (${Math.round(Math.min(...temperatures))}–${Math.round(Math.max(...temperatures))})`;
|
||||
}
|
||||
|
||||
this._chartsContainer.innerHTML = "";
|
||||
this._tooltip = document.createElement("div");
|
||||
@@ -258,15 +264,16 @@ function statsTables(profile, activityType) {
|
||||
const ride = /cycl|bik|ride/i.test(activityType || "");
|
||||
const hasHr = profile.some((p) => typeof p.heart_rate_bpm === "number");
|
||||
const hasPower = profile.some((p) => typeof p.power_w === "number");
|
||||
const hasTemp = profile.some((p) => typeof p.temperature_c === "number");
|
||||
const pace = (secs, meters) => (ride ? `${((meters / secs) * 3.6).toFixed(1)} km/h` : `${formatPace(secs / (meters / 1000))} /km`);
|
||||
let html = "";
|
||||
|
||||
if (timed.length > 1) {
|
||||
const step = ride || total > 50000 ? 5000 : 1000;
|
||||
const rows = splits(timed, step).map(
|
||||
(s) => `<tr><td>${(s.to / 1000).toFixed(s.to % 1000 ? 1 : 0)} km</td><td>${formatDuration(s.secs)}</td><td>${pace(s.secs, s.meters)}</td><td>↑ ${Math.round(s.gain)} m</td><td>↓ ${Math.round(s.loss)} m</td>${hasHr ? `<td>${s.hr ? `${Math.round(s.hr)} bpm` : ""}</td>` : ""}${hasPower ? `<td>${s.power ? `${Math.round(s.power)} W` : ""}</td>` : ""}</tr>`,
|
||||
(s) => `<tr><td>${(s.to / 1000).toFixed(s.to % 1000 ? 1 : 0)} km</td><td>${formatDuration(s.secs)}</td><td>${pace(s.secs, s.meters)}</td><td>↑ ${Math.round(s.gain)} m</td><td>↓ ${Math.round(s.loss)} m</td>${hasHr ? `<td>${s.hr ? `${Math.round(s.hr)} bpm` : ""}</td>` : ""}${hasPower ? `<td>${s.power ? `${Math.round(s.power)} W` : ""}</td>` : ""}${hasTemp ? `<td>${s.temp != null ? `${Math.round(s.temp)} °C` : ""}</td>` : ""}</tr>`,
|
||||
);
|
||||
html += `<details class="profile-stats"><summary>Splits (${step / 1000} km)</summary><table><thead><tr><th>At</th><th>Time</th><th>${ride ? "Speed" : "Pace"}</th><th>Ascent</th><th>Descent</th>${hasHr ? "<th>Avg HR</th>" : ""}${hasPower ? "<th>Avg power</th>" : ""}</tr></thead><tbody>${rows.join("")}</tbody></table></details>`;
|
||||
html += `<details class="profile-stats"><summary>Splits (${step / 1000} km)</summary><table><thead><tr><th>At</th><th>Time</th><th>${ride ? "Speed" : "Pace"}</th><th>Ascent</th><th>Descent</th>${hasHr ? "<th>Avg HR</th>" : ""}${hasPower ? "<th>Avg power</th>" : ""}${hasTemp ? "<th>Avg temp</th>" : ""}</tr></thead><tbody>${rows.join("")}</tbody></table></details>`;
|
||||
}
|
||||
|
||||
const best = [];
|
||||
@@ -306,7 +313,7 @@ function splits(profile, step) {
|
||||
});
|
||||
const meters = profile[i].distance_meters - profile[start].distance_meters;
|
||||
const secs = profile[i].elapsed_secs - profile[start].elapsed_secs;
|
||||
if (meters > 0 && secs > 0) out.push({ to: profile[i].distance_meters, meters, secs, gain, loss, hr: average(part, "heart_rate_bpm"), power: average(part, "power_w") });
|
||||
if (meters > 0 && secs > 0) out.push({ to: profile[i].distance_meters, meters, secs, gain, loss, hr: average(part, "heart_rate_bpm"), power: average(part, "power_w"), temp: average(part, "temperature_c") });
|
||||
start = i;
|
||||
}
|
||||
return out;
|
||||
|
||||
Reference in new issue
Block a user