ml-time-graph 1.17.1 → 1.19.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 +78 -0
- package/GRAPH_JSON_STRUCTURE.md +3 -1
- package/README.de.md +6 -4
- package/README.md +5 -4
- package/SKILLS.md +9 -538
- package/USAGE.md +27 -2
- package/dist/analyze/index.d.ts +2 -1
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +25 -17
- package/dist/index.js +26 -26
- package/dist/interaction/index.d.ts +4 -3
- package/dist/interaction/index.js +1 -1
- package/dist/internals.d.ts +8 -5
- package/dist/internals.js +4 -4
- package/dist/{marker_renderer-VcAK5as0.d.ts → marker_renderer-BKOhqPkn.d.ts} +21 -4
- package/dist/{types-D7tmWwH9.d.ts → types-pKdGBqvc.d.ts} +32 -2
- package/package.json +3 -2
- package/skills/ml-time-graph/SKILL.md +113 -0
- package/skills/ml-time-graph/reference/annotations-and-markers.md +63 -0
- package/skills/ml-time-graph/reference/axes.md +112 -0
- package/skills/ml-time-graph/reference/gaps.md +75 -0
- package/skills/ml-time-graph/reference/legend.md +57 -0
- package/skills/ml-time-graph/reference/rendering.md +84 -0
- package/skills/ml-time-graph/reference/series-styles.md +58 -0
- package/skills/ml-time-graph/reference/svelte.md +37 -0
- package/skills/ml-time-graph/reference/thresholds-and-fills.md +64 -0
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-BKOhqPkn.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-BKOhqPkn.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-pKdGBqvc.js';
|
|
5
|
+
import { TimeScale, LinearScale } from './internals.js';
|
|
6
|
+
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 FillWhere, O as GapBand, Q as GapConfig, U as GapLabel, V as GapRegion, W as GapStyle, X as GapsAtEnd, G as GridLayer, Y as LineShape, Z as LineStyle, _ as MarkerStyle, $ as MovingAverageType, a0 as SVGLineStyle, a1 as SensorType, a2 as SeriesGapStyle, a3 as SeriesGaps, a4 as SeriesOverlay, a5 as SeriesOverlayKind, a6 as SeriesType, a7 as ShadowStyle, a8 as SolidDashStyle, a9 as ThresholdLabelConfig, aa as getLineStyle, ab as resolveDash } from './types-pKdGBqvc.js';
|
|
5
7
|
|
|
6
8
|
/*!
|
|
7
9
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -93,9 +95,17 @@ interface PointsAtOptions {
|
|
|
93
95
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
94
96
|
*/
|
|
95
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Time-series chart. Configure it with {@link MLTimeGraphOptions} (series,
|
|
100
|
+
* thresholds, legend, axis labels, …), then call {@link MLTimeGraph.renderCommands}
|
|
101
|
+
* to get renderer-agnostic draw commands — a {@link Renderer} (e.g. SVGRenderer)
|
|
102
|
+
* turns those into output. The chart never touches the DOM itself.
|
|
103
|
+
*/
|
|
96
104
|
declare class MLTimeGraph {
|
|
97
105
|
private readonly _layout;
|
|
98
106
|
private readonly _idPraefix?;
|
|
107
|
+
/** classPrefix: vor jede Klasse ausser legend.itemClass (klassen_praefix.ts). */
|
|
108
|
+
private readonly _klassenPraefix?;
|
|
99
109
|
private readonly _renderer?;
|
|
100
110
|
private readonly _locale?;
|
|
101
111
|
private readonly _timeZone?;
|
|
@@ -127,7 +137,6 @@ declare class MLTimeGraph {
|
|
|
127
137
|
private _annotationSeq;
|
|
128
138
|
private readonly _axes?;
|
|
129
139
|
private _series;
|
|
130
|
-
private readonly_annotationBandHeight;
|
|
131
140
|
private _timeScale?;
|
|
132
141
|
private readonly _valueScales;
|
|
133
142
|
/** @param options Chart configuration; every field is optional and has a sensible default. */
|
|
@@ -185,8 +194,8 @@ declare class MLTimeGraph {
|
|
|
185
194
|
* muss deren Kurve treffen, nicht eine aehnliche (B-20261007-02).
|
|
186
195
|
*/
|
|
187
196
|
private _linienGrundlage;
|
|
188
|
-
|
|
189
|
-
private
|
|
197
|
+
/** Was rendereReihe vom Diagramm braucht (series/series_render.ts). */
|
|
198
|
+
private _reihenKontext;
|
|
190
199
|
legendItems(): LegendItem[];
|
|
191
200
|
private _legendeneintraege;
|
|
192
201
|
/**
|
|
@@ -231,14 +240,6 @@ declare class MLTimeGraph {
|
|
|
231
240
|
* when they have none) -- `hidden` and `pointsAt` cannot tell them apart.
|
|
232
241
|
*/
|
|
233
242
|
warnings(): string[];
|
|
234
|
-
/**
|
|
235
|
-
* `where` an einer Flaeche entscheidet an den Messwerten. Ist eine der
|
|
236
|
-
* beiden Kurven mit catmull-rom oder akima geglaettet, kann sie ueber die
|
|
237
|
-
* Messwerte hinausschwingen -- dann trifft die Flaeche die Linie am Rand des
|
|
238
|
-
* Fensters nicht genau. 'monotone' schwingt nicht ueber. Gegenstueck:
|
|
239
|
-
* ueberschwinger in go-time-graph/pkg/chart/warnings.go.
|
|
240
|
-
*/
|
|
241
|
-
private _ueberschwinger;
|
|
242
243
|
/**
|
|
243
244
|
* The points under the pointer at (x, y), in SVG pixels -- for a tooltip
|
|
244
245
|
* that gets data instead of HTML. Valid after `renderCommands()`, like
|
|
@@ -888,6 +889,12 @@ declare class SVGRenderer extends Renderer {
|
|
|
888
889
|
* `clip-plot-<hash>`.
|
|
889
890
|
*/
|
|
890
891
|
idPrefix?: string;
|
|
892
|
+
/**
|
|
893
|
+
* The chart's `classPrefix`, for the few classes this renderer writes
|
|
894
|
+
* itself (a labelled gap's group). The chart's own classes are already
|
|
895
|
+
* prefixed in its draw commands.
|
|
896
|
+
*/
|
|
897
|
+
classPrefix?: string;
|
|
891
898
|
});
|
|
892
899
|
/** Set a solid background colour, drawn as a full-size rect behind the chart. */
|
|
893
900
|
setBackgroundColor(color: string): void;
|
|
@@ -1145,6 +1152,7 @@ declare function mergeOptions(...layers: (OptionsLayer | undefined)[]): MLTimeGr
|
|
|
1145
1152
|
* Monate spaeter eine Datei aus einem Stapel von Berichten in der Hand haelt,
|
|
1146
1153
|
* kann sonst nicht feststellen, welcher Stand sie gezeichnet hat.
|
|
1147
1154
|
*/
|
|
1148
|
-
declare const VERSION = "1.
|
|
1155
|
+
declare const VERSION = "1.19.0";
|
|
1149
1156
|
|
|
1150
|
-
export { AggregatedPoint, AggregatedSeries, Annotation, AnnotationBandBuilder, AnnotationBandConfig, AnnotationBandItem, AnnotationBandItemBuilder, AnnotationBuilder, AnnotationPointShape, AnySeries,
|
|
1157
|
+
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 };
|
|
1158
|
+
export type { AutoMarginOptions, AxisGroupInput, AxisGroups, FieldAccessor, FillBetweenThresholdsInput, LimitStatsPoint, MktPoint, OptionsLayer, PointAt, PointsAtOptions, StatsAggregatedPoint, StdDevPoint, TimeInput, ToDataPointsSpec, TooltipOptions, TooltipSample };
|