ml-time-graph 1.18.0 → 1.20.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 +35 -0
- package/GRAPH_JSON_STRUCTURE.md +9 -0
- package/dist/analyze/index.d.ts +2 -1
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +14 -6
- package/dist/index.js +33 -33
- package/dist/interaction/index.d.ts +4 -2
- package/dist/internals.d.ts +10 -5
- package/dist/internals.js +11 -11
- package/dist/{marker_renderer-BZMcTbHC.d.ts → marker_renderer-fmHEb56H.d.ts} +3 -2
- package/dist/{types-CNIUKrmy.d.ts → types-Bo9798aK.d.ts} +23 -1
- package/package.json +1 -1
- package/skills/ml-time-graph/reference/annotations-and-markers.md +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,41 @@ release notes, and every change is in `git log` in full.
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## [1.20.0] - 2026-10-19
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- **`annotationBands[].labels: "fit"`** (TS and Go) — for many events in one band: only the
|
|
26
|
+
labels that fit side by side are drawn, measured against the real plot width; the last label
|
|
27
|
+
(or the first, `{ mode: "fit", keep: "first" }`) is always kept. Windows and their `title`
|
|
28
|
+
tooltips stay. Default `"all"` draws as before. Builders: `setLabels` / `SetLabels`.
|
|
29
|
+
(I-TGRAF-20261019-02)
|
|
30
|
+
|
|
31
|
+
## [1.19.0] - 2026-10-19
|
|
32
|
+
|
|
33
|
+
### Security
|
|
34
|
+
- **go-time-graph now requires Go 1.26** (was 1.25) and builds with Go 1.26.9. This closes 10
|
|
35
|
+
standard-library vulnerabilities reachable from `graph-server` (govulncheck) and updates
|
|
36
|
+
`golang.org/x/{crypto,net,text,sys,mod}`, whose fixes need Go 1.26. Go 1.25 is no longer
|
|
37
|
+
maintained since Go 1.27. No change to the output.
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- **Type exports** (TS) — `RenderOutput` and `GapBand` from `ml-time-graph`; `Point`,
|
|
41
|
+
`FlatSeriesStyle` and `RenderingContext` from `ml-time-graph/internals`. They already appeared
|
|
42
|
+
in public signatures (`render()`, `gaps.band`, the series renderers) but could not be named, so
|
|
43
|
+
a project emitting declarations could hit TS2742.
|
|
44
|
+
- **Gallery card "Line styles"** — every `style.line.style` variant, drawn from the same fixture
|
|
45
|
+
(`line_variants.json`) that the Go golden and the TS/Go parity test check.
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
- **Unknown `dash` variant** (TS) — a line style name the table does not know (e.g. `"dots"`
|
|
49
|
+
from JSON) now draws a plain solid line with no dash attributes, as `"solid"` does and as
|
|
50
|
+
the Go port always did. Before, TS wrote `stroke-dasharray="none" stroke-linecap="butt"`;
|
|
51
|
+
`resolveDash()` returned that pair instead of `null`. Looks the same; the SVG differs.
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- Internal clean-up in both ports (Go `zeichne` split into steps, shared SVG attribute and
|
|
55
|
+
rolling-window helpers). No change to the output: every fixture renders byte-identical.
|
|
56
|
+
|
|
22
57
|
## [1.18.0] - 2026-10-07
|
|
23
58
|
|
|
24
59
|
### Added
|
package/GRAPH_JSON_STRUCTURE.md
CHANGED
|
@@ -482,6 +482,14 @@ Bands rendered in a dedicated strip *outside* the plot area, useful for shift/ph
|
|
|
482
482
|
| `showInLegend` | `boolean` | `true` | Include in the legend |
|
|
483
483
|
| `background` | `string` | transparent | Strip background color |
|
|
484
484
|
| `items` | `AnnotationBandItem[]` | **required** | Individual windows inside the strip |
|
|
485
|
+
| `labels` | `'all' \| 'fit' \| { mode, keep? }` | `'all'` | `'fit'`: draw only the item labels that fit side by side (see below) |
|
|
486
|
+
|
|
487
|
+
**`labels: 'fit'`** — for many events close together, where centred labels would overlap
|
|
488
|
+
into an unreadable bar. One label is always drawn: the last by time, or the first with
|
|
489
|
+
`{ mode: 'fit', keep: 'first' }`. Then the others in time order, each only if it keeps 4 px
|
|
490
|
+
from every label already placed. A label that does not fit is left out, never moved; every
|
|
491
|
+
window is still drawn and keeps its `title`. Measured with the chart's text metrics against
|
|
492
|
+
the real plot width, identically in TS and Go.
|
|
485
493
|
|
|
486
494
|
### AnnotationBandItem
|
|
487
495
|
|
|
@@ -496,6 +504,7 @@ Bands rendered in a dedicated strip *outside* the plot area, useful for shift/ph
|
|
|
496
504
|
| `labelFontSize` | `number` | `10` | px |
|
|
497
505
|
| `labelFill` | `string` | inherited | Label color |
|
|
498
506
|
| `labelBaseline` | `'top' \| 'middle' \| 'bottom'` | `'middle'` | **Different value set than gap labels (`above/middle/below`)** |
|
|
507
|
+
| `title` | `string` | — | Hover tooltip (SVG `<title>`); interactive only, dropped in print |
|
|
499
508
|
|
|
500
509
|
---
|
|
501
510
|
|
package/dist/analyze/index.d.ts
CHANGED
|
@@ -680,4 +680,5 @@ interface F0Opts {
|
|
|
680
680
|
*/
|
|
681
681
|
declare function f0Sterilization(data: DataPoint[], opts?: F0Opts): number;
|
|
682
682
|
|
|
683
|
-
export {
|
|
683
|
+
export { DEFAULT_ACTIVATION_ENERGY, PRODUCT_PROFILES, SeriesProcessor, StatsAggregator, aggregateBySlot, aggregateWithStats, analyzeLongTermTrends, computeLimitExcursions, createAggr, currentTrend, detectGaps, divergenceExcursions, downsample, f0Sterilization, holdAlign, hotColdSpots, linearFit, mkt, predictTimeToThreshold, rollingEma, rollingMean, rollingMkt, rollingStdDev, rollingTrend, sampleStdDev, spatialDelta, stdDev, varianceCoefficient };
|
|
684
|
+
export type { AggregatedPoint, AggregationConfig, AggregationMode, AggregationThresholds, ComputeLimitsOpts, DataPoint, DivergenceEpisode, DivergenceOptions, F0Opts, HotColdSpotsResult, LimitExcursion, LimitStats, LimitStatsPoint, LongTermInsight, MktPoint, NamedSeries, PredictOpts, PredictResult, ProductConfig, ProductType, SensorStat, SpatialPoint, StatsAggregatedPoint, StatsResult, StdDevPoint, TrendFit, TrendPoint };
|
package/dist/analyze/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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}/*!
|
|
1
|
+
var _=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((a,o)=>a.time-o.time),e=[],t=[],r=null;for(let a of u){let o=i(a),m=l>0&&r&&a.time-r.time>l;(o||m)&&t.length&&(e.push(t),t=[]),o||t.push(a),r=a;}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=[],r=m=>m<=0?Number.NEGATIVE_INFINITY:e[m-1],a=m=>{let s=0;for(let h=0;h<e.length&&m>=e[h];h++)s=h+1;return s},o=[n[0]];for(let m=1;m<n.length;m++){let s=n[m-1],h=n[m],g=l(s),d=l(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=a((x+v)/2);t.push({data:o,zoneIndex:c,zoneLow:r(c)}),o=[f],x=v;}(p.length===0||p[p.length-1]!==d)&&o.push(h);}if(o.length>1||n.length===1){let m=l(o[0]),s=l(o[o.length-1]),h=a((m+s)/2);t.push({data:o,zoneIndex:h,zoneLow:r(h)});}return t}static splitByThreshold(n,i,l,u){let e=this.splitByBoundaries(n,[i],l,u),t={above:[],below:[]};for(let r of e)r.zoneIndex===0?t.below.push(r.data):t.above.push(r.data);return t}},C={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}},A=8.314462618,N=273.15;function T(n,i,l,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: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,r=-1/0,a=0;for(let f of e)f<t&&(t=f),f>r&&(r=f),a+=f;let o=a/e.length,m=l?0:null,s=l?0:null;if(l)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>l.limitHigh&&(m+=w),c.value<l.limitLow&&(s+=w);}}let h=0,g=0,d=(l?.activationEnergy??83144)/A;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:n,min:Number(t.toFixed(2)),max:Number(r.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 E(n,i="hourly",l,u,e=1){if(!n.length)return [];let t=i==="hourly"?36e5:i==="daily"?864e5:l??3600*1e3,r=[...n].sort((s,h)=>s.time-h.time),a=[],o=r[0].time,m=[];for(let s of r){for(;s.time-o>=t;)a.push(T(o,m,u,e)),o+=t,m=[];m.push(s);}return a.push(T(o,m,u,e)),a}function P(n,i){let l=1/0,u=-1/0,e=0;for(let r of i)r<l&&(l=r),r>u&&(u=r),e+=r;let t=e/i.length;return {time:n,min:l,max:u,avg:t,count:i.length}}function q(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 G(n){let i=[],l=0,u=0,e=0,t=0;for(let r of n)r.count>0&&(e++,r.minutesAboveHigh&&(l+=r.minutesAboveHigh),r.stdDev&&r.stdDev>u&&(u=r.stdDev),r.deltaMkt&&r.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 R(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 V(n,i="hourly",l){let u={limitLow:l.low,limitHigh:l.high,activationEnergy:l.activationEnergy};return E(n,i,l.interval,u,l.minCountForMkt??1)}var K=class{static compute(n){let i=n.map(a=>a.value).filter(a=>a!==null).sort((a,o)=>a-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((a,o)=>a+o,0)/l,e=l%2===1?i[Math.floor(l/2)]:(i[l/2-1]+i[l/2])/2,t=i.reduce((a,o)=>a+Math.pow(o-u,2),0)/l,r=Math.sqrt(t);return {min:i[0],max:i[l-1],avg:u,mean:u,median:e,stdDev:r,count:l}}static computeInRange(n,i,l){let u=n.filter(e=>e.time>=i&&e.time<=l);return this.compute(u)}};function O(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}function D(n,i,l){let u=new Array(n.length),e=0;for(let t=0;t<n.length;t++){let r=n[t].time,a=r-i;for(;e<t&&n[e].time<a;)e++;let o=n.slice(e,t+1).map(m=>m.value);u[t]={time:r,value:l(o),synthetic:true};}return u}var L=8.314,y=273.15,S=83144;function F(n,i=S){let l=i/L,u=0,e=0;for(let r of n)r!==null&&(u+=Math.exp(-l/(r+y)),e++);if(e===0)return null;let t=u/e;return l/-Math.log(t)-y}function U(n,i,l=S){return D(n,i,u=>F(u,l))}function I(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 r=t-u;e+=r*r;}return Math.sqrt(e/l)}function H(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 r=t-u;e+=r*r;}return Math.sqrt(e/(l-1))}function Y(n,i,l=false){return D(n,i,l?H:I)}function $(n,i){let l=new Array(n.length),u=0;for(let e=0;e<n.length;e++){let t=n[e].time,r=t-i;for(;u<e&&n[u].time<r;)u++;let a=0,o=0;for(let m=u;m<=e;m++){let s=n[m].value;s!==null&&(a+=s,o++);}l[e]={time:t,value:o===0?null:a/o,synthetic:true};}return l}function W(n,i){let l=new Array(n.length),u=null,e=0;for(let t=0;t<n.length;t++){let r=n[t].time,a=n[t].value;if(a===null){l[t]={time:r,value:u,synthetic:true};continue}if(u===null||i<=0)u=a;else {let o=1-Math.exp(-(r-e)/i);u=a*o+u*(1-o);}e=r,l[t]={time:r,value:u,synthetic:true};}return l}function Z(n,i){let{high:l,low:u}=i,e={msAboveHigh:0,msBelowLow:0,globalMax:null,globalMin:null,excursions:[]},t=null;for(let r=0;r<n.length;r++){let a=n[r];if(a.value===null){t&&(e.excursions.push(t),t=null);continue}(e.globalMax===null||a.value>e.globalMax)&&(e.globalMax=a.value),(e.globalMin===null||a.value<e.globalMin)&&(e.globalMin=a.value);let o=l!==void 0&&a.value>l,m=u!==void 0&&a.value<u,s=o?"above":m?"below":null,h=n[r-1];if(h&&h.value!==null&&s!==null){let g=a.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=a.time,t.durationMs=t.endTime-t.startTime,(s==="above"&&a.value>t.extremum||s==="below"&&a.value<t.extremum)&&(t.extremum=a.value)):(t&&e.excursions.push(t),t={startTime:a.time,endTime:a.time,side:s,extremum:a.value,durationMs:0});}return t&&e.excursions.push(t),e}function z(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],r=e[0];for(let a=1;a<e.length;a++)e[a].value<t.value&&(t=e[a]),e[a].value>r.value&&(r=e[a]);l.push({time:u,min:t.value,max:r.value,delta:e.length<2?null:r.value-t.value,minSensor:t.name,maxSensor:r.name});}return l}function j(n){let i=[];for(let e of n){let t=0,r=0,a=1/0,o=-1/0;for(let m of e.data)m.value!==null&&(t+=m.value,r++,m.value<a&&(a=m.value),m.value>o&&(o=m.value));r!==0&&i.push({name:e.name,mean:t/r,min:a,max:o,count:r});}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 J(n,i){let{maxDelta:l,minDurationMs:u=0}=i,e=[],t=null,r=()=>{t&&t.durationMs>=u&&e.push(t),t=null;};for(let a of z(n)){if(a.delta===null||a.delta<=l){r();continue}t?(t.endTime=a.time,t.durationMs=t.endTime-t.startTime,a.delta>t.peakDelta&&(t.peakDelta=a.delta,t.peakTime=a.time,t.maxSensor=a.maxSensor,t.minSensor=a.minSensor)):t={startTime:a.time,endTime:a.time,durationMs:0,peakDelta:a.delta,peakTime:a.time,maxSensor:a.maxSensor,minSensor:a.minSensor};}return r(),e}function Q(n,i){let l=i>0?i:0,u=new Set,e=n.map(r=>{let a=[...r.data].sort((o,m)=>o.time-m.time);for(let o of a)u.add(o.time);return a}),t=[...u].sort((r,a)=>r-a);return n.map((r,a)=>{let o=e[a],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<=l?g.value:null;return {time:h,value:d}});return {name:r.name,data:s}})}function k(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 r=i*t-l*l;if(r===0)return null;let a=(i*e-l*u)/r,o=(u-a*l)/i;return {slope:a,intercept:o,n:i}}function B(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 k(e)}function X(n,i){let l=[],u=0;for(let e=0;e<n.length;e++){let t=n[e].time,r=t-i;for(;u<n.length&&n[u].time<r;)u++;let a=k(n.slice(u,e+1));l.push({time:t,fit:a});}return l}function ee(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 r=B(n,u);if(!r||r.slope===0)return null;let a=r.slope>0&&t.value<i,o=r.slope<0&&t.value>i;if(e==="above"&&!a||e==="below"&&!o||e==="either"&&!a&&!o)return null;let m=(i-r.intercept)/r.slope,s=m-t.time;return s<=0?null:{msUntil:s,eta:m,fit:r,currentValue:t.value}}function te(n,i={}){let l=i.refTempCelsius??121.11,u=i.zValueKelvin??10,e=0;for(let t=0;t<n.length-1;t++){let r=n[t],a=n[t+1];if(r.value===null||a.value===null)continue;let o=(a.time-r.time)/6e4;if(o<=0)continue;let m=Math.pow(10,(r.value-l)/u),s=Math.pow(10,(a.value-l)/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(l,i,n){return {time:l.time+Math.round(n*
|
|
|
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{
|
|
15
|
+
*/export{S as DEFAULT_ACTIVATION_ENERGY,C as PRODUCT_PROFILES,_ as SeriesProcessor,K as StatsAggregator,E as aggregateBySlot,V as aggregateWithStats,G as analyzeLongTermTrends,Z as computeLimitExcursions,P as createAggr,B as currentTrend,q as detectGaps,J as divergenceExcursions,R as downsample,te as f0Sterilization,Q as holdAlign,j as hotColdSpots,k as linearFit,F as mkt,ee as predictTimeToThreshold,W as rollingEma,$ as rollingMean,U as rollingMkt,Y as rollingStdDev,X as rollingTrend,H as sampleStdDev,z as spatialDelta,I as stdDev,O as varianceCoefficient};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { M as MLTimeGraphOptions, L as LegendItem,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { M as MLTimeGraphOptions, L as LegendItem, b as Margin, Y as YAxisConfig, A as AxesConfig, X as XAxisConfig, c as LegendOptions, d as LegendPosition, e as LegendOrientation, f as Marker, g as RenderOutput } from './marker_renderer-fmHEb56H.js';
|
|
2
|
+
import { Renderer, LayoutResult } from './internals.js';
|
|
3
|
+
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-fmHEb56H.js';
|
|
4
|
+
import { e as AnySeries, i as Annotation, a as DrawCommand, g as Gap, h as GapsConfig, f as Threshold, H as Highlight, j as AnnotationBandConfig, l as SeriesStyle, c as LineVariant, S as SmoothingType, F as FillSpec, m as TimeSeries, b as LineDashStyle, n as ThresholdFill, k 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 './types-Bo9798aK.js';
|
|
5
|
+
import { TimeScale, LinearScale } from './internals.js';
|
|
6
|
+
export { v as AggregatedShowAs, w as AggregationConfig, x as AggregationMode, y as AnnotationBandLabels, z as AnnotationKind, B as AxisOrientation, A as AxisPosition, C as DataPointRef, E as EnumMap, I as FillBound, J as FillRegion, K as FillSide, N as FillStyle, O as FillWhere, Q as GapBand, U as GapConfig, V as GapLabel, W as GapRegion, X as GapStyle, Y as GapsAtEnd, G as GridLayer, Z as LineShape, _ as LineStyle, $ as MarkerStyle, a0 as MovingAverageType, a1 as SVGLineStyle, a2 as SensorType, a3 as SeriesGapStyle, a4 as SeriesGaps, a5 as SeriesOverlay, a6 as SeriesOverlayKind, a7 as SeriesType, a8 as ShadowStyle, a9 as SolidDashStyle, aa as ThresholdLabelConfig, ab as getLineStyle, ac as resolveDash } from './types-Bo9798aK.js';
|
|
5
7
|
|
|
6
8
|
/*!
|
|
7
9
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -840,6 +842,11 @@ declare class AnnotationBandBuilder {
|
|
|
840
842
|
setShowAxis(show: boolean): this;
|
|
841
843
|
/** Sets whether the band is listed in the chart legend. */
|
|
842
844
|
setShowInLegend(show: boolean): this;
|
|
845
|
+
/**
|
|
846
|
+
* Sets which item labels are drawn: `"all"` (default) or `"fit"` — only those that fit
|
|
847
|
+
* side by side; `keep` picks the label that is always drawn.
|
|
848
|
+
*/
|
|
849
|
+
setLabels(mode: "all" | "fit", keep?: "last" | "first"): this;
|
|
843
850
|
/** Sets the background color of the band. */
|
|
844
851
|
setBackground(bg: string): this;
|
|
845
852
|
/** Adds an event range/item to the band. */
|
|
@@ -1150,6 +1157,7 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
|
|
|
1150
1157
|
* Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
|
|
1151
1158
|
* kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
|
|
1152
1159
|
*/
|
|
1153
|
-
declare const VERSION = "1.
|
|
1160
|
+
declare const VERSION = "1.20.0";
|
|
1154
1161
|
|
|
1155
|
-
export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries,
|
|
1162
|
+
export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries, AxesConfig, DataPoint, DrawCommand, FillSpec, Gap, GapsConfig, GraphBuilder, HatchVariant, Highlight, HighlightBuilder, LabelAnchor, LegendItem, LegendOptions, LegendOrientation, LegendPosition, LineDashStyle, LineVariant, MLTimeGraph, MLTimeGraphOptions, Margin, Marker, MarkerBuilder, MarkerLineStyle, PointStyleType, RangeLabelPosition, RenderOutput, SVGRenderer, SeriesStyle, SmoothingType, TextBaseline, Threshold, ThresholdBuilder, ThresholdFill, ThresholdLabelPosition, TimeSeries, TimeSeriesBuilder, VERSION, XAxisConfig, YAxisConfig, attachTooltip, autoMargin, axisGroups, fillBetweenThresholds, mergeOptions, mount, parseAggregated, parseDataPoint, parseSeries, toDataPoints, toSeries, zeigerImSvg };
|
|
1163
|
+
export type { AutoMarginOptions, AxisGroupInput, AxisGroups, FieldAccessor, FillBetweenThresholdsInput, LimitStatsPoint, MktPoint, OptionsLayer, PointAt, PointsAtOptions, StatsAggregatedPoint, StdDevPoint, TimeInput, ToDataPointsSpec, TooltipOptions, TooltipSample };
|