ml-time-graph 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ # Thresholds, zones and filled areas — ml-time-graph
2
+
3
+ Part of the `ml-time-graph` skill — back to [SKILL.md](../SKILL.md). The exhaustive reference
4
+ is `USAGE.md` in the package root ([USAGE.md](../../../USAGE.md)).
5
+
6
+ ## Thresholds & Zone Colouring
7
+ Define thresholds once and reference them by name to colour lines or zones:
8
+ ```ts
9
+ mount('#chart', {
10
+ thresholds: [
11
+ { name: 'warn', value: 25, color: '#f59e0b', line: 'dashed', label: 'Warning' },
12
+ { name: 'crit', value: 30, color: '#ef4444', line: 'solid', label: 'Critical' },
13
+ ],
14
+ series: [{ name: 'Temp', data: tempData, colorByThresholds: ['warn', 'crit'] }],
15
+ });
16
+ ```
17
+
18
+ ## Filled Areas Between Curve and Threshold
19
+ Use `style.fill.regions` with bounds (`from`, `to`, `side`, optional `hatch`):
20
+ ```ts
21
+ style: {
22
+ fill: {
23
+ regions: [
24
+ { from: { threshold: 'warn' }, to: 'series', side: 'above', fill: { color: '#f59e0b33', hatch: 'classic-diagonal' } },
25
+ { from: { threshold: 'crit' }, to: 'series', side: 'above', fill: '#ef444444' },
26
+ ],
27
+ },
28
+ }
29
+ ```
30
+
31
+ **Only where two edges differ:** `where: { exceeds: 2 }` on a region between two series fills
32
+ only where they are more than 2 apart (`side: 'above' | 'below'`, `maxAgeMs`) — decided on the
33
+ readings, not on the smoothed curve. For two probes that should agree.
34
+
35
+ ## Two probes that should agree — `divergenceExcursions`
36
+ ```ts
37
+ import { divergenceExcursions } from 'ml-time-graph/analyze';
38
+
39
+ const episodes = divergenceExcursions(
40
+ [{ name: 'Oben', data: oben }, { name: 'Unten', data: unten }],
41
+ { maxDelta: 2, minDurationMs: 30 * 60_000 },
42
+ );
43
+ // → [{ startTime, endTime, durationMs, peakDelta, peakTime, maxSensor, minSensor }]
44
+ ```
45
+ Two sensors measuring the same thing: while they agree, all is well. Beyond `maxDelta` something
46
+ is wrong — one is icing up, one sits in the draught, one has drifted. **`maxSensor` is the half
47
+ you can act on**: *Unten is 4.5 °C warmer* sends someone to the right probe, *the difference was
48
+ 4.5 °C* does not.
49
+
50
+ `minDurationMs` drops episodes shorter than that — a single sample over the limit is noise, not an
51
+ incident. A timestamp with fewer than two readings has no difference and ends an episode, the way
52
+ a gap does. Sensors are matched by timestamp without interpolation, so bring them to the same
53
+ cadence first.
54
+
55
+ Draw the result as highlights, with `rotate: 'auto'` so a long label in a short episode turns
56
+ upright instead of spilling over the data:
57
+
58
+ ```ts
59
+ highlights: episodes.map((e) => ({
60
+ startTime: e.startTime, endTime: e.endTime,
61
+ label: `${e.maxSensor} +${e.peakDelta.toFixed(1)} °C`,
62
+ labelPosition: 'top', rotate: 'auto',
63
+ }))
64
+ ```