second pass. low

This commit is contained in:
Davide Scaini
2026-04-01 19:00:28 +02:00
parent 3d364c3992
commit bd5831c2fd
11 changed files with 277 additions and 62 deletions
+11 -3
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import * as Plot from '@observablehq/plot';
import { onMount } from 'svelte';
import { onMount, onDestroy } from 'svelte';
import type { Timeseries, AthleteZones } from '../lib/types';
export let timeseries: Timeseries;
@@ -82,8 +82,15 @@
// Range handles — reset whenever the metric or chart type changes
let trimMin = 0;
let trimMax = 100;
$: if (dataMin !== undefined) resetTrim(dataMin, dataMax);
function resetTrim(lo: number, hi: number) { trimMin = lo; trimMax = hi; }
let lastResetTab: Tab | null = null;
$: {
// Reset trim on tab change OR when data range changes
if (activeTab !== lastResetTab || trimMin < dataMin || trimMax > dataMax) {
trimMin = dataMin;
trimMax = dataMax;
lastResetTab = activeTab;
}
}
$: step = (dataMax - dataMin) / 200 || 1;
@@ -116,6 +123,7 @@
// ── Rendering ────────────────────────────────────────────────────────────
onMount(() => { renderChart(); });
onDestroy(() => { chart?.remove(); chart = null; });
$: if (chartEl) {
activeTab; xMode; chartType; histData; histThresholds; alignZones;