ml-time-graph 1.12.1 → 1.14.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.
package/CHANGELOG.md CHANGED
@@ -19,6 +19,74 @@ release notes, and every change is in `git log` in full.
19
19
 
20
20
  ---
21
21
 
22
+ ## [1.14.0] - 2026-10-07
23
+
24
+ ### Added
25
+ - **`chart.plotRect`** (TS) / **`PlotRect()`** (Go) — the plot area the series are drawn into.
26
+ - **`autoMargin(options)`** (TS) / **`chart.AutoMargin()`** (Go) — margins that fit what the chart
27
+ draws (tick labels, axis titles, stacked axes, outside threshold labels). Measured on the draw
28
+ commands, no DOM, a few ms; same result in both ports.
29
+ - **`chart.pointsAt(x, y)`** (TS) / **`PointsAt()`** (Go) — the points under the pointer, as data
30
+ for your own tooltip: per visible series the one nearest in time; aggregated series give their
31
+ bucket. Same rules in both ports, checked against a shared fixture.
32
+
33
+ ### Fixed
34
+ - **`chart.layout` ignored an outside legend** (TypeScript). It returned the plot area before the
35
+ legend reserved its margin, while the scales used the shifted one — a brush zoom computed from it
36
+ picked a different time range than it showed.
37
+
38
+ ## [1.13.0] - 2026-10-07
39
+
40
+ ### Added
41
+ - **`holdAlign` — probes that do not report at the same time.** `divergenceExcursions` and
42
+ `spatialDelta` match readings by their exact timestamp; a probe that reports only on change and
43
+ one that reports every minute almost never share one, so a real divergence went unseen.
44
+ `holdAlign(sensors, maxAgeMs)` lays every probe onto the union of all timestamps and carries its
45
+ last reading forward for at most `maxAgeMs` — after that the probe has no value, because a silent
46
+ probe is not one that agrees. A gap marker ends the hold at once; `maxAgeMs <= 0` keeps exact
47
+ matching. In `ml-time-analyze` and as `analyze.HoldAlign` in Go.
48
+ - **Go: `analyze.SpatialDelta` and `analyze.DivergenceExcursions`** — the Go port had none of the
49
+ spatial analysis. Same decisions as TypeScript: the limit is strictly greater, a timestamp with
50
+ fewer than two readings ends an episode, `endTime` is the last reading over the limit, a
51
+ one-reading episode lasts 0 ms and passes `minDurationMs: 0`, and the probes named are those at
52
+ the peak. On a tie the FIRST probe of the input wins in both ports.
53
+ - **A shared fixture for analysis results.** `go-time-graph/test_data/analyze/divergence.json` is
54
+ read by the Go and the TypeScript tests alike (in its own directory: every `*.json` directly
55
+ under `test_data/` is taken for a chart template), with expectations worked out by hand. Until now
56
+ only the renderer had parity templates — a difference between the two divergence detectors would
57
+ have passed every existing check.
58
+ - **Fill regions between two smoothed series follow both lines exactly** — each edge is its
59
+ series' own curve (own runs, own smoothing type), clipped to where both have values. New
60
+ draw-command field `smoothTailType`. Go: `FillSpecRenderContext.FremdeReihe`; `FremdeSerie` is
61
+ deprecated.
62
+
63
+ - **`grid: true` / `grid: false`** on an axis — short for `{ major: {} }` / `{ major: false }`.
64
+
65
+ ### Changed
66
+ - **SVG about a quarter smaller.** Grid, axes and series markers write their shared styles once,
67
+ on a group (axes: lines first, then labels). The image is pixel-identical. Draw commands keep
68
+ every attribute; markers now come in a `series-markers` group, and groups carry the marker
69
+ `sharedStyles`. PDF output is byte-identical.
70
+
71
+ ### Fixed
72
+ - **`smoothingType` had no effect on min/max/avg series (TypeScript only).** A chart asking for
73
+ `monotone` or `akima` on an aggregated series got Catmull-Rom, while the Go port drew the curve
74
+ asked for. Also affected `LineSeries` and `renderSplitLine` via `ml-time-graph/internals`.
75
+ - **`fillToMax` / `fillToMin` did not follow smoothed min/max/avg lines.** The fill had straight
76
+ edges and stuck out past the curves between data points. New draw-command field `smoothTail`;
77
+ custom renderers in Go use `renderer.SmoothPathFor(pts, cmd)`.
78
+ - **Go could not read `grid.major: false`** — the whole chart failed to load.
79
+ - **`major: false` alone switched the grid on** for the other direction (TypeScript). Now the grid
80
+ is on only when some axis switches it on.
81
+ - **Array-form `style.line` (TypeScript only):** fill smoothing, `gapThreshold` and legend colour
82
+ now come from the first entry, as in Go. Before, the fill stayed straight under a smoothed line.
83
+
84
+ ### Removed
85
+ - **`ZonedLineSeries`, `Zone`, `ZonedFill`, `ZonedLineConfig` (via `ml-time-graph/internals`).** A
86
+ second, older implementation of the zone colouring the chart already does for
87
+ `colorByThresholds`. Set `colorByThresholds` on the series instead.
88
+
89
+
22
90
  ## [1.12.1] - 2026-10-06
23
91
 
24
92
  ### Fixed
package/SKILLS.md CHANGED
@@ -270,6 +270,11 @@ travel in JSON, so the server cannot run yours. Same chart, two renderers, two l
270
270
  the browser is the only renderer; use a generated table when both have to agree. `estimateMetrics`
271
271
  (exported) reproduces the layout of versions before 1.10.0.
272
272
 
273
+ ### Grid
274
+ `axes: { x: { grid: true } }` — a grid in both directions; one axis is enough. `grid: false` on
275
+ the other axis leaves that direction out; a `false` alone switches nothing on. `true` is short for
276
+ `{ major: {} }`; use the object form for colour, minor lines or `layer`.
277
+
273
278
  ### Minor Ticks & Grid
274
279
  ```ts
275
280
  axes: {
@@ -428,6 +433,11 @@ chart.renderCommands();
428
433
  const timeMs = chart.invertTime(pixelX);
429
434
  const value = chart.invertValue(pixelY, yAxisIndex);
430
435
  const { x, y } = chart.project(timeMs, value, yAxisIndex);
436
+
437
+ // The plot area the scales map onto (an outside legend included):
438
+ const { x: px0, y: py0, width, height } = chart.plotRect;
439
+ // Data for your own tooltip — per visible series the point nearest in time:
440
+ const points = chart.pointsAt(pixelX, pixelY, { hidden: ['flow'] });
431
441
  ```
432
442
 
433
443
  ### Server-Side Rendering (Node.js)
@@ -517,7 +527,7 @@ scratch image.
517
527
  ## Traps (Read Before Coding)
518
528
 
519
529
  - **Timestamps are numbers, not Date objects:** `time` is always milliseconds since Unix epoch (`number`). Passing a `Date` object fails typechecking or evaluates to `NaN`.
520
- - **Labels are not measured (fixed margins):** The renderer has no DOM and cannot compute text bounding boxes. Margins default to `{ top: 20, right: 20, bottom: 40, left: 60 }`. If you add a right Y-axis or formatted units (e.g. `120.5 °C`), `right: 20` will clip the labels against the SVG edge. A clipped number is a wrong number, not an incomplete one (`120` clipped to `20`). Always set `margin.right` explicitly (e.g. 70–90 px) when using right axes.
530
+ - **Margins are fixed unless you measure them:** The chart draws into `margin` (default `{ top: 20, right: 20, bottom: 40, left: 60 }`). A right Y-axis or a formatted unit (`120.5 °C`) does not fit into `right: 20`, and a clipped number is a wrong number (`120` clipped to `20`). Use `margin: autoMargin(options)` — it measures the labels the chart actually draws (no DOM, a few ms) — or set the margins yourself.
521
531
  - **`resolveDash()` vs `getLineStyle()`:** `dashed` and `dotted` predate the scalable dash table and keep fixed SVG patterns (`"4,4"` and `"2,4"`) in the renderer for backwards compatibility. `getLineStyle()` returns the scalable table (`"6, 4"` for width 2). Anyone rendering custom legend swatches must call `resolveDash(variant, width)` so the swatch matches what is actually drawn.
522
532
  - **Markers do not inherit `line.width`:** `style.markers` carries its own pen — `strokeWidth`, `stroke`, `fill`. That is usually what you want (a 10 px line with 10 px marker outlines is a blob), but it means a marker stays hairline-thin when the line gets thick, and nothing tells you. Set `markers.strokeWidth` explicitly whenever `line.width` leaves the default.
523
533
  - **Marker suppression at threshold:** `style.markers.threshold` (and default `theme.pointThreshold = 100`) hides point markers when series sample count exceeds it to prevent visual crowding. Crucially, `chart.legendItems()` also omits the `marker` property when points are suppressed, because a symbol in the legend missing from the curve states something untrue.
package/USAGE.md CHANGED
@@ -445,10 +445,17 @@ new MLTimeGraph({
445
445
  });
446
446
  ```
447
447
 
448
- **A grid is drawn only when you ask for one.** Set `grid: { major: {} }` on either axis and
449
- both get one; leave it out and there is none. (Before 1.5.1 the Go port drew a grid when
450
- nothing was configured while the TypeScript side drew none — the same JSON gave two
451
- different charts.)
448
+ **A grid is drawn only when you ask for one.** Set `grid: true` — short for
449
+ `grid: { major: {} }` — on either axis and both directions get one; leave it out and there is
450
+ none. `grid: false` (or `major: false`) on the other axis leaves that direction out:
451
+
452
+ ```ts
453
+ axes: { x: { grid: true } } // both directions
454
+ axes: { x: { grid: true }, left: { grid: false } } // vertical lines only
455
+ ```
456
+
457
+ A `false` alone switches nothing on. (Before 1.5.1 the Go port drew a grid when nothing was
458
+ configured while the TypeScript side drew none — the same JSON gave two different charts.)
452
459
 
453
460
  **The grid is drawn over the series, not under it.** That is what `grid.layer: 'front'` means,
454
461
  and it is the default: a filled area down to the baseline would otherwise swallow the lines.
@@ -473,6 +480,27 @@ widest stroke plus a little is a good rule of thumb. An explicit `domain` is lef
473
480
  alone, and padding that does not fit the chart height is ignored rather than
474
481
  producing an inverted scale.
475
482
 
483
+ ### Margins that fit — `autoMargin`
484
+
485
+ The chart draws into fixed margins. When they are too narrow, labels are cut, and a cut number
486
+ is a wrong number (`-80` becomes `-8`). `autoMargin(options)` returns margins that fit what the
487
+ chart actually draws — tick labels, axis titles, stacked axes, threshold labels `outside-*`:
488
+
489
+ ```ts
490
+ import { MLTimeGraph, autoMargin } from 'ml-time-graph';
491
+
492
+ const chart = new MLTimeGraph({ ...options, margin: autoMargin(options) });
493
+ ```
494
+
495
+ - **Measured, not estimated:** it renders the chart and measures the draw commands, with the
496
+ options' `textMetrics` (default `liberationMetrics`). No DOM.
497
+ - **A helper, not an option:** `margin` stays numbers. Call it once per change of the options —
498
+ a few milliseconds, independent of the amount of data (it draws only each series' extreme
499
+ points, which is what the axes are made of).
500
+ - A legend `outside-*` reserves its room on top, as before. `{ padding, minimum }` tune the air
501
+ (default 4 px) and the least any side gets (default 8 px).
502
+ - The Go port has the same function (`chart.AutoMargin`) and gives the same margins.
503
+
476
504
  ### Multi-Axis Layout (N Stacked Y-Axes)
477
505
 
478
506
  To support 3 or more vertical axes (or arbitrary left/right positioning), define `axes.y: YAxisConfig[]` and assign series using `yAxisIndex`:
@@ -883,10 +911,33 @@ Options: `format` (HTML; default = time header + `name: value` rows),
883
911
  the `.mlc-tooltip` CSS class — **don't set `transform`**; placement (incl. the
884
912
  flip) is computed in JS.
885
913
 
914
+ ### Points under the pointer — `pointsAt` (your own tooltip)
915
+
916
+ When the tooltip is your own component (a Svelte snippet, a React element) it needs
917
+ data, not HTML. `chart.pointsAt(x, y, options?)` returns it, in SVG pixels, after
918
+ `renderCommands()`:
919
+
920
+ ```ts
921
+ chart.renderCommands();
922
+ const points = chart.pointsAt(px, py, { radius: 20, hidden: ['flow'] });
923
+ // [{ seriesId, name, axisIndex, time, value, x, y, distance }, …]
924
+ ```
925
+
926
+ The rules, the same in the Go port (`PointsAt`):
927
+
928
+ - per visible series at most one point — the one nearest in **time**, within `radius`
929
+ pixels horizontally (default 20); on a tie the nearer one, then the earlier;
930
+ - gaps (`value: null`), `synthetic` points and series listed in `hidden` (by `id`,
931
+ or `name` when there is none) do not count;
932
+ - an aggregated series gives its bucket — `min`, `max`, `avg`, `count` — never a
933
+ made-up single value; its `distance` is measured to the min..max band;
934
+ - sorted by distance to the pointer; outside the plot area there is nothing.
935
+
886
936
  ### Zoom / pan
887
937
 
888
938
  Zoom, pan and minimap are **not** baked into the chart. Map pixels back to data
889
- with `chart.invertTime(px)` / `chart.invertValue(py, axisIndex)` and wire the
939
+ with `chart.invertTime(px)` / `chart.invertValue(py, axisIndex)` — the plot area
940
+ they map onto is `chart.plotRect` — and wire the
890
941
  interaction in your app, or pull the optional `Zoom` / `Minimap` helpers from the
891
942
  [`ml-time-graph/interaction`](#package-exports) subpath. See the demo gallery's
892
943
  "Fridge" (range slider) and "Interaction" pages.
@@ -553,6 +553,28 @@ interface DivergenceEpisode {
553
553
  */
554
554
  declare function divergenceExcursions(sensors: NamedSeries[], opts: DivergenceOptions): DivergenceEpisode[];
555
555
 
556
+ /*!
557
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
558
+ * MIT with Attribution: free use incl. commercial requires visible credit to
559
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
560
+ */
561
+
562
+ /**
563
+ * Bringt Fuehler auf die sortierte Vereinigung aller Zeitstempel. Zu jedem
564
+ * Zeitpunkt gilt fuer jeden Fuehler sein letzter Messwert -- solange er
565
+ * hoechstens `maxAgeMs` alt ist; danach `null` (keine Aussage, nicht "einig").
566
+ *
567
+ * Eine Luecken-Marke (`value: null`) bricht das Halten ab. `maxAgeMs <= 0` heisst:
568
+ * nur der exakte Zeitstempel zaehlt -- dasselbe wie ohne Ausrichtung. Die
569
+ * Messwerte eines Fuehlers werden nach Zeit geordnet (stabil); bei gleichem
570
+ * Zeitstempel gilt der letzte. Die Eingabe bleibt unveraendert.
571
+ *
572
+ * @example
573
+ * // Unten meldet nur bei Aenderung, Oben jede Minute:
574
+ * divergenceExcursions(holdAlign([oben, unten], 10 * 60_000), { maxDelta: 2 });
575
+ */
576
+ declare function holdAlign(sensors: NamedSeries[], maxAgeMs: number): NamedSeries[];
577
+
556
578
  /*!
557
579
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
558
580
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -658,4 +680,4 @@ interface F0Opts {
658
680
  */
659
681
  declare function f0Sterilization(data: DataPoint[], opts?: F0Opts): number;
660
682
 
661
- export { type AggregatedPoint, type AggregationConfig, type AggregationMode, type AggregationThresholds, type ComputeLimitsOpts, DEFAULT_ACTIVATION_ENERGY, type DataPoint, type DivergenceEpisode, type DivergenceOptions, type F0Opts, type HotColdSpotsResult, type LimitExcursion, type LimitStats, type LimitStatsPoint, type LongTermInsight, type MktPoint, type NamedSeries, PRODUCT_PROFILES, type PredictOpts, type PredictResult, type ProductConfig, type ProductType, type SensorStat, SeriesProcessor, type SpatialPoint, type StatsAggregatedPoint, StatsAggregator, type StatsResult, type StdDevPoint, type TrendFit, type TrendPoint, aggregateBySlot, aggregateWithStats, analyzeLongTermTrends, computeLimitExcursions, createAggr, currentTrend, detectGaps, divergenceExcursions, downsample, f0Sterilization, hotColdSpots, linearFit, mkt, predictTimeToThreshold, rollingEma, rollingMean, rollingMkt, rollingStdDev, rollingTrend, sampleStdDev, spatialDelta, stdDev, varianceCoefficient };
683
+ export { type AggregatedPoint, type AggregationConfig, type AggregationMode, type AggregationThresholds, type ComputeLimitsOpts, DEFAULT_ACTIVATION_ENERGY, type DataPoint, type DivergenceEpisode, type DivergenceOptions, type F0Opts, type HotColdSpotsResult, type LimitExcursion, type LimitStats, type LimitStatsPoint, type LongTermInsight, type MktPoint, type NamedSeries, PRODUCT_PROFILES, type PredictOpts, type PredictResult, type ProductConfig, type ProductType, type SensorStat, SeriesProcessor, type SpatialPoint, type StatsAggregatedPoint, StatsAggregator, type StatsResult, type StdDevPoint, type TrendFit, type TrendPoint, aggregateBySlot, aggregateWithStats, analyzeLongTermTrends, computeLimitExcursions, createAggr, currentTrend, detectGaps, divergenceExcursions, downsample, f0Sterilization, holdAlign, hotColdSpots, linearFit, mkt, predictTimeToThreshold, rollingEma, rollingMean, rollingMkt, rollingStdDev, rollingTrend, sampleStdDev, spatialDelta, stdDev, varianceCoefficient };
@@ -1,4 +1,4 @@
1
- var I=class{static interpolateDataPoint(n,i,l){return {time:n.time+Math.round(l*(i.time-n.time)),value:(n.value??0)+l*((i.value??0)-(n.value??0)),synthetic:true}}static interpolateAggregatedPoint(n,i,l){let u=(e,t)=>e!==null&&t!==null?e+l*(t-e):null;return {time:n.time+l*(i.time-n.time),min:u(n.min,i.min),max:u(n.max,i.max),avg:u(n.avg,i.avg),count:Math.round(n.count+l*(i.count-n.count))}}static getRuns(n,i,l=0){let u=[...n].sort((r,o)=>r.time-o.time),e=[],t=[],a=null;for(let r of u){let o=i(r),m=l>0&&a&&r.time-a.time>l;(o||m)&&t.length&&(e.push(t),t=[]),o||t.push(r),a=r;}return t.length&&e.push(t),e}static splitByBoundaries(n,i,l,u){if(n.length===0)return [];if(i.length===0)return [{data:n,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let e=[...i].sort((m,s)=>m-s),t=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:e[m-1],r=m=>{let s=0;for(let f=0;f<e.length&&m>=e[f];f++)s=f+1;return s},o=[n[0]];for(let m=1;m<n.length;m++){let s=n[m-1],f=n[m],g=l(s),d=l(f),p;d>g?p=e.filter(v=>v>g&&v<=d):d<g?p=e.filter(v=>v>=d&&v<g).reverse():p=[];let x=g;for(let v of p){let b=(v-g)/(d-g),h=u(s,f,b);o.push(h);let c=r((x+v)/2);t.push({data:o,zoneIndex:c,zoneLow:a(c)}),o=[h],x=v;}(p.length===0||p[p.length-1]!==d)&&o.push(f);}if(o.length>1||n.length===1){let m=l(o[0]),s=l(o[o.length-1]),f=r((m+s)/2);t.push({data:o,zoneIndex:f,zoneLow:a(f)});}return t}static splitByThreshold(n,i,l,u){let e=this.splitByBoundaries(n,[i],l,u),t={above:[],below:[]};for(let a of e)a.zoneIndex===0?t.below.push(a.data):t.above.push(a.data);return t}},H={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},D=8.314462618,N=273.15;function T(n,i,l,u=1){let e=i.filter(h=>h.value!==null&&h.value!==void 0&&!Number.isNaN(h.value)).map(h=>h.value);if(!e.length)return {time:n,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:l?0:null,minutesBelowLow:l?0:null,count:0};let t=1/0,a=-1/0,r=0;for(let h of e)h<t&&(t=h),h>a&&(a=h),r+=h;let o=r/e.length,m=l?0:null,s=l?0:null;if(l)for(let h=0;h<i.length;h++){let c=i[h];if(c.value!==null&&c.value!==void 0){let M=i[h+1],w=(M?M.time-c.time:0)/(1e3*60);c.value>l.limitHigh&&(m+=w),c.value<l.limitLow&&(s+=w);}}let f=0,g=0,d=(l?.activationEnergy??83144)/D;for(let h of e){f+=Math.pow(h-o,2);let c=h+N;g+=Math.exp(-d/c);}let p=f/e.length,x=Math.sqrt(p),v=null,b=null;if(e.length>=u){let h=g/e.length,c=d/-Math.log(h);v=Number((c-N).toFixed(2)),b=Number((v-o).toFixed(2));}return {time:n,min:Number(t.toFixed(2)),max:Number(a.toFixed(2)),avg:Number(o.toFixed(2)),mkt:v,deltaMkt:b,stdDev:Number(x.toFixed(2)),minutesAboveHigh:m!==null?Number(m.toFixed(1)):null,minutesBelowLow:s!==null?Number(s.toFixed(1)):null,count:e.length}}function S(n,i="hourly",l,u,e=1){if(!n.length)return [];let t=i==="hourly"?36e5:i==="daily"?864e5:l??3600*1e3,a=[...n].sort((s,f)=>s.time-f.time),r=[],o=a[0].time,m=[];for(let s of a){for(;s.time-o>=t;)r.push(T(o,m,u,e)),o+=t,m=[];m.push(s);}return r.push(T(o,m,u,e)),r}function z(n,i){let l=1/0,u=-1/0,e=0;for(let a of i)a<l&&(l=a),a>u&&(u=a),e+=a;let t=e/i.length;return {time:n,min:l,max:u,avg:t,count:i.length}}function B(n,i=6e4){if(n.length<2)return [];let l=[...n].sort((e,t)=>e.time-t.time),u=[];for(let e=1;e<l.length;e++)l[e].time-l[e-1].time>i&&u.push({startTime:l[e-1].time,endTime:l[e].time});return u}function _(n){let i=[],l=0,u=0,e=0,t=0;for(let a of n)a.count>0&&(e++,a.minutesAboveHigh&&(l+=a.minutesAboveHigh),a.stdDev&&a.stdDev>u&&(u=a.stdDev),a.deltaMkt&&a.deltaMkt>2&&t++);return e===0?[]:(l>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(l)} Minuten zu warm.`,metric:"Total Excursion Time"}),t>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),u>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${u}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function C(n,i){if(n.length<=i)return n;let l=[],u=Math.ceil(n.length/i);l.push(n[0]);for(let e=1;e<n.length;e+=u)l.push(n[Math.min(e,n.length-1)]);return l}function P(n,i="hourly",l){let u={limitLow:l.low,limitHigh:l.high,activationEnergy:l.activationEnergy};return S(n,i,l.interval,u,l.minCountForMkt??1)}var q=class{static compute(n){let i=n.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let l=i.length,u=i.reduce((r,o)=>r+o,0)/l,e=l%2===1?i[Math.floor(l/2)]:(i[l/2-1]+i[l/2])/2,t=i.reduce((r,o)=>r+Math.pow(o-u,2),0)/l,a=Math.sqrt(t);return {min:i[0],max:i[l-1],avg:u,mean:u,median:e,stdDev:a,count:l}}static computeInRange(n,i,l){let u=n.filter(e=>e.time>=i&&e.time<=l);return this.compute(u)}};function G(n,i){let l=typeof n=="number"?n:n.mean,u=typeof n=="number"?i??NaN:n.stdDev;return !Number.isFinite(l)||!Number.isFinite(u)||l===0?null:Math.abs(u/l)*100}var R=83144;function k(n,i=83144){let l=i/8.314,u=0,e=0;for(let a of n)a!==null&&(u+=Math.exp(-l/(a+273.15)),e++);if(e===0)return null;let t=u/e;return l/-Math.log(t)-273.15}function V(n,i,l=83144){let u=new Array(n.length),e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=a-i;for(;e<t&&n[e].time<r;)e++;let o=n.slice(e,t+1).map(s=>s.value),m=k(o,l);u[t]={time:a,value:m,synthetic:true};}return u}function A(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l===0)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/l)}function E(n){let i=0,l=0;for(let t of n)t!==null&&(i+=t,l++);if(l<2)return null;let u=i/l,e=0;for(let t of n){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/(l-1))}function K(n,i,l=false){let u=new Array(n.length),e=0,t=l?E:A;for(let a=0;a<n.length;a++){let r=n[a].time,o=r-i;for(;e<a&&n[e].time<o;)e++;let m=n.slice(e,a+1).map(f=>f.value),s=t(m);u[a]={time:r,value:s,synthetic:true};}return u}function O(n,i){let l=new Array(n.length),u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<e&&n[u].time<a;)u++;let r=0,o=0;for(let m=u;m<=e;m++){let s=n[m].value;s!==null&&(r+=s,o++);}l[e]={time:t,value:o===0?null:r/o,synthetic:true};}return l}function U(n,i){let l=new Array(n.length),u=null,e=0;for(let t=0;t<n.length;t++){let a=n[t].time,r=n[t].value;if(r===null){l[t]={time:a,value:u,synthetic:true};continue}if(u===null||i<=0)u=r;else {let o=1-Math.exp(-(a-e)/i);u=r*o+u*(1-o);}e=a,l[t]={time:a,value:u,synthetic:true};}return l}function Y(n,i){let{high:l,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},t=null;for(let a=0;a<n.length;a++){let r=n[a];if(r.value===null){t&&(e.excursions.push(t),t=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=l!==void 0&&r.value>l,m=u!==void 0&&r.value<u,s=o?"above":m?"below":null,f=n[a-1];if(f&&f.value!==null&&s!==null){let g=r.time-f.time;s==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(s===null){t&&(e.excursions.push(t),t=null);continue}t&&t.side===s?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,(s==="above"&&r.value>t.extremum||s==="below"&&r.value<t.extremum)&&(t.extremum=r.value)):(t&&e.excursions.push(t),t={startTime:r.time,endTime:r.time,side:s,extremum:r.value,durationMs:0});}return t&&e.excursions.push(t),e}function L(n){if(n.length===0)return [];let i=new Map;for(let u of n)for(let e of u.data){if(e.value===null)continue;let t=i.get(e.time);t||(t=[],i.set(e.time,t)),t.push({name:u.name,value:e.value});}let l=[];for(let u of [...i.keys()].sort((e,t)=>e-t)){let e=i.get(u);if(e.length===0){l.push({time:u,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let t=e[0],a=e[0];for(let r=1;r<e.length;r++)e[r].value<t.value&&(t=e[r]),e[r].value>a.value&&(a=e[r]);l.push({time:u,min:t.value,max:a.value,delta:e.length<2?null:a.value-t.value,minSensor:t.name,maxSensor:a.name});}return l}function $(n){let i=[];for(let e of n){let t=0,a=0,r=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(t+=m.value,a++,m.value<r&&(r=m.value),m.value>o&&(o=m.value));a!==0&&i.push({name:e.name,mean:t/a,min:r,max:o,count:a});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let l=i[0],u=i[0];for(let e=1;e<i.length;e++)i[e].mean>l.mean&&(l=i[e]),i[e].mean<u.mean&&(u=i[e]);return {sensors:i,hottest:l,coldest:u,meanDelta:l.mean-u.mean}}function W(n,i){let{maxDelta:l,minDurationMs:u=0}=i,e=[],t=null,a=()=>{t&&t.durationMs>=u&&e.push(t),t=null;};for(let r of L(n)){if(r.delta===null||r.delta<=l){a();continue}t?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,r.delta>t.peakDelta&&(t.peakDelta=r.delta,t.peakTime=r.time,t.maxSensor=r.maxSensor,t.minSensor=r.minSensor)):t={startTime:r.time,endTime:r.time,durationMs:0,peakDelta:r.delta,peakTime:r.time,maxSensor:r.maxSensor,minSensor:r.minSensor};}return a(),e}function y(n){let i=0,l=0,u=0,e=0,t=0;for(let m of n)m.value!==null&&(i++,l+=m.time,u+=m.value,e+=m.time*m.value,t+=m.time*m.time);if(i<2)return null;let a=i*t-l*l;if(a===0)return null;let r=(i*e-l*u)/a,o=(u-r*l)/i;return {slope:r,intercept:o,n:i}}function F(n,i){if(n.length===0)return null;let l=n[n.length-1].time,u=l-i,e=n.filter(t=>t.time>=u&&t.time<=l);return y(e)}function Z(n,i){let l=[],u=0;for(let e=0;e<n.length;e++){let t=n[e].time,a=t-i;for(;u<n.length&&n[u].time<a;)u++;let r=y(n.slice(u,e+1));l.push({time:t,fit:r});}return l}function j(n,i,l={}){let u=l.lookbackMs??9e5,e=l.side??"either";if(n.length===0)return null;let t=n[n.length-1];if(t.value===null)return null;let a=F(n,u);if(!a||a.slope===0)return null;let r=a.slope>0&&t.value<i,o=a.slope<0&&t.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let m=(i-a.intercept)/a.slope,s=m-t.time;return s<=0?null:{msUntil:s,eta:m,fit:a,currentValue:t.value}}function J(n,i={}){let l=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let t=0;t<n.length-1;t++){let a=n[t],r=n[t+1];if(a.value===null||r.value===null)continue;let o=(r.time-a.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(a.value-l)/u),s=Math.pow(10,(r.value-l)/u);e+=(m+s)/2*o;}return e}/*!
1
+ var I=class{static interpolateDataPoint(l,i,n){return {time:l.time+Math.round(n*(i.time-l.time)),value:(l.value??0)+n*((i.value??0)-(l.value??0)),synthetic:true}}static interpolateAggregatedPoint(l,i,n){let u=(e,t)=>e!==null&&t!==null?e+n*(t-e):null;return {time:l.time+n*(i.time-l.time),min:u(l.min,i.min),max:u(l.max,i.max),avg:u(l.avg,i.avg),count:Math.round(l.count+n*(i.count-l.count))}}static getRuns(l,i,n=0){let u=[...l].sort((r,o)=>r.time-o.time),e=[],t=[],a=null;for(let r of u){let o=i(r),m=n>0&&a&&r.time-a.time>n;(o||m)&&t.length&&(e.push(t),t=[]),o||t.push(r),a=r;}return t.length&&e.push(t),e}static splitByBoundaries(l,i,n,u){if(l.length===0)return [];if(i.length===0)return [{data:l,zoneIndex:0,zoneLow:Number.NEGATIVE_INFINITY}];let e=[...i].sort((m,s)=>m-s),t=[],a=m=>m<=0?Number.NEGATIVE_INFINITY:e[m-1],r=m=>{let s=0;for(let h=0;h<e.length&&m>=e[h];h++)s=h+1;return s},o=[l[0]];for(let m=1;m<l.length;m++){let s=l[m-1],h=l[m],g=n(s),d=n(h),p;d>g?p=e.filter(v=>v>g&&v<=d):d<g?p=e.filter(v=>v>=d&&v<g).reverse():p=[];let x=g;for(let v of p){let b=(v-g)/(d-g),f=u(s,h,b);o.push(f);let c=r((x+v)/2);t.push({data:o,zoneIndex:c,zoneLow:a(c)}),o=[f],x=v;}(p.length===0||p[p.length-1]!==d)&&o.push(h);}if(o.length>1||l.length===1){let m=n(o[0]),s=n(o[o.length-1]),h=r((m+s)/2);t.push({data:o,zoneIndex:h,zoneLow:a(h)});}return t}static splitByThreshold(l,i,n,u){let e=this.splitByBoundaries(l,[i],n,u),t={above:[],below:[]};for(let a of e)a.zoneIndex===0?t.below.push(a.data):t.above.push(a.data);return t}},H={pharma_cold:{limitLow:2,limitHigh:8,activationEnergy:83144},pharma_ambient:{limitLow:15,limitHigh:25,activationEnergy:83144},blood:{limitLow:2,limitHigh:6,activationEnergy:83144},food_chilled:{limitLow:0,limitHigh:4},frozen:{limitLow:-40,limitHigh:-18}},D=8.314462618,N=273.15;function T(l,i,n,u=1){let e=i.filter(f=>f.value!==null&&f.value!==void 0&&!Number.isNaN(f.value)).map(f=>f.value);if(!e.length)return {time:l,min:null,max:null,avg:null,mkt:null,deltaMkt:null,stdDev:null,minutesAboveHigh:n?0:null,minutesBelowLow:n?0:null,count:0};let t=1/0,a=-1/0,r=0;for(let f of e)f<t&&(t=f),f>a&&(a=f),r+=f;let o=r/e.length,m=n?0:null,s=n?0:null;if(n)for(let f=0;f<i.length;f++){let c=i[f];if(c.value!==null&&c.value!==void 0){let M=i[f+1],w=(M?M.time-c.time:0)/(1e3*60);c.value>n.limitHigh&&(m+=w),c.value<n.limitLow&&(s+=w);}}let h=0,g=0,d=(n?.activationEnergy??83144)/D;for(let f of e){h+=Math.pow(f-o,2);let c=f+N;g+=Math.exp(-d/c);}let p=h/e.length,x=Math.sqrt(p),v=null,b=null;if(e.length>=u){let f=g/e.length,c=d/-Math.log(f);v=Number((c-N).toFixed(2)),b=Number((v-o).toFixed(2));}return {time:l,min:Number(t.toFixed(2)),max:Number(a.toFixed(2)),avg:Number(o.toFixed(2)),mkt:v,deltaMkt:b,stdDev:Number(x.toFixed(2)),minutesAboveHigh:m!==null?Number(m.toFixed(1)):null,minutesBelowLow:s!==null?Number(s.toFixed(1)):null,count:e.length}}function S(l,i="hourly",n,u,e=1){if(!l.length)return [];let t=i==="hourly"?36e5:i==="daily"?864e5:n??3600*1e3,a=[...l].sort((s,h)=>s.time-h.time),r=[],o=a[0].time,m=[];for(let s of a){for(;s.time-o>=t;)r.push(T(o,m,u,e)),o+=t,m=[];m.push(s);}return r.push(T(o,m,u,e)),r}function z(l,i){let n=1/0,u=-1/0,e=0;for(let a of i)a<n&&(n=a),a>u&&(u=a),e+=a;let t=e/i.length;return {time:l,min:n,max:u,avg:t,count:i.length}}function B(l,i=6e4){if(l.length<2)return [];let n=[...l].sort((e,t)=>e.time-t.time),u=[];for(let e=1;e<n.length;e++)n[e].time-n[e-1].time>i&&u.push({startTime:n[e-1].time,endTime:n[e].time});return u}function _(l){let i=[],n=0,u=0,e=0,t=0;for(let a of l)a.count>0&&(e++,a.minutesAboveHigh&&(n+=a.minutesAboveHigh),a.stdDev&&a.stdDev>u&&(u=a.stdDev),a.deltaMkt&&a.deltaMkt>2&&t++);return e===0?[]:(n>120&&i.push({type:"critical",message:`Kritische Gesamtbelastung: Das Produkt war im gesamten Zeitraum insgesamt ${Math.round(n)} Minuten zu warm.`,metric:"Total Excursion Time"}),t>e*.15&&i.push({type:"warning",message:"Frequent thermal shocks detected. The kinetic temperature deviates strongly from the average (possible regular door openings).",metric:"Delta MKT Instability"}),u>4&&i.push({type:"warning",message:`High instability measured. Maximum standard deviation was ${u}\xB0C. The cooling system controls imprecisely.`,metric:"Standard Deviation Peak"}),i)}function C(l,i){if(l.length<=i)return l;let n=[],u=Math.ceil(l.length/i);n.push(l[0]);for(let e=1;e<l.length;e+=u)n.push(l[Math.min(e,l.length-1)]);return n}function P(l,i="hourly",n){let u={limitLow:n.low,limitHigh:n.high,activationEnergy:n.activationEnergy};return S(l,i,n.interval,u,n.minCountForMkt??1)}var q=class{static compute(l){let i=l.map(r=>r.value).filter(r=>r!==null).sort((r,o)=>r-o);if(i.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let n=i.length,u=i.reduce((r,o)=>r+o,0)/n,e=n%2===1?i[Math.floor(n/2)]:(i[n/2-1]+i[n/2])/2,t=i.reduce((r,o)=>r+Math.pow(o-u,2),0)/n,a=Math.sqrt(t);return {min:i[0],max:i[n-1],avg:u,mean:u,median:e,stdDev:a,count:n}}static computeInRange(l,i,n){let u=l.filter(e=>e.time>=i&&e.time<=n);return this.compute(u)}};function G(l,i){let n=typeof l=="number"?l:l.mean,u=typeof l=="number"?i??NaN:l.stdDev;return !Number.isFinite(n)||!Number.isFinite(u)||n===0?null:Math.abs(u/n)*100}var R=83144;function k(l,i=83144){let n=i/8.314,u=0,e=0;for(let a of l)a!==null&&(u+=Math.exp(-n/(a+273.15)),e++);if(e===0)return null;let t=u/e;return n/-Math.log(t)-273.15}function V(l,i,n=83144){let u=new Array(l.length),e=0;for(let t=0;t<l.length;t++){let a=l[t].time,r=a-i;for(;e<t&&l[e].time<r;)e++;let o=l.slice(e,t+1).map(s=>s.value),m=k(o,n);u[t]={time:a,value:m,synthetic:true};}return u}function A(l){let i=0,n=0;for(let t of l)t!==null&&(i+=t,n++);if(n===0)return null;let u=i/n,e=0;for(let t of l){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/n)}function E(l){let i=0,n=0;for(let t of l)t!==null&&(i+=t,n++);if(n<2)return null;let u=i/n,e=0;for(let t of l){if(t===null)continue;let a=t-u;e+=a*a;}return Math.sqrt(e/(n-1))}function K(l,i,n=false){let u=new Array(l.length),e=0,t=n?E:A;for(let a=0;a<l.length;a++){let r=l[a].time,o=r-i;for(;e<a&&l[e].time<o;)e++;let m=l.slice(e,a+1).map(h=>h.value),s=t(m);u[a]={time:r,value:s,synthetic:true};}return u}function O(l,i){let n=new Array(l.length),u=0;for(let e=0;e<l.length;e++){let t=l[e].time,a=t-i;for(;u<e&&l[u].time<a;)u++;let r=0,o=0;for(let m=u;m<=e;m++){let s=l[m].value;s!==null&&(r+=s,o++);}n[e]={time:t,value:o===0?null:r/o,synthetic:true};}return n}function U(l,i){let n=new Array(l.length),u=null,e=0;for(let t=0;t<l.length;t++){let a=l[t].time,r=l[t].value;if(r===null){n[t]={time:a,value:u,synthetic:true};continue}if(u===null||i<=0)u=r;else {let o=1-Math.exp(-(a-e)/i);u=r*o+u*(1-o);}e=a,n[t]={time:a,value:u,synthetic:true};}return n}function Y(l,i){let{high:n,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},t=null;for(let a=0;a<l.length;a++){let r=l[a];if(r.value===null){t&&(e.excursions.push(t),t=null);continue}(e.globalMax===null||r.value>e.globalMax)&&(e.globalMax=r.value),(e.globalMin===null||r.value<e.globalMin)&&(e.globalMin=r.value);let o=n!==void 0&&r.value>n,m=u!==void 0&&r.value<u,s=o?"above":m?"below":null,h=l[a-1];if(h&&h.value!==null&&s!==null){let g=r.time-h.time;s==="above"?e.msAboveHigh+=g:e.msBelowLow+=g;}if(s===null){t&&(e.excursions.push(t),t=null);continue}t&&t.side===s?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,(s==="above"&&r.value>t.extremum||s==="below"&&r.value<t.extremum)&&(t.extremum=r.value)):(t&&e.excursions.push(t),t={startTime:r.time,endTime:r.time,side:s,extremum:r.value,durationMs:0});}return t&&e.excursions.push(t),e}function L(l){if(l.length===0)return [];let i=new Map;for(let u of l)for(let e of u.data){if(e.value===null)continue;let t=i.get(e.time);t||(t=[],i.set(e.time,t)),t.push({name:u.name,value:e.value});}let n=[];for(let u of [...i.keys()].sort((e,t)=>e-t)){let e=i.get(u);if(e.length===0){n.push({time:u,min:null,max:null,delta:null,minSensor:null,maxSensor:null});continue}let t=e[0],a=e[0];for(let r=1;r<e.length;r++)e[r].value<t.value&&(t=e[r]),e[r].value>a.value&&(a=e[r]);n.push({time:u,min:t.value,max:a.value,delta:e.length<2?null:a.value-t.value,minSensor:t.name,maxSensor:a.name});}return n}function $(l){let i=[];for(let e of l){let t=0,a=0,r=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(t+=m.value,a++,m.value<r&&(r=m.value),m.value>o&&(o=m.value));a!==0&&i.push({name:e.name,mean:t/a,min:r,max:o,count:a});}if(i.length===0)return {sensors:[],hottest:null,coldest:null,meanDelta:null};let n=i[0],u=i[0];for(let e=1;e<i.length;e++)i[e].mean>n.mean&&(n=i[e]),i[e].mean<u.mean&&(u=i[e]);return {sensors:i,hottest:n,coldest:u,meanDelta:n.mean-u.mean}}function W(l,i){let{maxDelta:n,minDurationMs:u=0}=i,e=[],t=null,a=()=>{t&&t.durationMs>=u&&e.push(t),t=null;};for(let r of L(l)){if(r.delta===null||r.delta<=n){a();continue}t?(t.endTime=r.time,t.durationMs=t.endTime-t.startTime,r.delta>t.peakDelta&&(t.peakDelta=r.delta,t.peakTime=r.time,t.maxSensor=r.maxSensor,t.minSensor=r.minSensor)):t={startTime:r.time,endTime:r.time,durationMs:0,peakDelta:r.delta,peakTime:r.time,maxSensor:r.maxSensor,minSensor:r.minSensor};}return a(),e}function Z(l,i){let n=i>0?i:0,u=new Set,e=l.map(a=>{let r=[...a.data].sort((o,m)=>o.time-m.time);for(let o of r)u.add(o.time);return r}),t=[...u].sort((a,r)=>a-r);return l.map((a,r)=>{let o=e[r],m=-1,s=t.map(h=>{for(;m+1<o.length&&o[m+1].time<=h;)m++;let g=m>=0?o[m]:void 0,d=g&&g.value!==null&&h-g.time<=n?g.value:null;return {time:h,value:d}});return {name:a.name,data:s}})}function y(l){let i=0,n=0,u=0,e=0,t=0;for(let m of l)m.value!==null&&(i++,n+=m.time,u+=m.value,e+=m.time*m.value,t+=m.time*m.time);if(i<2)return null;let a=i*t-n*n;if(a===0)return null;let r=(i*e-n*u)/a,o=(u-r*n)/i;return {slope:r,intercept:o,n:i}}function F(l,i){if(l.length===0)return null;let n=l[l.length-1].time,u=n-i,e=l.filter(t=>t.time>=u&&t.time<=n);return y(e)}function j(l,i){let n=[],u=0;for(let e=0;e<l.length;e++){let t=l[e].time,a=t-i;for(;u<l.length&&l[u].time<a;)u++;let r=y(l.slice(u,e+1));n.push({time:t,fit:r});}return n}function J(l,i,n={}){let u=n.lookbackMs??9e5,e=n.side??"either";if(l.length===0)return null;let t=l[l.length-1];if(t.value===null)return null;let a=F(l,u);if(!a||a.slope===0)return null;let r=a.slope>0&&t.value<i,o=a.slope<0&&t.value>i;if(e==="above"&&!r||e==="below"&&!o||e==="either"&&!r&&!o)return null;let m=(i-a.intercept)/a.slope,s=m-t.time;return s<=0?null:{msUntil:s,eta:m,fit:a,currentValue:t.value}}function Q(l,i={}){let n=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let t=0;t<l.length-1;t++){let a=l[t],r=l[t+1];if(a.value===null||r.value===null)continue;let o=(r.time-a.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(a.value-n)/u),s=Math.pow(10,(r.value-n)/u);e+=(m+s)/2*o;}return e}/*!
2
2
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
3
3
  * MIT with Attribution: free use incl. commercial requires visible credit to
4
4
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
@@ -12,4 +12,4 @@ var I=class{static interpolateDataPoint(n,i,l){return {time:n.time+Math.round(l*
12
12
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
13
13
  * MIT with Attribution: free use incl. commercial requires visible credit to
14
14
  * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
15
- */export{R as DEFAULT_ACTIVATION_ENERGY,H as PRODUCT_PROFILES,I as SeriesProcessor,q as StatsAggregator,S as aggregateBySlot,P as aggregateWithStats,_ as analyzeLongTermTrends,Y as computeLimitExcursions,z as createAggr,F as currentTrend,B as detectGaps,W as divergenceExcursions,C as downsample,J as f0Sterilization,$ as hotColdSpots,y as linearFit,k as mkt,j as predictTimeToThreshold,U as rollingEma,O as rollingMean,V as rollingMkt,K as rollingStdDev,Z as rollingTrend,E as sampleStdDev,L as spatialDelta,A as stdDev,G as varianceCoefficient};
15
+ */export{R as DEFAULT_ACTIVATION_ENERGY,H as PRODUCT_PROFILES,I as SeriesProcessor,q as StatsAggregator,S as aggregateBySlot,P as aggregateWithStats,_ as analyzeLongTermTrends,Y as computeLimitExcursions,z as createAggr,F as currentTrend,B as detectGaps,W as divergenceExcursions,C as downsample,Q as f0Sterilization,Z as holdAlign,$ as hotColdSpots,y as linearFit,k as mkt,J as predictTimeToThreshold,U as rollingEma,O as rollingMean,V as rollingMkt,K as rollingStdDev,j as rollingTrend,E as sampleStdDev,L as spatialDelta,A as stdDev,G as varianceCoefficient};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,44 @@
1
- import { M as MLTimeGraphOptions, L as LegendItem, R as Renderer, a as LayoutResult, b as Margin, A as AxesConfig, X as XAxisConfig, Y as YAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-D5TfGx8R.js';
2
- export { h as AxisLabelsStyle, i as AxisStyle, G as GridLineStyle, j as GridStyle, T as TextMetrics, k as Theme, l as TickConfig, m as drawMarker, n as estimateMetrics, o as getDefaultTheme, p as liberationMetrics, r as resetDefaultTheme, s as setDefaultTheme, q as slugify } from './marker_renderer-D5TfGx8R.js';
3
- import { d as AnySeries, h as Annotation, a as DrawCommand, T as TimeScale, L as LinearScale, f as Gap, g as GapsConfig, e as Threshold, H as Highlight, i as AnnotationBandConfig, k as SeriesStyle, b as LineVariant, S as SmoothingType, F as FillSpec, l as TimeSeries, m as LineDashStyle, n as ThresholdFill, j as HatchVariant, o as ThresholdLabelPosition, P as PointStyleType, M as MarkerLineStyle, R as RangeLabelPosition, p as AnnotationPointShape, q as LabelAnchor, r as AnnotationBandItem, s as TextBaseline, t as AggregatedPoint, u as AggregatedSeries, D as DataPoint } from './scale-BStQU_t-.js';
4
- export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationKind, z as AxisOrientation, A as AxisPosition, B as DataPointRef, E as EnumMap, C as FillBound, I as FillRegion, J as FillSide, K as FillStyle, N as GapConfig, O as GapLabel, Q as GapRegion, U as GapStyle, G as GridLayer, V as LineShape, W as LineStyle, X as MarkerStyle, Y as MovingAverageType, Z as SVGLineStyle, _ as SensorType, $ as SeriesOverlay, a0 as SeriesOverlayKind, a1 as SeriesType, a2 as ShadowStyle, a3 as SolidDashStyle, a4 as ThresholdLabelConfig, a5 as getLineStyle, a6 as resolveDash } from './scale-BStQU_t-.js';
1
+ import { M as MLTimeGraphOptions, L as LegendItem, R as Renderer, a as LayoutResult, b as Margin, A as AxesConfig, X as XAxisConfig, Y as YAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-C5rNViFi.js';
2
+ export { h as AxisLabelsStyle, i as AxisStyle, G as GridLineStyle, j as GridStyle, T as TextMetrics, k as Theme, l as TickConfig, m as drawMarker, n as estimateMetrics, o as getDefaultTheme, p as liberationMetrics, r as resetDefaultTheme, s as setDefaultTheme, q as slugify } from './marker_renderer-C5rNViFi.js';
3
+ import { d as AnySeries, h as Annotation, a as DrawCommand, T as TimeScale, L as LinearScale, f as Gap, g as GapsConfig, e as Threshold, H as Highlight, i as AnnotationBandConfig, k as SeriesStyle, b as LineVariant, S as SmoothingType, F as FillSpec, l as TimeSeries, m as LineDashStyle, n as ThresholdFill, j as HatchVariant, o as ThresholdLabelPosition, P as PointStyleType, M as MarkerLineStyle, R as RangeLabelPosition, p as AnnotationPointShape, q as LabelAnchor, r as AnnotationBandItem, s as TextBaseline, t as AggregatedPoint, u as AggregatedSeries, D as DataPoint } from './scale-CDPJGYpZ.js';
4
+ export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationKind, z as AxisOrientation, A as AxisPosition, B as DataPointRef, E as EnumMap, C as FillBound, I as FillRegion, J as FillSide, K as FillStyle, N as GapConfig, O as GapLabel, Q as GapRegion, U as GapStyle, G as GridLayer, V as LineShape, W as LineStyle, X as MarkerStyle, Y as MovingAverageType, Z as SVGLineStyle, _ as SensorType, $ as SeriesOverlay, a0 as SeriesOverlayKind, a1 as SeriesType, a2 as ShadowStyle, a3 as SolidDashStyle, a4 as ThresholdLabelConfig, a5 as getLineStyle, a6 as resolveDash } from './scale-CDPJGYpZ.js';
5
+
6
+ /*!
7
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
8
+ * MIT with Attribution: free use incl. commercial requires visible credit to
9
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
10
+ */
11
+
12
+ /** One series' point under the pointer. */
13
+ interface PointAt {
14
+ /** The series' `id`, or its `name` when it has none -- the key for `hidden`. */
15
+ seriesId: string;
16
+ name: string;
17
+ axisIndex: number;
18
+ /** Time of the point (ms). */
19
+ time: number;
20
+ /** The measured value -- raw series only. */
21
+ value?: number;
22
+ /** The bucket of an aggregated series -- never a made-up single value. */
23
+ min?: number;
24
+ max?: number;
25
+ avg?: number;
26
+ count?: number;
27
+ /** Screen position in SVG pixels; for a bucket, `y` is its average. */
28
+ x: number;
29
+ y: number;
30
+ /** Distance to the pointer in pixels; for a bucket, to its min..max band. */
31
+ distance: number;
32
+ }
33
+ interface PointsAtOptions {
34
+ /**
35
+ * How far (horizontally, in pixels) a point may lie from the pointer.
36
+ * Default: the theme's `tooltipSnapRadius` (20).
37
+ */
38
+ radius?: number;
39
+ /** Series ids (see {@link PointAt.seriesId}) the user has hidden. */
40
+ hidden?: Iterable<string>;
41
+ }
5
42
 
6
43
  /*!
7
44
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
@@ -65,12 +102,32 @@ declare class MLTimeGraph {
65
102
  enableAnnotation(id: string): void;
66
103
  private _axisIndexOf;
67
104
  private _timesOf;
68
- private _valuesOf;
105
+ /**
106
+ * Das Layout, mit dem tatsaechlich gezeichnet wird, samt der aufgeloesten
107
+ * Legende.
108
+ *
109
+ * Eine Legende ausserhalb der Zeichenflaeche verschiebt die Raender; die
110
+ * Skalen werden aus DIESEM Layout gebaut. Bis 07.10.2026 rechnete nur
111
+ * renderCommands es aus, und der Getter `layout` lieferte das aus dem
112
+ * Konstruktor -- wer daraus eine Mausposition in Zeit umrechnete
113
+ * (Brush-Zoom), lag um die Legendenbreite daneben (B-20261007-04). Eine
114
+ * Stelle fuer beide, damit sie nicht wieder auseinanderlaufen.
115
+ */
116
+ private _layoutMitLegende;
69
117
  /**
70
118
  * Compute the chart's renderer-agnostic draw commands.
71
119
  */
72
120
  renderCommands(): DrawCommand[];
73
121
  /** Build the draw commands for a single series based on its type. */
122
+ /**
123
+ * Wie die Linie einer skalaren Reihe gezeichnet wird: ihr Grund-Eintrag,
124
+ * ihre Form und die Lueckenschwelle, nach der sie bricht.
125
+ *
126
+ * Eine Stelle, weil zwei sie brauchen: das Zeichnen der Reihe selbst, und
127
+ * eine Flaeche in einer ANDEREN Reihe, die bis an diese Linie reicht -- sie
128
+ * muss deren Kurve treffen, nicht eine aehnliche (B-20261007-02).
129
+ */
130
+ private _linienGrundlage;
74
131
  private _renderSeries;
75
132
  private _interpolateValue;
76
133
  legendItems(): LegendItem[];
@@ -87,29 +144,39 @@ declare class MLTimeGraph {
87
144
  * keine Vorlage zeigt, prueft nichts (edge_serien_ohne_farbe).
88
145
  */
89
146
  private _palettenFarbe;
147
+ private _legendItems;
148
+ get renderer(): Renderer | undefined;
90
149
  /**
91
- * Die Zustaende der Reihen an EINER Achse, aufsteigend -- oder undefined,
92
- * wenn keine Reihe dort eine `enumMap` hat.
93
- *
94
- * Mehrere Reihen auf derselben Achse duerfen verschiedene Karten mitbringen;
95
- * zusammengelegt wird die Vereinigung, damit kein Zustand ohne Strich bleibt.
150
+ * The layout the chart is drawn with -- margins included that an outside
151
+ * legend reserves. Matches the scales, so `invertTime(layout.chartX)` is the
152
+ * start of the time domain.
96
153
  */
97
- private _zustaendeVon;
154
+ get layout(): LayoutResult;
98
155
  /**
99
- * Beschriftung eines Zustands; unbekannte Werte behalten ihre Zahl.
100
- *
101
- * Nennen zwei Reihen denselben Wert verschieden -- eine Pumpe "Running", ein
102
- * Ventil "Open" --, gewinnt die ERSTE. Das ist keine Loesung des Konflikts,
103
- * sondern eine feste Regel dafuer: eine Achse hat EIN Vokabular, und wer zwei
104
- * braucht, braucht zwei Achsen. Vorher gewann die zuletzt genannte Reihe, und
105
- * die Achse trug eine Mischung aus beiden.
156
+ * The plot area in SVG pixels: where the series are drawn and what the
157
+ * scales map onto. Use it to turn a pointer position into time and value
158
+ * (with `invertTime` / `invertValue`) or to place an overlay.
106
159
  */
107
- private _zustandName;
108
- private _legendItems;
109
- get renderer(): Renderer | undefined;
110
- get layout(): LayoutResult;
160
+ get plotRect(): {
161
+ x: number;
162
+ y: number;
163
+ width: number;
164
+ height: number;
165
+ };
111
166
  get timeScale(): TimeScale | undefined;
112
167
  get valueScales(): Map<number, LinearScale>;
168
+ /**
169
+ * The points under the pointer at (x, y), in SVG pixels -- for a tooltip
170
+ * that gets data instead of HTML. Valid after `renderCommands()`, like
171
+ * `invertTime`.
172
+ *
173
+ * Per visible series at most one: the point nearest in TIME, within
174
+ * `radius` pixels horizontally. Gaps, synthetic points and hidden series do
175
+ * not count; an aggregated series gives its bucket (min/max/avg), not a
176
+ * made-up single value. Sorted by distance to the pointer. Outside the plot
177
+ * area there is nothing. Same rules in the Go port (`PointsAt`).
178
+ */
179
+ pointsAt(x: number, y: number, options?: PointsAtOptions): PointAt[];
113
180
  invertTime(x: number): number;
114
181
  invertValue(y: number, axisIndex?: number): number;
115
182
  project(time: number, value: number, axisIndex?: number): {
@@ -118,6 +185,34 @@ declare class MLTimeGraph {
118
185
  };
119
186
  }
120
187
 
188
+ /*!
189
+ * MLTimeGraph — Copyright (c) 2026 Michael Lechner
190
+ * MIT with Attribution: free use incl. commercial requires visible credit to
191
+ * "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
192
+ */
193
+
194
+ interface AutoMarginOptions {
195
+ /** Air between the outermost element and the canvas edge, in px. Default (and 0): 4. */
196
+ padding?: number;
197
+ /** No side gets less than this, in px. Default (and 0): 8. */
198
+ minimum?: number;
199
+ }
200
+ /**
201
+ * Raender, die zu dem passen, was das Diagramm tatsaechlich zeichnet: Achsen-
202
+ * beschriftungen, Achsentitel, aussenliegende Grenzwert-Beschriftungen.
203
+ * Gemessen an den Zeichenbefehlen, mit den Textmetriken der Optionen (Vorgabe
204
+ * `liberationMetrics`) -- ohne DOM.
205
+ *
206
+ * Use the result as `margin`, once per change of the options:
207
+ *
208
+ * ```ts
209
+ * const chart = new MLTimeGraph({ ...options, margin: autoMargin(options) });
210
+ * ```
211
+ *
212
+ * A legend outside the plot reserves its own room on top, as before.
213
+ */
214
+ declare function autoMargin(options: MLTimeGraphOptions, opts?: AutoMarginOptions): Margin;
215
+
121
216
  /*!
122
217
  * MLTimeGraph — Copyright (c) 2026 Michael Lechner
123
218
  * MIT with Attribution: free use incl. commercial requires visible credit to
@@ -611,7 +706,7 @@ declare class SVGRenderer extends Renderer {
611
706
  render(commands: DrawCommand[]): RenderOutput;
612
707
  _toSVG(cmd: DrawCommand): string;
613
708
  /** Register or retrieve a hatch pattern by variant. Returns the pattern id for use as fill="url(#id)". */
614
- _hatchPattern(variant: string, fillColor: string | undefined): string;
709
+ _hatchPattern(variant: HatchVariant, fillColor: string | undefined): string;
615
710
  _path(c: Extract<DrawCommand, {
616
711
  type: "path";
617
712
  }>): string;
@@ -862,6 +957,6 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
862
957
  * Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
863
958
  * kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
864
959
  */
865
- declare const VERSION = "1.12.1";
960
+ declare const VERSION = "1.14.0";
866
961
 
867
- export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, AxesConfig, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, type LimitStatsPoint, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, type MktPoint, type OptionsLayer, PointStyleType, RangeLabelPosition, SVGRenderer, SeriesStyle, SmoothingType, type StatsAggregatedPoint, type StdDevPoint, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, VERSION, XAxisConfig, YAxisConfig, attachTooltip, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };
962
+ export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, type AutoMarginOptions, AxesConfig, DataPoint, DrawCommand, type FieldAccessor, type FillBetweenThresholdsInput, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, type LimitStatsPoint, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, type MktPoint, type OptionsLayer, type PointAt, PointStyleType, type PointsAtOptions, RangeLabelPosition, SVGRenderer, SeriesStyle, SmoothingType, type StatsAggregatedPoint, type StdDevPoint, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, type TimeInput, TimeSeries, TimeSeriesBuilder, type ToDataPointsSpec, type TooltipOptions, type TooltipSample, VERSION, XAxisConfig, YAxisConfig, attachTooltip, autoMargin, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries };