ml-time-graph 1.1.0 → 1.2.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/README.md +2 -2
- package/USAGE.md +116 -7
- package/dist/analyze/index.d.ts +15 -1
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +65 -7
- package/dist/index.js +20 -20
- package/dist/interaction/index.d.ts +1 -1
- package/dist/internals.d.ts +7 -7
- package/dist/internals.js +4 -4
- package/dist/{layout-DDdMtPrB.d.ts → layout-C_t250fG.d.ts} +5 -5
- package/dist/{scale-DcFBNLdU.d.ts → scale-DFyECKZq.d.ts} +46 -46
- package/docs/MKT_AGGREGATE.md +66 -68
- package/package.json +65 -65
package/dist/internals.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var V=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time+t*(e.time-a.time),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let r=(o,n)=>o!==null&&n!==null?o+t*(n-o):null;return {time:a.time+t*(e.time-a.time),min:r(a.min,e.min),max:r(a.max,e.max),avg:r(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let r=[...a].sort((m,s)=>m.time-s.time),o=[],n=[],i=null;for(let m of r){let s=e(m),l=t>0&&i&&m.time-i.time>t;(s||l)&&n.length&&(o.push(n),n=[]),s||n.push(m),i=m;}return n.length&&o.push(n),o}static splitByBoundaries(a,e,t,r){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0}];let o=[...e].sort((s,l)=>s-l),n=[],i=s=>{let l=0;for(let u=0;u<o.length&&s>=o[u];u++)l=u+1;return l},m=[a[0]];for(let s=1;s<a.length;s++){let l=a[s-1],u=a[s],d=t(l),c=t(u),f;c>d?f=o.filter(p=>p>d&&p<=c):c<d?f=o.filter(p=>p>=c&&p<d).reverse():f=[];for(let p of f){let b=(p-d)/(c-d),y=r(l,u,b);m.push(y),n.push({data:m,zoneIndex:i((d+p)/2)}),m=[y];}m.push(u);}if(m.length>0){let s=t(m[0]),l=t(m[m.length-1]);n.push({data:m,zoneIndex:i((s+l)/2)});}return n}static splitByThreshold(a,e,t,r){let o=this.splitByBoundaries(a,[e],t,r),n={above:[],below:[]};for(let i of o)i.zoneIndex===0?n.below.push(i.data):n.above.push(i.data);return n}};var me=class{static compute(a){let e=a.map(m=>m.value).filter(m=>m!==null).sort((m,s)=>m-s);if(e.length===0)return {min:NaN,max:NaN,avg:NaN,mean:NaN,median:NaN,stdDev:NaN,count:0};let t=e.length,r=e.reduce((m,s)=>m+s,0)/t,o=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,n=e.reduce((m,s)=>m+Math.pow(s-r,2),0)/t,i=Math.sqrt(n);return {min:e[0],max:e[t-1],avg:r,mean:r,median:o,stdDev:i,count:t}}static computeInRange(a,e,t){let r=a.filter(o=>o.time>=e&&o.time<=t);return this.compute(r)}};var h={stroke:"#4285f4",strokeWidth:2,pointSize:4,pointThreshold:100,gapThreshold:0,fill:"none",hatch:null,bandFill:"#4285f4",bandOpacity:.6,bandAvgLine:"#e53e3e",minColor:"#3b82f6",maxColor:"#ef4444",avgColor:"#64748b",areaFillAlpha:"4285f433",axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:11,axisLabelColor:"#444",axisLabelSize:12,gridStroke:"#e2e8f0",gridStrokeWidth:1,gridOpacity:1,legendStroke:"#ccc",legendText:"#333",legendFont:11,annotationColor:"#334155",annotationWidth:1.5,annotationHead:9,annotationRadius:4,annotationFontSize:11,thresholdColor:"#666",thresholdLine:"dashed",thresholdFillOpacity:.12,thresholdFontSize:10,highlightColor:"#fbbf24",highlightOpacity:.2,highlightLabelColor:"#92400e",markerColor:"#f59e0b",markerSize:5,gapFill:"#fff",gapStroke:"#ccc",gapStrokeWidth:1,gapFontColor:"#999",gapFontSize:10,gapFillOpacity:.15,tooltipBg:"#fff",tooltipBorder:"#cbd5e1",tooltipText:"#1e293b",tooltipValue:"#3b82f6",tooltipCrosshair:"#94a3b8",tooltipSnapRadius:20,statsLineColor:"#94a3b8",statsLabelColor:"#64748b",minimapStroke:"#94a3b8",minimapBg:"#f8f9fa",minimapBrush:"#3b82f644",palette:["#4285f4","#ea4335","#22c55e","#fbbc05","#9334ea","#12b5e5","#fb923c","#6366f1"]};function ue(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",r="#4D88FF",o=2){if(e==="none")return `
|
|
2
2
|
<pattern id="${a}" width="10" height="10" patternUnits="userSpaceOnUse">
|
|
3
3
|
<rect width="10" height="10" fill="${t}" />
|
|
4
4
|
</pattern>
|
|
@@ -25,10 +25,10 @@ var E=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
25
25
|
${l}
|
|
26
26
|
${s}
|
|
27
27
|
</pattern>
|
|
28
|
-
`.trim()}function I(a){return {id:a.id,line:{stroke:a.stroke??d.stroke,strokeWidth:a.strokeWidth??d.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??d.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??d.pointSize,stroke:a.stroke??d.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let r=[],o=a.reduce((i,m)=>i+m.data.length,0),n=I(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?r.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&r.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:m.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return r}function V(a,e,t){let r=[],o=I(t);for(let n=0;n<a.length;n++){let i=a[n];if(i.data.length<2)continue;let m=[];for(let s=0;s<i.data.length;s++){let l=e.timeScale.map(i.data[s].time),u=e.valueScale.map(i.data[s].value);s===0?m.push({x:l,y:u}):(m.push({x:l,y:m[m.length-1].y}),m.push({x:l,y:u}));}r.push({type:"path",id:t.id?`${t.id}-line-${n}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return r}function xe(a,e,t,r,o){let n=[],i=I(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(r(h))})),u=s.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(o(h))})).reverse();n.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return n}function B(a,e,t,r){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),n=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(t.yLow(h))})),u=m.data.map(h=>({x:e.timeScale.map(h.time),y:e.valueScale.map(t.yHigh(h))})).reverse();n.push({type:"path",id:r?.id?`${r.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return n}function Se(a,e,t,r){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),n=[];return r.below&&n.push(...w(o.below.map(i=>({data:i})),t,r.below)),r.above&&n.push(...w(o.above.map(i=>({data:i})),t,r.above)),n}function P(a,e,t,r){let o=I(t);if(!o.markers.type||o.markers.type==="none")return [];let n=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=r(m),h=t.pointStroke??u,c=t.pointFill??u,f=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${i}`:void 0;ke(n,p,o.markers.type,s,l,o.markers.size,h,c,f);}return n}function ke(a,e,t,r,o,n,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:r-n,y:o-n,w:n*2,h:n*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:r-n,y1:o-n,x2:r+n,y2:o+n,stroke:i,strokeWidth:s,id:e}),a.push({type:"line",x1:r-n,y1:o+n,x2:r+n,y2:o-n,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o},{x:r,y:o+n},{x:r-n,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let h=u%2===0?n:n*.5,c=Math.PI/2*3+u*Math.PI/5;l.push({x:r+h*Math.cos(c),y:o+h*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:r-n,y:o+n},{x:r,y:o-n},{x:r+n,y:o+n}],stroke:i,strokeWidth:s,fill:"none",id:e});break;default:a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,H=8,N=20,ve=11,G=18,Y=a=>a.length*ve*.6;function we(a,e="vertical"){if(e==="horizontal"){let r=0;for(let o of a)r+=T+H+Y(o.name)+G;return {width:Math.max(0,r-G),height:N}}let t=0;for(let r of a)t=Math.max(t,Y(r.name));return {width:T+H+t,height:a.length*N}}function Ce(a){let{items:e,x:t,y:r,orientation:o="vertical"}=a,n=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?r:r+s*N;n.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:d.legendStroke,strokeWidth:1}),n.push({type:"text",content:m.name,x:l+T+H,y:u+T-2,fontSize:d.legendFont,fill:d.legendText}),o==="horizontal"&&(i+=T+H+Y(m.name)+G);}),{type:"group",cssClass:"chart-legend",commands:n}}function Te(a){let{xTicks:e,yTicks:t,xRange:r,yRange:o,stroke:n=d.gridStroke,strokeWidth:i=d.gridStrokeWidth,dashed:m=false,opacity:s=d.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:n,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:n,strokeWidth:i,dashed:m,opacity:s});return l}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[r,o]=this.#e,[n,i]=this.#t;return o===r?n:n+(t-r)/(o-r)*(i-n)}invert(e){let[t,r]=this.#e,[o,n]=this.#t;return n===o?t:t+(e-o)/(n-o)*(r-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,r=12){let[o,n]=this.#e.domain(),i=n-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let h of k)if(h.ms>=m){s=h.ms;break}let l=s,u=Math.round(i/l);for(;u>r&&l<k[k.length-1].ms;){let h=k.findIndex(c=>c.ms===l);l=k[Math.min(h+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let h=k.findIndex(c=>c.ms===l);l=k[Math.max(h-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,r=e?.maxTicks??12,{interval:o}=this.tickInterval((t+r)/2,t,r),[n,i]=this.#e.domain(),m=[],s=Math.ceil(n/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return new Intl.DateTimeFormat(this.#t,t).format(new Date(e))}},A=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,r=this.#e.length;return r<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/r+Math.abs(t-e)*this.#n*2/r}get bandwidth(){let[e,t]=this.#t,r=this.#e.length;if(r<=1)return Math.abs(t-e)*(1-this.#r*2);let o=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-o)/r*(1-this.#n)}map(e){let t=this.#e.findIndex(h=>String(h)===String(e));if(t===-1)return this.#t[0];let[r,o]=this.#t,n=this.#e.length;if(n<=1)return (r+o)/2;let i=this.#r*2*Math.abs(o-r),m=Math.abs(o-r)-i,s=o>=r?1:-1,l=m/n;return r+this.#r*Math.abs(o-r)*s+t*l}invert(e){let t=0,r=1/0;for(let o=0;o<this.#e.length;o++){let n=this.map(this.#e[o]),i=Math.abs(e-n);i<r&&(r=i,t=o);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Le(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Me(a){let{thresholds:e,valueScale:t,xRange:r}=a,[o,n]=r,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],h=[];for(let c of e){let f=c.color??d.thresholdColor,p=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:o,y:s,w:n-o,h:Math.max(0,p-s),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:o,y:p,w:n-o,h:Math.max(0,l-p),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??d.thresholdLine;if(b!=="none"){let y=Le(b),g={type:"line",x1:o,y1:p,x2:n,y2:p,stroke:f,strokeWidth:1,...y,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(g.shadowColor=c.shadowColor,g.shadowBlur=c.shadowBlur??4,g.shadowOffsetX=c.shadowOffsetX??0,g.shadowOffsetY=c.shadowOffsetY??2),u.push(g);}if(c.label!==false){let y=c.label&&typeof c.label=="object"?c.label:void 0,g=typeof c.label=="string"?c.label:y?.text??c.name,S=y?.position??"right";h.push({..._e(g,S,o,n,p,f,y),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:h}}function De(a){let e=Me(a);return [...e.inside,...e.labels]}function _e(a,e,t,r,o,n,i){let m=(t+r)/2,s={type:"text",content:a,fontSize:d.thresholdFontSize,fill:n},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:r+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:r-4,y:o-4,anchor:"end"}}}function $e(a){let{gaps:e,timeScale:t,yRange:r,fill:o=d.gapFill,hatch:n,fillOpacity:i=d.gapFillOpacity??.15,stroke:m=d.gapStroke,strokeWidth:s=d.gapStrokeWidth,dashed:l=true,fontSize:u=d.gapFontSize,fontFill:h=d.gapFontColor,labelBaseline:c="middle",labelRotate:f}=a,[p,b]=r,y=[];for(let g of e){let S=t.map(g.startTime),$=t.map(g.endTime),C=g.fill??o,F=g.hatch??n,se=g.fillOpacity??i,le=g.label??"",ge=g.rotate??f,z=g.labelBaseline??c;if(g.style==="dashed_border"||!g.style?y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se,stroke:m,strokeWidth:s,dashed:l}):g.style==="empty"&&y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se}),le){let ye=Fe(p,b,z),be=z==="above"?"top":z==="below"?"bottom":"middle";y.push({type:"text",content:le,x:(S+$)/2,y:ye,anchor:"middle",fontSize:u,fill:h,textBaseline:be,rotate:ge});}}return y}function Fe(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Pe(a){let{markers:e,timeScale:t,valueScale:r,yRange:o=[0,300]}=a,[n,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??d.markerColor,h=s.pointStyle??(s.value!==void 0?"circle":"none"),c=s.lineStyle??"full";if(s.value!==void 0){let f=r.map(s.value);if(c==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?m.push({type:"line",x1:l,y1:n,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),h!=="none"&&Re(m,l,f,u,h),s.label){let p=c==="to-value"?f-10:n-6;m.push({type:"text",content:s.label,x:l,y:p,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:n-6,anchor:"middle",fontSize:11,fill:u});}return m}function Re(a,e,t,r,o){let n=d.markerSize;switch(o){case "circle":a.push({type:"circle",cx:e,cy:t,r:n,fill:r});break;case "square":a.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:r});break;case "cross":a.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:r,strokeWidth:2});break;case "arrow":a.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:r,strokeWidth:2,fill:"none"});break;case "diamond":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:r,stroke:"none"});break;case "triangle":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:r,stroke:"none"});break;case "star":{let i=[],m=n*.4;for(let s=0;s<10;s++){let l=s%2===0?n:m,u=Math.PI/2*3+s*Math.PI/5;i.push({x:e+l*Math.cos(u),y:t+l*Math.sin(u)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "plus":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:r,strokeWidth:2});break;case "triangle-down":a.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:r,stroke:"none"});break;case "hexagon":{let i=[];for(let m=0;m<6;m++){let s=m*(Math.PI/3);i.push({x:e+n*Math.cos(s),y:t+n*Math.sin(s)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "hourglass":a.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:r,stroke:"none"});break;case "line-horizontal":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2});break}}function Ae(a){let{highlights:e,timeScale:t,yRange:r,height:o}=a,[n,i]=r,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:n,w:u-l,h:i-n,fill:s.color??d.highlightColor,opacity:s.opacity??d.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:We(s.labelPosition??"top",n,i,o),anchor:"middle",fontSize:d.annotationFontSize,fill:s.color??d.highlightLabelColor,rotate:s.rotate});}return m}function We(a,e,t,r){switch(a){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function X(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function je(a){let{annotations:e,timeScale:t,valueScales:r}=a,o=[],n=i=>{let m=r.get(i.axis??0)??r.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=n(i.from),u=n(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??d.annotationColor,strokeWidth:i.width??d.annotationWidth,dash:i.dash});break}case "arrow":{let l=n(i.from),u=n(i.to),h=i.color??d.annotationColor,c=i.headSize??d.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:h,strokeWidth:i.width??d.annotationWidth});let f=Math.hypot(u.x-l.x,u.y-l.y)||1,p=(u.x-l.x)/f,b=(u.y-l.y)/f,y=u.x-p*c,g=u.y-b*c;s({type:"path",points:[{x:u.x,y:u.y},{x:y-b*c*.5,y:g+p*c*.5},{x:y+b*c*.5,y:g-p*c*.5}],fill:h,stroke:"none"});break}case "rect":{let l=n(i.from),u=n(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=n(i.at),u=i.color??"#334155",h=i.radius??d.annotationRadius,c=i.shape??"circle";c==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:h,fill:u}):c==="square"?s({type:"rect",x:l.x-h,y:l.y-h,w:h*2,h:h*2,fill:u}):(s({type:"line",x1:l.x-h,y1:l.y-h,x2:l.x+h,y2:l.y+h,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-h,y1:l.y+h,x2:l.x+h,y2:l.y-h,stroke:u,strokeWidth:1.5}));break}case "label":{let l=n(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:d.annotationFontSize,fill:i.color??d.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=X(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var U=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:r}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-r.left-r.right,chartHeight:t-r.top-r.bottom,chartX:r.left,chartY:r.top,margin:r}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var Z=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(r=>e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(r=>`<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" />`).join(`
|
|
28
|
+
`.trim()}function I(a){return {id:a.id,line:{stroke:a.stroke??h.stroke,strokeWidth:a.strokeWidth??h.strokeWidth,smoothing:a.smoothing??false,dashed:a.dashed??false},fill:a.fill??h.areaFillAlpha,markers:{type:a.pointStyle??"none",size:a.pointSize??h.pointSize,stroke:a.stroke??h.stroke,fill:"#ffffff"},shadow:{color:a.shadowColor??"transparent",blur:a.shadowBlur??0,offsetX:a.shadowOffsetX??0,offsetY:a.shadowOffsetY??0}}}function w(a,e,t){let r=[],o=a.reduce((i,m)=>i+m.data.length,0),n=I(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?r.push({type:"path",id:t.id?`${t.id}-line-${i}`:void 0,points:m.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})),stroke:m.color??n.line.stroke,strokeWidth:n.line.strokeWidth,smoothing:n.line.smoothing,dashed:n.line.dashed,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur,shadowOffsetX:n.shadow.offsetX,shadowOffsetY:n.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&r.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(n.markers.size,n.line.strokeWidth),fill:m.color??n.line.stroke,shadowColor:n.shadow.color,shadowBlur:n.shadow.blur});}return r}function E(a,e,t){let r=[],o=I(t);for(let n=0;n<a.length;n++){let i=a[n];if(i.data.length<2)continue;let m=[];for(let s=0;s<i.data.length;s++){let l=e.timeScale.map(i.data[s].time),u=e.valueScale.map(i.data[s].value);s===0?m.push({x:l,y:u}):(m.push({x:l,y:m[m.length-1].y}),m.push({x:l,y:u}));}r.push({type:"path",id:t.id?`${t.id}-line-${n}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return r}function xe(a,e,t,r,o){let n=[],i=I(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(r(d))})),u=s.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(o(d))})).reverse();n.push({type:"path",id:t.id?`${t.id}-fill-${m}`:void 0,points:[...l,...u],fill:s.color??i.fill,hatch:t.hatch,stroke:"none"});}return n}function B(a,e,t,r){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),n=[];for(let i=0;i<o.length;i++){let m=o[i];if(m.data.length<2)continue;let s=t.getColor(m.zoneIndex);if(!s)continue;let l=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yLow(d))})),u=m.data.map(d=>({x:e.timeScale.map(d.time),y:e.valueScale.map(t.yHigh(d))})).reverse();n.push({type:"path",id:r?.id?`${r.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return n}function Se(a,e,t,r){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),n=[];return r.below&&n.push(...w(o.below.map(i=>({data:i})),t,r.below)),r.above&&n.push(...w(o.above.map(i=>({data:i})),t,r.above)),n}function P(a,e,t,r){let o=I(t);if(!o.markers.type||o.markers.type==="none")return [];let n=[];for(let i=0;i<a.length;i++){let m=a[i],s=e.timeScale.map(m.time),l=e.valueScale.map(m.value),u=r(m),d=t.pointStroke??u,c=t.pointFill??u,f=t.pointStrokeWidth??1.5,p=t.id?`${t.id}-marker-${i}`:void 0;ke(n,p,o.markers.type,s,l,o.markers.size,d,c,f);}return n}function ke(a,e,t,r,o,n,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:r-n,y:o-n,w:n*2,h:n*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:r-n,y1:o-n,x2:r+n,y2:o+n,stroke:i,strokeWidth:s,id:e}),a.push({type:"line",x1:r-n,y1:o+n,x2:r+n,y2:o-n,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o},{x:r,y:o+n},{x:r-n,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:r,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let d=u%2===0?n:n*.5,c=Math.PI/2*3+u*Math.PI/5;l.push({x:r+d*Math.cos(c),y:o+d*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:r-n,y:o+n},{x:r,y:o-n},{x:r+n,y:o+n}],stroke:i,strokeWidth:s,fill:"none",id:e});break;default:a.push({type:"circle",cx:r,cy:o,r:n,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,H=8,N=20,ve=11,G=18,Y=a=>a.length*ve*.6;function we(a,e="vertical"){if(e==="horizontal"){let r=0;for(let o of a)r+=T+H+Y(o.name)+G;return {width:Math.max(0,r-G),height:N}}let t=0;for(let r of a)t=Math.max(t,Y(r.name));return {width:T+H+t,height:a.length*N}}function Ce(a){let{items:e,x:t,y:r,orientation:o="vertical"}=a,n=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?r:r+s*N;n.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1}),n.push({type:"text",content:m.name,x:l+T+H,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+H+Y(m.name)+G);}),{type:"group",cssClass:"chart-legend",commands:n}}function Te(a){let{xTicks:e,yTicks:t,xRange:r,yRange:o,stroke:n=h.gridStroke,strokeWidth:i=h.gridStrokeWidth,dashed:m=false,opacity:s=h.gridOpacity}=a,l=[];if(t)for(let u of t)l.push({type:"line",x1:r[0],y1:u,x2:r[1],y2:u,stroke:n,strokeWidth:i,dashed:m,opacity:s});if(e)for(let u of e)l.push({type:"line",x1:u,y1:o[0],x2:u,y2:o[1],stroke:n,strokeWidth:i,dashed:m,opacity:s});return l}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[r,o]=this.#e,[n,i]=this.#t;return o===r?n:n+(t-r)/(o-r)*(i-n)}invert(e){let[t,r]=this.#e,[o,n]=this.#t;return n===o?t:t+(e-o)/(n-o)*(r-t)}domain(){return [...this.#e]}range(){return [...this.#t]}},k=[{label:"second",ms:1e3},{label:"2_seconds",ms:2e3},{label:"5_seconds",ms:5e3},{label:"10_seconds",ms:1e4},{label:"30_seconds",ms:3e4},{label:"minute",ms:6e4},{label:"5_minutes",ms:3e5},{label:"15_minutes",ms:9e5},{label:"30_minutes",ms:18e5},{label:"hour",ms:36e5},{label:"3_hours",ms:108e5},{label:"6_hours",ms:216e5},{label:"day",ms:864e5},{label:"week",ms:6048e5},{label:"month",ms:2592e6},{label:"3_months",ms:7776e6},{label:"6_months",ms:15552e6},{label:"year",ms:31536e6},{label:"2_years",ms:63072e6},{label:"5_years",ms:15768e7}],R=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e.locale||(typeof navigator<"u"?navigator.language:"en-US");}map(e){return this.#e.map(Number(e))}invert(e){return this.#e.invert(e)}domain(){return this.#e.domain()}range(){return this.#e.range()}get locale(){return this.#t}tickInterval(e,t=3,r=12){let[o,n]=this.#e.domain(),i=n-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let d of k)if(d.ms>=m){s=d.ms;break}let l=s,u=Math.round(i/l);for(;u>r&&l<k[k.length-1].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.min(d+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let d=k.findIndex(c=>c.ms===l);l=k[Math.max(d-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,r=e?.maxTicks??12,{interval:o}=this.tickInterval((t+r)/2,t,r),[n,i]=this.#e.domain(),m=[],s=Math.ceil(n/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return new Intl.DateTimeFormat(this.#t,t).format(new Date(e))}},A=class{#e;#t;#n;#r;constructor(e){this.#e=[...e.domain],this.#t=[...e.range],this.#n=e.paddingInner??.1,this.#r=e.paddingOuter??.05;}get step(){let[e,t]=this.#t,r=this.#e.length;return r<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/r+Math.abs(t-e)*this.#n*2/r}get bandwidth(){let[e,t]=this.#t,r=this.#e.length;if(r<=1)return Math.abs(t-e)*(1-this.#r*2);let o=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-o)/r*(1-this.#n)}map(e){let t=this.#e.findIndex(d=>String(d)===String(e));if(t===-1)return this.#t[0];let[r,o]=this.#t,n=this.#e.length;if(n<=1)return (r+o)/2;let i=this.#r*2*Math.abs(o-r),m=Math.abs(o-r)-i,s=o>=r?1:-1,l=m/n;return r+this.#r*Math.abs(o-r)*s+t*l}invert(e){let t=0,r=1/0;for(let o=0;o<this.#e.length;o++){let n=this.map(this.#e[o]),i=Math.abs(e-n);i<r&&(r=i,t=o);}return this.#e[t]}domain(){return this.#e.length===0?["",""]:[this.#e[0],this.#e[this.#e.length-1]]}range(){return [...this.#t]}positions(){let e=new Map;for(let t of this.#e)e.set(t,this.map(t));return e}};function Le(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Me(a){let{thresholds:e,valueScale:t,xRange:r}=a,[o,n]=r,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],d=[];for(let c of e){let f=c.color??h.thresholdColor,p=t.map(c.value);c.fill==="above"?u.push({type:"rect",x:o,y:s,w:n-o,h:Math.max(0,p-s),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0}):c.fill==="below"&&u.push({type:"rect",x:o,y:p,w:n-o,h:Math.max(0,l-p),fill:f,hatch:c.fillHatch,opacity:c.fillOpacity??.12,id:c.id?`${c.id}-fill`:void 0});let b=c.line??h.thresholdLine;if(b!=="none"){let y=Le(b),g={type:"line",x1:o,y1:p,x2:n,y2:p,stroke:f,strokeWidth:1,...y,id:c.id?`${c.id}-line`:void 0};c.shadowColor&&(g.shadowColor=c.shadowColor,g.shadowBlur=c.shadowBlur??4,g.shadowOffsetX=c.shadowOffsetX??0,g.shadowOffsetY=c.shadowOffsetY??2),u.push(g);}if(c.label!==false){let y=c.label&&typeof c.label=="object"?c.label:void 0,g=typeof c.label=="string"?c.label:y?.text??c.name,S=y?.position??"right";d.push({..._e(g,S,o,n,p,f,y),id:c.id?`${c.id}-label`:void 0});}}return {inside:u,labels:d}}function De(a){let e=Me(a);return [...e.inside,...e.labels]}function _e(a,e,t,r,o,n,i){let m=(t+r)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:n},l=i?{...i.rotate!==void 0&&{rotate:i.rotate},...i.textBaseline!==void 0&&{textBaseline:i.textBaseline}}:{};switch(e){case "left":return {...s,...l,x:t+4,y:o-4,anchor:"start"};case "above":return {...s,...l,x:m,y:o-6,anchor:"middle"};case "below":return {...s,...l,x:m,y:o+14,anchor:"middle"};case "center":return {...s,...l,x:m,y:o-4,anchor:"middle"};case "outside-left":return {...s,...l,x:t-6,y:o+3,anchor:"end",textBaseline:l.textBaseline??"middle"};case "outside-right":return {...s,...l,x:r+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:r-4,y:o-4,anchor:"end"}}}function $e(a){let{gaps:e,timeScale:t,yRange:r,fill:o=h.gapFill,hatch:n,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:d=h.gapFontColor,labelBaseline:c="middle",labelRotate:f}=a,[p,b]=r,y=[];for(let g of e){let S=t.map(g.startTime),$=t.map(g.endTime),C=g.fill??o,F=g.hatch??n,se=g.fillOpacity??i,le=g.label??"",ge=g.rotate??f,z=g.labelBaseline??c;if(g.style==="dashed_border"||!g.style?y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se,stroke:m,strokeWidth:s,dashed:l}):g.style==="empty"&&y.push({type:"rect",x:S,y:p,w:$-S,h:b-p,fill:C,hatch:F,opacity:se}),le){let ye=Fe(p,b,z),be=z==="above"?"top":z==="below"?"bottom":"middle";y.push({type:"text",content:le,x:(S+$)/2,y:ye,anchor:"middle",fontSize:u,fill:d,textBaseline:be,rotate:ge});}}return y}function Fe(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Pe(a){let{markers:e,timeScale:t,valueScale:r,yRange:o=[0,300]}=a,[n,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,d=s.pointStyle??(s.value!==void 0?"circle":"none"),c=s.lineStyle??"full";if(s.value!==void 0){let f=r.map(s.value);if(c==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="to-top"?m.push({type:"line",x1:l,y1:n,x2:l,y2:f,stroke:u,strokeWidth:1,dashed:true}):c==="full"&&m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),d!=="none"&&Re(m,l,f,u,d),s.label){let p=c==="to-value"?f-10:n-6;m.push({type:"text",content:s.label,x:l,y:p,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:n,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:n-6,anchor:"middle",fontSize:11,fill:u});}return m}function Re(a,e,t,r,o){let n=h.markerSize;switch(o){case "circle":a.push({type:"circle",cx:e,cy:t,r:n,fill:r});break;case "square":a.push({type:"rect",x:e-n,y:t-n,w:n*2,h:n*2,fill:r});break;case "cross":a.push({type:"line",x1:e-n,y1:t-n,x2:e+n,y2:t+n,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e-n,y1:t+n,x2:e+n,y2:t-n,stroke:r,strokeWidth:2});break;case "arrow":a.push({type:"path",points:[{x:e-n,y:t+n},{x:e,y:t-n},{x:e+n,y:t+n}],stroke:r,strokeWidth:2,fill:"none"});break;case "diamond":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t},{x:e,y:t+n},{x:e-n,y:t}],fill:r,stroke:"none"});break;case "triangle":a.push({type:"path",points:[{x:e,y:t-n},{x:e+n,y:t+n},{x:e-n,y:t+n}],fill:r,stroke:"none"});break;case "star":{let i=[],m=n*.4;for(let s=0;s<10;s++){let l=s%2===0?n:m,u=Math.PI/2*3+s*Math.PI/5;i.push({x:e+l*Math.cos(u),y:t+l*Math.sin(u)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "plus":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2}),a.push({type:"line",x1:e,y1:t-n,x2:e,y2:t+n,stroke:r,strokeWidth:2});break;case "triangle-down":a.push({type:"path",points:[{x:e,y:t+n},{x:e+n,y:t-n},{x:e-n,y:t-n}],fill:r,stroke:"none"});break;case "hexagon":{let i=[];for(let m=0;m<6;m++){let s=m*(Math.PI/3);i.push({x:e+n*Math.cos(s),y:t+n*Math.sin(s)});}a.push({type:"path",points:i,fill:r,stroke:"none"});break}case "hourglass":a.push({type:"path",points:[{x:e-n,y:t-n},{x:e+n,y:t-n},{x:e-n,y:t+n},{x:e+n,y:t+n}],fill:r,stroke:"none"});break;case "line-horizontal":a.push({type:"line",x1:e-n,y1:t,x2:e+n,y2:t,stroke:r,strokeWidth:2});break}}function Ae(a){let{highlights:e,timeScale:t,yRange:r,height:o}=a,[n,i]=r,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:n,w:u-l,h:i-n,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:We(s.labelPosition??"top",n,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function We(a,e,t,r){switch(a){case "above":return e-5;case "below":return r!==void 0?r-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function X(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function je(a){let{annotations:e,timeScale:t,valueScales:r}=a,o=[],n=i=>{let m=r.get(i.axis??0)??r.values().next().value;return {x:t.map(i.time),y:m?m.map(i.value):0}};for(let i of e){let m=[],s=l=>m.push(l);switch(i.type){case "line":{let l=n(i.from),u=n(i.to);s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:i.color??h.annotationColor,strokeWidth:i.width??h.annotationWidth,dash:i.dash});break}case "arrow":{let l=n(i.from),u=n(i.to),d=i.color??h.annotationColor,c=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:d,strokeWidth:i.width??h.annotationWidth});let f=Math.hypot(u.x-l.x,u.y-l.y)||1,p=(u.x-l.x)/f,b=(u.y-l.y)/f,y=u.x-p*c,g=u.y-b*c;s({type:"path",points:[{x:u.x,y:u.y},{x:y-b*c*.5,y:g+p*c*.5},{x:y+b*c*.5,y:g-p*c*.5}],fill:d,stroke:"none"});break}case "rect":{let l=n(i.from),u=n(i.to);s({type:"rect",x:Math.min(l.x,u.x),y:Math.min(l.y,u.y),w:Math.abs(u.x-l.x),h:Math.abs(u.y-l.y),fill:i.fill??"none",stroke:i.stroke,opacity:i.opacity});break}case "point":{let l=n(i.at),u=i.color??"#334155",d=i.radius??h.annotationRadius,c=i.shape??"circle";c==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:d,fill:u}):c==="square"?s({type:"rect",x:l.x-d,y:l.y-d,w:d*2,h:d*2,fill:u}):(s({type:"line",x1:l.x-d,y1:l.y-d,x2:l.x+d,y2:l.y+d,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-d,y1:l.y+d,x2:l.x+d,y2:l.y-d,stroke:u,strokeWidth:1.5}));break}case "label":{let l=n(i.at);s({type:"text",content:i.text,x:l.x+(i.dx??0),y:l.y+(i.dy??0),anchor:i.anchor??"middle",fontSize:h.annotationFontSize,fill:i.color??h.annotationColor,rotate:i.rotate});break}}if(i.id&&m.length>0){let l=X(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var U=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:r}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-r.left-r.right,chartHeight:t-r.top-r.bottom,chartX:r.left,chartY:r.top,margin:r}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var Z=class{#e;constructor(){this.#e=[];}add(e){this.#e.push(e);}clear(){this.#e=[];}isInside(e,t){return this.#e.length===0?true:this.#e.some(r=>e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(r=>`<rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" />`).join(`
|
|
29
29
|
`);return `<clipPath id="${e}">
|
|
30
30
|
${t}
|
|
31
|
-
</clipPath>`}get regions(){return [...this.#e]}};var W={axisColor:d.axisColor,tickColor:d.tickColor,textColor:d.textColor,textSize:d.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??W).axisColor}get tickColor(){return (this.#t.colors??W).tickColor}get textColor(){return (this.#t.colors??W).textColor}get textSize(){return (this.#t.colors??W).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(n=>({time:n,x:this.#e.map(n),label:this.tickLabel(n)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,r=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+r)/2,t,r),n={};return o<6e4?(n.hour="2-digit",n.minute="2-digit",n.second="2-digit"):o<36e5||o<864e5?(n.hour="2-digit",n.minute="2-digit"):o<31536e6?(n.day="numeric",n.month="short",o>=2592e6&&(n.day=void 0,n.month="long")):(n.year="numeric",o<2*31536e6&&(n.month="short")),this.#e.format(e,n)}antiOverlap(e){if(e.length<=1)return e;let t=60,r=[e[0]];for(let o=1;o<e.length;o++){let n=r[r.length-1].x;Math.abs(e[o].x-n)>=t&&r.push(e[o]);}return r}render(){let e=this.generateTicks(),t=this.#t.colors??W,r=this.#t.y??0,o=[],[n]=this.#e.range();o.push({type:"line",x1:n,y1:r,x2:e[e.length-1]?.x??n,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let i of e)o.push({type:"line",x1:i.x,y1:r,x2:i.x,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:i.label,x:i.x,y:r+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var O={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Oe(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ie(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let r=t;for(;r+1<a.length&&a[r+1].label===a[t].label;)r++;for(let o=t+1;o<r;o++)e[o]=true;t=r+1;}return e}var q=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).textSize}generateTicks(){let e=this.#t.format??Oe,t=6,[r,o]=this.#e.domain(),n=o-r;if(n===0)return [{value:r,position:this.#e.map(r),label:e(r)}];let i=n/t,m=Math.pow(10,Math.floor(Math.log10(i))),s=i/m,l;s<=1.5?l=m:s<=3?l=2*m:s<=7?l=5*m:l=10*m;let u=[],h=Math.ceil(r/l)*l;for(let c=h;c<=o;c+=l)u.push({value:c,position:this.#e.map(c),label:e(c)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??O,r=this.#t.x??0,o=this.#t.orientation??"vertical",n=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(h=>Math.abs(h-u)<=m),l=[];if(o==="vertical"){let[u,h]=this.#e.range();l.push({type:"line",x1:r,y1:u,x2:r,y2:h,stroke:t.axisColor,strokeWidth:t.axisWidth});let c=Ie(e);e.forEach((f,p)=>{let b=s(f.position),y=c[p]?{opacity:0}:{};n==="left"?(l.push({type:"line",x1:r-4,y1:f.position,x2:r,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r-8,y:f.position+4,anchor:"end",fontSize:11,fill:t.textColor,...y})):(l.push({type:"line",x1:r,y1:f.position,x2:r+4,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r+8,y:f.position+4,anchor:"start",fontSize:11,fill:t.textColor,...y}));});}else {let[u,h]=this.#e.range();l.push({type:"line",x1:u,y1:r,x2:h,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e)l.push({type:"line",x1:c.position,y1:r,x2:c.position,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:c.label,x:c.position,y:r+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var K=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((r,o)=>r-o).map(String);this.#t=t,this.#e=new A({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:r=true,gapValues:o}=this.#n,n=new Set(o??[]);return this.#t.map((i,m)=>{let s=Number(i),l=t?e[s]??String(s):String(s),u=this.#e.map(s),h=r?d.palette[m%d.palette.length]:void 0;return {value:s,label:l,y:u,color:h,isGap:n.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return d.palette[t%d.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,r=[];for(let o of e)o.isGap||r.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??d.textColor});return r}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"id"+Date.now+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var Q=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,r)=>t.x-r.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??d.stroke,strokeWidth:e.strokeWidth??d.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},r=e.pointThreshold??d.pointThreshold,o=e.gapThreshold??d.gapThreshold,n=e.id,i=x.getRuns(this.data,h=>h.value===null,o),m=i.reduce((h,c)=>h+c.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(h=>({data:h})),u=[];if(u.push(...w(l,s,{...t,id:n?`${n}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=r)for(let h of i)u.push(...P(h,s,{...t,id:n?`${n}-marker`:void 0},()=>t.stroke));return u}};var J=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(o=>o.value!==null).sort((o,n)=>o.time-n.time),r=[];for(let o=0;o<t.length;o++){let n=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?r.push({x:n,y:i}):(r.push({x:n,y:r[r.length-1].y}),r.push({x:n,y:i}));}return r}render(){let e=x.getRuns(this.data,o=>o.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},r=e.map(o=>({data:o}));return V(r,t,{stroke:this.#e.stroke??d.stroke,strokeWidth:this.#e.strokeWidth??d.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ee=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=Math.max(...this.data.map(r=>r.count));return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??d.bandFill,r=e.hatch,o=e.avgLine??false,n=e.avgLineColor??d.bandAvgLine,i=e.bandWidth??10,m=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let l=this.timeScale.map(s.time),u=e.valueScale.map(s.max),h=e.valueScale.map(s.min),c=i,f=this.data.indexOf(s);if(m.push({type:"rect",x:l-c/2,y:u,w:c,h:h-u,fill:t,hatch:r,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),o&&s.avg!==null){let p=e.valueScale.map(s.avg);m.push({type:"line",x1:l-c/2,y1:p,x2:l+c/2,y2:p,stroke:n,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return m}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??d.minColor,r=e.maxColor??d.maxColor,o=e.avgColor??d.avgColor,n=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??d.strokeWidth,s=x.getRuns(this.data,h=>h.min===null||h.max===null||h.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];for(let h of s)h.length<2||(e.fillToMax&&u.push(...B(h,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.max,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),e.fillToMin&&u.push(...B(h,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.min,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),u.push(...w([{data:h.map(c=>({time:c.time,value:c.max}))}],l,{stroke:r,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w([{data:h.map(c=>({time:c.time,value:c.min}))}],l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w([{data:h.map(c=>({time:c.time,value:c.avg}))}],l,{stroke:o,strokeWidth:m,smoothing:i,dashed:n,id:this.id?`${this.id}-avg`:void 0})));return u}};var ne=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,r)=>t.value-r.value);}#n(e){return e===0?this.#e.baseColor??d.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??d.stroke,r={stroke:t,strokeWidth:e.strokeWidth??d.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??d.pointSize},o=e.gapThreshold??d.gapThreshold,n=e.pointThreshold??d.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,h)=>u+h.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=[];for(let u of i){if(u.length<2)continue;if(e.fill){let p=e.fill.value,b=x.splitByBoundaries(u,[p],g=>g.value,x.interpolateDataPoint),y=e.valueScale.map(p);for(let g=0;g<b.length;g++){let S=b[g],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=p){let C=S.data.map(F=>({x:this.timeScale.map(F.time),y:e.valueScale.map(F.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${g}`:void 0,points:[...C,{x:C[C.length-1].x,y},{x:C[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let h=this.#t.map(p=>p.value),f=x.splitByBoundaries(u,h,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));l.push(...w(f,s,{...r,id:this.id?`${this.id}-line`:void 0})),r.pointStyle&&r.pointStyle!=="none"&&m<=n&&l.push(...P(u,s,{...r,id:this.id?`${this.id}-marker`:void 0},p=>{let b=t;for(let y of this.#t)p.value>=y.value&&(b=y.color);return b}));}return l}};var re=class{#e;constructor(e,t,r,o){this.#e={...e,xRange:t,y:r,height:o};}render(){let{items:e,timeScale:t,background:r,hatch:o,showAxis:n,xRange:i,y:m,height:s}=this.#e,l=[];r&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:r,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let h=t.map(u.startTime),c=t.map(u.endTime);if(!(c-h<1)&&(l.push({type:"rect",x:h,y:m,w:c-h,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let f=u.labelFontSize??10;l.push({type:"text",content:u.label,x:(h+c)/2,y:this.#t(u.labelBaseline,f),anchor:"middle",fontSize:f,fill:u.labelFill??"#333"});}}if(n){let u=new j({domain:t.domain(),xRange:i,y:m+s+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return l}#t(e,t){let{y:r,height:o}=this.#e;switch(e){case "top":return r+t*.9;case "bottom":return r+o-t*.25;default:return r+o/2+t*.35}}};var oe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:r,showMin:o=false,showMax:n=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=d.statsLineColor,labelColor:u=d.statsLabelColor}=this.#e,h=me.compute(e),c=[{name:"min",value:h.min,enabled:o},{name:"max",value:h.max,enabled:n},{name:"avg",value:h.avg,enabled:i},{name:"median",value:h.median,enabled:m}],f=[],[p,b]=r;for(let y of c.filter(g=>g.enabled)){let g=t.map(y.value);f.push({type:"line",x1:p,y1:g,x2:b,y2:g,stroke:l,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:p+4,y:g-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:b-4,y:g-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(p+b)/2,y:g-4,anchor:"middle",fontSize:10,fill:u});}return f}};var M=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,r){try{let o=this.#n&&r?this.#r(e,r,t):t;return new Intl.DateTimeFormat(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return new Intl.DateTimeFormat(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let r=this.format(e),o=this.format(t);return `${r} \u2014 ${o}`}#r(e,t,r){let o=Math.abs(e-t),n=864e5,i=36e5,m=6e4,s={};return o<m?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):o<i?(s.minute="2-digit",s.hour="2-digit"):o<n?(s.hour="2-digit",s.minute="2-digit"):o<7*n?(s.weekday="short",s.day="numeric"):o<365*n?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...r,...s}}};var D=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var _=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let r={};return e.forEach((o,n)=>{r[n]=o;}),new a({map:r,showValue:t})}};var Be={time:new M,value:new D,enum:new _};var He={...d};function ie(){return He}function ae(a,e){let t=ie();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ce(a){let e=a.style?.line;return e===false?[]:e===void 0?[ae({},a)]:Array.isArray(e)?e.map(t=>ae(t,a)):[ae(e,a)]}function he(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=ie(),o=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??o,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function de(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function pe(a){return a.style?.gap}function fe(a){return a.style?.fill}function ze(a){return {lines:ce(a),fill:fe(a),markers:he(a),shadow:de(a),gap:pe(a),id:a.style?.id??a.id}}/*!
|
|
31
|
+
</clipPath>`}get regions(){return [...this.#e]}};var W={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},j=class{#e;#t;constructor(e){this.#e=new R({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??W).axisColor}get tickColor(){return (this.#t.colors??W).tickColor}get textColor(){return (this.#t.colors??W).textColor}get textSize(){return (this.#t.colors??W).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(n=>({time:n,x:this.#e.map(n),label:this.tickLabel(n)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,r=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+r)/2,t,r),n={};return o<6e4?(n.hour="2-digit",n.minute="2-digit",n.second="2-digit"):o<36e5||o<864e5?(n.hour="2-digit",n.minute="2-digit"):o<31536e6?(n.day="numeric",n.month="short",o>=2592e6&&(n.day=void 0,n.month="long")):(n.year="numeric",o<2*31536e6&&(n.month="short")),this.#e.format(e,n)}antiOverlap(e){if(e.length<=1)return e;let t=60,r=[e[0]];for(let o=1;o<e.length;o++){let n=r[r.length-1].x;Math.abs(e[o].x-n)>=t&&r.push(e[o]);}return r}render(){let e=this.generateTicks(),t=this.#t.colors??W,r=this.#t.y??0,o=[],[n,i]=this.#e.range();o.push({type:"line",x1:n,y1:r,x2:i,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let m of e)o.push({type:"line",x1:m.x,y1:r,x2:m.x,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:m.label,x:m.x,y:r+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var O={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Oe(a){return Math.abs(a)>=1e6?`${(a/1e6).toFixed(1)}M`:Math.abs(a)>=1e3?`${(a/1e3).toFixed(1)}k`:Number.isInteger(a)?String(a):a.toFixed(1)}function Ie(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let r=t;for(;r+1<a.length&&a[r+1].label===a[t].label;)r++;for(let o=t+1;o<r;o++)e[o]=true;t=r+1;}return e}var q=class{#e;#t;constructor(e){this.#e=new L({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??O).axisColor}get tickColor(){return (this.#t.colors??O).tickColor}get textColor(){return (this.#t.colors??O).textColor}get textSize(){return (this.#t.colors??O).textSize}generateTicks(){let e=this.#t.format??Oe,t=6,[r,o]=this.#e.domain(),n=o-r;if(n===0)return [{value:r,position:this.#e.map(r),label:e(r)}];let i=n/t,m=Math.pow(10,Math.floor(Math.log10(i))),s=i/m,l;s<=1.5?l=m:s<=3?l=2*m:s<=7?l=5*m:l=10*m;let u=[],d=Math.ceil(r/l)*l;for(let c=d;c<=o;c+=l)u.push({value:c,position:this.#e.map(c),label:e(c)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??O,r=this.#t.x??0,o=this.#t.orientation??"vertical",n=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(d=>Math.abs(d-u)<=m),l=[];if(o==="vertical"){let[u,d]=this.#e.range();l.push({type:"line",x1:r,y1:u,x2:r,y2:d,stroke:t.axisColor,strokeWidth:t.axisWidth});let c=Ie(e);e.forEach((f,p)=>{let b=s(f.position),y=c[p]?{opacity:0}:{};n==="left"?(l.push({type:"line",x1:r-4,y1:f.position,x2:r,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r-8,y:f.position+4,anchor:"end",fontSize:11,fill:t.textColor,...y})):(l.push({type:"line",x1:r,y1:f.position,x2:r+4,y2:f.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),b||l.push({type:"text",content:f.label,x:r+8,y:f.position+4,anchor:"start",fontSize:11,fill:t.textColor,...y}));});}else {let[u,d]=this.#e.range();l.push({type:"line",x1:u,y1:r,x2:d,y2:r,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let c of e)l.push({type:"line",x1:c.position,y1:r,x2:c.position,y2:r+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:c.label,x:c.position,y:r+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var K=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((r,o)=>r-o).map(String);this.#t=t,this.#e=new A({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:r=true,gapValues:o}=this.#n,n=new Set(o??[]);return this.#t.map((i,m)=>{let s=Number(i),l=t?e[s]??String(s):String(s),u=this.#e.map(s),d=r?h.palette[m%h.palette.length]:void 0;return {value:s,label:l,y:u,color:d,isGap:n.has(s)}})}colorFor(e){let t=this.#t.indexOf(String(e));if(!(t===-1||!(this.#n.autoColor??true)))return h.palette[t%h.palette.length]}render(){let e=this.generateTicks(),t=this.#n.x??0,r=[];for(let o of e)o.isGap||r.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return r}map(e){return this.#e.map(e)}isGap(e){return new Set(this.#n.gapValues??[]).has(e)}};var v=class a{#e;#t;static uidcnt=0;#n;constructor(e,t=[]){this.#e=e.id??"id"+Date.now+ ++a.uidcnt,this.#t=e.timeScale,this.#n=t;}get id(){return this.#e}get timeScale(){return this.#t}get data(){return this.#n}};var Q=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale;return this.data.filter(t=>t.value!==null).map(t=>({x:this.timeScale.map(t.time),y:e.map(t.value),time:t.time})).sort((t,r)=>t.x-r.x)}render(){let e=this.#e,t={smoothing:e.smoothing??false,stroke:e.stroke??h.stroke,strokeWidth:e.strokeWidth??h.strokeWidth,dashed:e.dashed??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize,shadowColor:e.shadowColor,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY},r=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,n=e.id,i=x.getRuns(this.data,d=>d.value===null,o),m=i.reduce((d,c)=>d+c.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(d=>({data:d})),u=[];if(u.push(...w(l,s,{...t,id:n?`${n}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=r)for(let d of i)u.push(...P(d,s,{...t,id:n?`${n}-marker`:void 0},()=>t.stroke));return u}};var J=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(o=>o.value!==null).sort((o,n)=>o.time-n.time),r=[];for(let o=0;o<t.length;o++){let n=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?r.push({x:n,y:i}):(r.push({x:n,y:r[r.length-1].y}),r.push({x:n,y:i}));}return r}render(){let e=x.getRuns(this.data,o=>o.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},r=e.map(o=>({data:o}));return E(r,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ee=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=Math.max(...this.data.map(r=>r.count));return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,r=e.hatch,o=e.avgLine??false,n=e.avgLineColor??h.bandAvgLine,i=e.bandWidth??10,m=[];for(let s of this.data){if(s.min===null||s.max===null)continue;let l=this.timeScale.map(s.time),u=e.valueScale.map(s.max),d=e.valueScale.map(s.min),c=i,f=this.data.indexOf(s);if(m.push({type:"rect",x:l-c/2,y:u,w:c,h:d-u,fill:t,hatch:r,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${f}`:void 0}),o&&s.avg!==null){let p=e.valueScale.map(s.avg);m.push({type:"line",x1:l-c/2,y1:p,x2:l+c/2,y2:p,stroke:n,strokeWidth:1,id:this.id?`${this.id}-avg-${f}`:void 0});}}return m}};var te=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,r=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,n=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??h.strokeWidth,s=x.getRuns(this.data,d=>d.min===null||d.max===null||d.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];for(let d of s)d.length<2||(e.fillToMax&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.max,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax`:void 0})),e.fillToMin&&u.push(...B(d,l,{boundaries:[],yLow:c=>c.avg,yHigh:c=>c.min,getValue:c=>c.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin`:void 0})),u.push(...w([{data:d.map(c=>({time:c.time,value:c.max}))}],l,{stroke:r,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.min}))}],l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w([{data:d.map(c=>({time:c.time,value:c.avg}))}],l,{stroke:o,strokeWidth:m,smoothing:i,dashed:n,id:this.id?`${this.id}-avg`:void 0})));return u}};var ne=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,r)=>t.value-r.value);}#n(e){return e===0?this.#e.baseColor??h.stroke:this.#t[e-1].color}render(){let e=this.#e,t=e.baseColor??h.stroke,r={stroke:t,strokeWidth:e.strokeWidth??h.strokeWidth,smoothing:e.smoothing??false,pointStyle:e.pointStyle??"none",pointSize:e.pointSize??h.pointSize},o=e.gapThreshold??h.gapThreshold,n=e.pointThreshold??h.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,d)=>u+d.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=[];for(let u of i){if(u.length<2)continue;if(e.fill){let p=e.fill.value,b=x.splitByBoundaries(u,[p],g=>g.value,x.interpolateDataPoint),y=e.valueScale.map(p);for(let g=0;g<b.length;g++){let S=b[g],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=p){let C=S.data.map(F=>({x:this.timeScale.map(F.time),y:e.valueScale.map(F.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${g}`:void 0,points:[...C,{x:C[C.length-1].x,y},{x:C[0].x,y}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let d=this.#t.map(p=>p.value),f=x.splitByBoundaries(u,d,p=>p.value,x.interpolateDataPoint).map(p=>({data:p.data,color:this.#n(p.zoneIndex)}));l.push(...w(f,s,{...r,id:this.id?`${this.id}-line`:void 0})),r.pointStyle&&r.pointStyle!=="none"&&m<=n&&l.push(...P(u,s,{...r,id:this.id?`${this.id}-marker`:void 0},p=>{let b=t;for(let y of this.#t)p.value>=y.value&&(b=y.color);return b}));}return l}};var re=class{#e;constructor(e,t,r,o){this.#e={...e,xRange:t,y:r,height:o};}render(){let{items:e,timeScale:t,background:r,hatch:o,showAxis:n,xRange:i,y:m,height:s}=this.#e,l=[];r&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:r,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let d=t.map(u.startTime),c=t.map(u.endTime);if(!(c-d<1)&&(l.push({type:"rect",x:d,y:m,w:c-d,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let f=u.labelFontSize??10;l.push({type:"text",content:u.label,x:(d+c)/2,y:this.#t(u.labelBaseline,f),anchor:"middle",fontSize:f,fill:u.labelFill??"#333"});}}if(n){let u=new j({domain:t.domain(),xRange:i,y:m+s+4});l.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return l}#t(e,t){let{y:r,height:o}=this.#e;switch(e){case "top":return r+t*.9;case "bottom":return r+o-t*.25;default:return r+o/2+t*.35}}};var oe=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:r,showMin:o=false,showMax:n=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,d=me.compute(e),c=[{name:"min",value:d.min,enabled:o},{name:"max",value:d.max,enabled:n},{name:"avg",value:d.avg,enabled:i},{name:"median",value:d.median,enabled:m}],f=[],[p,b]=r;for(let y of c.filter(g=>g.enabled)){let g=t.map(y.value);f.push({type:"line",x1:p,y1:g,x2:b,y2:g,stroke:l,strokeWidth:1});let S=`${y.name}: ${y.value.toFixed(1)}`;(s==="start"||s==="both")&&f.push({type:"text",content:S,x:p+4,y:g-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&f.push({type:"text",content:S,x:b-4,y:g-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&f.push({type:"text",content:S,x:(p+b)/2,y:g-4,anchor:"middle",fontSize:10,fill:u});}return f}};var M=class{#e;#t;#n;constructor(e){this.#e=e?.locale||(typeof navigator<"u"?navigator.language:"en-US"),this.#t=e?.fallbackLocales??["en-US"],this.#n=e?.autoFormat??true;}format(e,t,r){try{let o=this.#n&&r?this.#r(e,r,t):t;return new Intl.DateTimeFormat(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return new Intl.DateTimeFormat(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let r=this.format(e),o=this.format(t);return `${r} \u2014 ${o}`}#r(e,t,r){let o=Math.abs(e-t),n=864e5,i=36e5,m=6e4,s={};return o<m?(s.second="2-digit",s.minute="2-digit",s.hour="2-digit"):o<i?(s.minute="2-digit",s.hour="2-digit"):o<n?(s.hour="2-digit",s.minute="2-digit"):o<7*n?(s.weekday="short",s.day="numeric"):o<365*n?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...r,...s}}};var D=class a{#e;#t;_compact;#n;constructor(e){this.#e=e?.unit??"",this.#t=e?.decimals??1,this._compact=e?.compact??false,this.#n=e?.custom;}format(e){if(this.#n)return this.#n(e);let t;return this._compact&&Math.abs(e)>=1e6?t=`${(e/1e6).toFixed(this.#t)}M`:this._compact&&Math.abs(e)>=1e3?t=`${(e/1e3).toFixed(this.#t)}k`:t=e.toFixed(this.#t),this.#e?`${t}${this.#e}`:t}formatRange(e,t){return `${this.format(e)} \u2014 ${this.format(t)}`}static unit(e,t=1){return new a({unit:e,decimals:t})}static temperature(e="\xB0C"){return new a({unit:e,decimals:1})}static percentage(){return new a({unit:"%",decimals:0})}};var _=class a{#e;#t;#n;constructor(e){this.#e=e?.map??{},this.#t=e?.fallback??(t=>String(t)),this.#n=e?.showValue??false;}format(e){let t=this.#e[e]??this.#t(e);return this.#n?`(${e}) ${t}`:t}has(e){return e in this.#e}labels(){return Object.values(this.#e)}values(){return Object.keys(this.#e).map(Number)}static fromLabels(e,t=false){let r={};return e.forEach((o,n)=>{r[n]=o;}),new a({map:r,showValue:t})}};var Be={time:new M,value:new D,enum:new _};var He={...h};function ie(){return He}function ae(a,e){let t=ie();return {color:a.color??t.stroke,width:a.width??t.strokeWidth,style:a.style??"solid",smoothing:a.smoothing??false,shape:a.shape??(e.seriesType==="step"?"step":"line"),gapThreshold:a.gapThreshold??t.gapThreshold,opacity:a.opacity??1}}function ce(a){let e=a.style?.line;return e===false?[]:e===void 0?[ae({},a)]:Array.isArray(e)?e.map(t=>ae(t,a)):[ae(e,a)]}function de(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=ie(),o=(a.style?.line&&!Array.isArray(a.style.line)?a.style.line.color:void 0)??t.stroke;return {type:e.type,size:e.size??t.pointSize,stroke:e.stroke??o,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function he(a){let e=a.style?.shadow;if(!(!e?.color||e.color==="transparent"||e.color==="none"))return {color:e.color,blur:e.blur??4,offsetX:e.offsetX??0,offsetY:e.offsetY??0}}function pe(a){return a.style?.gap}function fe(a){return a.style?.fill}function ze(a){return {lines:ce(a),fill:fe(a),markers:de(a),shadow:he(a),gap:pe(a),id:a.style?.id??a.id}}/*!
|
|
32
32
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
33
33
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
34
34
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -47,4 +47,4 @@ var E=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
47
47
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
48
48
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
49
49
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
50
|
-
*/export{re as AnnotationBandSeries,A as BandScale,ee as BandSeries,Z as Clip,K as EnumAxis,_ as EnumFormatter,Be as Formatters,U as Layout,Q as LineSeries,L as LinearScale,te as MinMaxAvgSeries,
|
|
50
|
+
*/export{re as AnnotationBandSeries,A as BandScale,ee as BandSeries,Z as Clip,K as EnumAxis,_ as EnumFormatter,Be as Formatters,U as Layout,Q as LineSeries,L as LinearScale,te as MinMaxAvgSeries,V as Renderer,oe as StatsOverlay,J as StepSeries,k as TIME_INTERVALS,j as TimeAxis,M as TimeFormatter,R as TimeScale,q as ValueAxis,D as ValueFormatter,ne as ZonedLineSeries,ue as getHatch,we as measureLegend,je as renderAnnotations,xe as renderArea,$e as renderGaps,Te as renderGrid,Ae as renderHighlights,Ce as renderLegend,w as renderLine,Pe as renderMarkers,P as renderSeriesMarkers,Se as renderSplitLine,E as renderStep,De as renderThresholds,B as renderZonedArea,fe as resolveFill,pe as resolveGap,ce as resolveLines,de as resolveMarkers,ze as resolveSeriesStyle,he as resolveShadow,X as slugify,h as theme};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as DrawCommand, s as DrawGroup, _ as PointStyleType } from './scale-
|
|
1
|
+
import { o as DrawCommand, s as DrawGroup, _ as PointStyleType } from './scale-DFyECKZq.js';
|
|
2
2
|
|
|
3
3
|
/** Output format type for the renderer (SVG string, Canvas, or nothing). */
|
|
4
|
-
type RenderType =
|
|
4
|
+
type RenderType = "svg" | "canvas" | "none";
|
|
5
5
|
|
|
6
6
|
/*!
|
|
7
7
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -170,7 +170,7 @@ interface LegendItem {
|
|
|
170
170
|
color: string;
|
|
171
171
|
}
|
|
172
172
|
/** Layout direction for legend items. */
|
|
173
|
-
type LegendOrientation =
|
|
173
|
+
type LegendOrientation = "vertical" | "horizontal";
|
|
174
174
|
/** Configuration for legend rendering including items, position, and orientation. */
|
|
175
175
|
interface LegendConfig {
|
|
176
176
|
items: LegendItem[];
|
|
@@ -195,7 +195,7 @@ interface Marker {
|
|
|
195
195
|
label?: string;
|
|
196
196
|
color?: string;
|
|
197
197
|
pointStyle?: PointStyleType;
|
|
198
|
-
lineStyle?:
|
|
198
|
+
lineStyle?: "full" | "to-value" | "to-top";
|
|
199
199
|
seriesIndex?: number;
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -232,7 +232,7 @@ interface LayoutResult {
|
|
|
232
232
|
/** Pixel Y offset of chart area */
|
|
233
233
|
chartY: number;
|
|
234
234
|
/** Margins used */
|
|
235
|
-
margin: LayoutConfig[
|
|
235
|
+
margin: LayoutConfig["margin"];
|
|
236
236
|
}
|
|
237
237
|
declare class Layout {
|
|
238
238
|
readonly _config: LayoutConfig;
|
|
@@ -50,7 +50,7 @@ type LineVariant = "solid" | "dotted" | "sparse-dots" | "dashed" | "long-dash" |
|
|
|
50
50
|
*/
|
|
51
51
|
type Dashstyle_t = LineVariant;
|
|
52
52
|
interface DrawPath extends DrawEffects {
|
|
53
|
-
type:
|
|
53
|
+
type: "path";
|
|
54
54
|
points: Point[];
|
|
55
55
|
smoothing?: boolean;
|
|
56
56
|
/**
|
|
@@ -74,7 +74,7 @@ interface DrawPath extends DrawEffects {
|
|
|
74
74
|
id?: string;
|
|
75
75
|
}
|
|
76
76
|
interface DrawLine extends DrawEffects {
|
|
77
|
-
type:
|
|
77
|
+
type: "line";
|
|
78
78
|
x1: number;
|
|
79
79
|
y1: number;
|
|
80
80
|
x2: number;
|
|
@@ -89,7 +89,7 @@ interface DrawLine extends DrawEffects {
|
|
|
89
89
|
id?: string;
|
|
90
90
|
}
|
|
91
91
|
interface DrawRect extends DrawEffects {
|
|
92
|
-
type:
|
|
92
|
+
type: "rect";
|
|
93
93
|
x: number;
|
|
94
94
|
y: number;
|
|
95
95
|
w: number;
|
|
@@ -104,7 +104,7 @@ interface DrawRect extends DrawEffects {
|
|
|
104
104
|
id?: string;
|
|
105
105
|
}
|
|
106
106
|
interface DrawCircle extends DrawEffects {
|
|
107
|
-
type:
|
|
107
|
+
type: "circle";
|
|
108
108
|
cx: number;
|
|
109
109
|
cy: number;
|
|
110
110
|
r: number;
|
|
@@ -116,7 +116,7 @@ interface DrawCircle extends DrawEffects {
|
|
|
116
116
|
id?: string;
|
|
117
117
|
}
|
|
118
118
|
interface DrawText {
|
|
119
|
-
type:
|
|
119
|
+
type: "text";
|
|
120
120
|
content: string;
|
|
121
121
|
x: number;
|
|
122
122
|
y: number;
|
|
@@ -129,20 +129,20 @@ interface DrawText {
|
|
|
129
129
|
opacity?: number;
|
|
130
130
|
/** Rotation in degrees, around (x, y). Used e.g. for vertical axis labels. */
|
|
131
131
|
rotate?: number;
|
|
132
|
-
textBaseline?:
|
|
132
|
+
textBaseline?: "top" | "middle" | "bottom";
|
|
133
133
|
/** Optional SVG `id` attribute for this element. */
|
|
134
134
|
id?: string;
|
|
135
135
|
}
|
|
136
|
-
type DrawDirection_t =
|
|
136
|
+
type DrawDirection_t = "vertical" | "horizontal";
|
|
137
137
|
interface DrawGradient {
|
|
138
|
-
type:
|
|
138
|
+
type: "gradient";
|
|
139
139
|
points: Point[];
|
|
140
140
|
stops: GradientStop[];
|
|
141
141
|
direction: DrawDirection_t;
|
|
142
142
|
}
|
|
143
|
-
type DrawGapType_t$1 =
|
|
143
|
+
type DrawGapType_t$1 = "dashed_border" | "empty" | "label";
|
|
144
144
|
interface DrawGap {
|
|
145
|
-
type:
|
|
145
|
+
type: "gap";
|
|
146
146
|
x1: number;
|
|
147
147
|
y1: number;
|
|
148
148
|
x2: number;
|
|
@@ -153,7 +153,7 @@ interface DrawGap {
|
|
|
153
153
|
id?: string;
|
|
154
154
|
}
|
|
155
155
|
interface DrawGroup {
|
|
156
|
-
type:
|
|
156
|
+
type: "group";
|
|
157
157
|
commands: DrawCommand[];
|
|
158
158
|
cssClass?: string;
|
|
159
159
|
/** Optional SVG `id` attribute for this group. */
|
|
@@ -169,11 +169,11 @@ interface DrawGroup {
|
|
|
169
169
|
}
|
|
170
170
|
/** Union aller Commands */
|
|
171
171
|
type DrawCommand = DrawPath | DrawLine | DrawRect | DrawCircle | DrawText | DrawGradient | DrawGap | DrawGroup;
|
|
172
|
-
type LineParams = Omit<DrawLine,
|
|
173
|
-
type PathParams = Omit<DrawPath,
|
|
174
|
-
type RectParams = Omit<DrawRect,
|
|
175
|
-
type CircleParams = Omit<DrawCircle,
|
|
176
|
-
type TextParams = Omit<DrawText,
|
|
172
|
+
type LineParams = Omit<DrawLine, "type">;
|
|
173
|
+
type PathParams = Omit<DrawPath, "type">;
|
|
174
|
+
type RectParams = Omit<DrawRect, "type">;
|
|
175
|
+
type CircleParams = Omit<DrawCircle, "type">;
|
|
176
|
+
type TextParams = Omit<DrawText, "type">;
|
|
177
177
|
|
|
178
178
|
/*!
|
|
179
179
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -444,48 +444,48 @@ type SeriesOverlayKind = SeriesOverlay["kind"];
|
|
|
444
444
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
445
445
|
*/
|
|
446
446
|
|
|
447
|
-
/**
|
|
447
|
+
/** Single data point — numeric value or integer enum key. */
|
|
448
448
|
interface DataPoint {
|
|
449
|
-
/**
|
|
449
|
+
/** Time (ms timestamp). */
|
|
450
450
|
time: number;
|
|
451
|
-
/**
|
|
451
|
+
/** Numeric value or integer enum key; null = gap (the line breaks here). */
|
|
452
452
|
value: number | null;
|
|
453
|
-
/**
|
|
453
|
+
/** Optional annotation text. */
|
|
454
454
|
annotation?: string;
|
|
455
455
|
/**
|
|
456
|
-
*
|
|
457
|
-
* `SeriesProcessor`
|
|
458
|
-
*
|
|
459
|
-
*
|
|
456
|
+
* Synthetic point — not a real measurement. Set automatically by the
|
|
457
|
+
* `SeriesProcessor` on interpolated points (threshold intersections, gap
|
|
458
|
+
* edges), but can also be set manually for computed helper points (e.g. a
|
|
459
|
+
* trend line over interpolated values).
|
|
460
460
|
*
|
|
461
|
-
* Renderer
|
|
462
|
-
*
|
|
463
|
-
*
|
|
461
|
+
* Renderer consequences: no point marker, no tooltip snap, no entry in the
|
|
462
|
+
* value table. Scales (Y min/max) still count the point, otherwise the line
|
|
463
|
+
* geometry would be distorted. Defaults to `undefined` = real measurement.
|
|
464
464
|
*
|
|
465
|
-
*
|
|
465
|
+
* See API_DESIGN.md §4.1.
|
|
466
466
|
*/
|
|
467
467
|
synthetic?: boolean;
|
|
468
468
|
}
|
|
469
|
-
/**
|
|
469
|
+
/** Aggregated measurement per time slot (hourly/daily/custom). */
|
|
470
470
|
interface AggregatedPoint {
|
|
471
|
-
/** Slot
|
|
471
|
+
/** Slot start time (ms). */
|
|
472
472
|
time: number;
|
|
473
|
-
/** Minimum
|
|
473
|
+
/** Minimum value; null = gap slot. */
|
|
474
474
|
min: number | null;
|
|
475
|
-
/** Maximum
|
|
475
|
+
/** Maximum value; null = gap slot. */
|
|
476
476
|
max: number | null;
|
|
477
|
-
/**
|
|
477
|
+
/** Average; null = gap slot. */
|
|
478
478
|
avg: number | null;
|
|
479
|
-
/**
|
|
479
|
+
/** Number of raw data points in the slot. */
|
|
480
480
|
count: number;
|
|
481
481
|
}
|
|
482
|
-
/** Sensor
|
|
482
|
+
/** Sensor type */
|
|
483
483
|
type SensorType = "numeric" | "enum";
|
|
484
484
|
/** Map from enum value (number) to human-readable label */
|
|
485
485
|
interface EnumMap {
|
|
486
486
|
[key: number]: string;
|
|
487
487
|
}
|
|
488
|
-
/** Raw
|
|
488
|
+
/** Raw series (numeric or enum) */
|
|
489
489
|
interface TimeSeries {
|
|
490
490
|
name: string;
|
|
491
491
|
data: DataPoint[];
|
|
@@ -510,11 +510,11 @@ interface TimeSeries {
|
|
|
510
510
|
/** Optional SVG id prefix for series elements. */
|
|
511
511
|
id?: string;
|
|
512
512
|
}
|
|
513
|
-
/**
|
|
513
|
+
/** Aggregated series: min/max/avg per slot. */
|
|
514
514
|
interface AggregatedSeries {
|
|
515
515
|
name: string;
|
|
516
516
|
data: AggregatedPoint[];
|
|
517
|
-
/** 'band' =
|
|
517
|
+
/** 'band' = filled rectangle per slot; 'minmaxavg' = min/max/avg lines + optional fill */
|
|
518
518
|
showAs?: "band" | "minmaxavg";
|
|
519
519
|
yAxisIndex?: number;
|
|
520
520
|
avgLine?: boolean;
|
|
@@ -531,20 +531,20 @@ interface AggregatedSeries {
|
|
|
531
531
|
minColor?: string;
|
|
532
532
|
maxColor?: string;
|
|
533
533
|
avgColor?: string;
|
|
534
|
-
/**
|
|
534
|
+
/** Avg line dashed (default: true). */
|
|
535
535
|
avgDashed?: boolean;
|
|
536
|
-
/**
|
|
536
|
+
/** Semi-transparent fill between avg and max */
|
|
537
537
|
fillToMax?: string;
|
|
538
538
|
/** Hatch pattern for fillToMax */
|
|
539
539
|
fillToMaxHatch?: HatchVariant;
|
|
540
|
-
/**
|
|
540
|
+
/** Semi-transparent fill between avg and min */
|
|
541
541
|
fillToMin?: string;
|
|
542
542
|
/** Hatch pattern for fillToMin */
|
|
543
543
|
fillToMinHatch?: HatchVariant;
|
|
544
544
|
/** Optional SVG id prefix for series elements. */
|
|
545
545
|
id?: string;
|
|
546
546
|
}
|
|
547
|
-
/** Series
|
|
547
|
+
/** Series type: raw, enum, or aggregated */
|
|
548
548
|
type AnySeries = TimeSeries | AggregatedSeries;
|
|
549
549
|
/** Time range gap with optional label and style */
|
|
550
550
|
interface Gap {
|
|
@@ -555,7 +555,7 @@ interface Gap {
|
|
|
555
555
|
/** Hatch pattern for gap fill */
|
|
556
556
|
hatch?: HatchVariant;
|
|
557
557
|
fillOpacity?: number;
|
|
558
|
-
labelBaseline?:
|
|
558
|
+
labelBaseline?: "above" | "middle" | "below";
|
|
559
559
|
rotate?: number;
|
|
560
560
|
style?: DrawGapType_t$1;
|
|
561
561
|
}
|
|
@@ -718,9 +718,9 @@ interface AnnotationBandItem {
|
|
|
718
718
|
/** Label fill color (default: inherit from theme). */
|
|
719
719
|
labelFill?: string;
|
|
720
720
|
/**
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
labelBaseline?:
|
|
721
|
+
* Label vertical position: 'top', 'middle' (default), or 'bottom' inside the band.
|
|
722
|
+
*/
|
|
723
|
+
labelBaseline?: "top" | "middle" | "bottom";
|
|
724
724
|
}
|
|
725
725
|
/**
|
|
726
726
|
* Configuration for an annotation band — a horizontal strip below the main chart
|