aboutsummaryrefslogtreecommitdiff
path: root/web/frontend/analytics-logic.ts
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 11:18:06 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 11:18:06 +0200
commitf7264b8f594859c1430bd13e765db03002842d38 (patch)
treeb4cb9e008b8ba8567ead0a6263b69deb8a8b2f8d /web/frontend/analytics-logic.ts
parent53615a05708ff852af42905e2b5ced66ba70c43d (diff)
Add normalized difficulty versus moving duration to analytics
Extend analytics with a second scatter plotting Cotacol per 100 km against moving hours, keep speed versus Cotacol as first chart, render both canvases from shared points, open ride detail in a new tab on dot click, and keep all website copy in English.
Diffstat (limited to 'web/frontend/analytics-logic.ts')
-rw-r--r--web/frontend/analytics-logic.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/web/frontend/analytics-logic.ts b/web/frontend/analytics-logic.ts
index 7a53944..e8a1559 100644
--- a/web/frontend/analytics-logic.ts
+++ b/web/frontend/analytics-logic.ts
@@ -33,3 +33,11 @@ const roundStep = (value: number): number => {
export const formatSpeed = (speed: number): string => `${speed.toFixed(1)}`;
export const formatCotacol = (cotacol: number): string => (cotacol >= 100 ? `${Math.round(cotacol)}` : `${cotacol.toFixed(1)}`);
+
+export const formatHours = (hours: number): string => {
+ if (hours < 1) return `${Math.round(hours * 60)}m`;
+ const h = Math.floor(hours);
+ const m = Math.round((hours - h) * 60);
+ if (m === 0) return `${h}h`;
+ return `${h}h${String(m).padStart(2, "0")}`;
+};