ml-time-graph 1.1.1 → 1.3.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 +6 -3
- package/USAGE.md +44 -2
- package/dist/analyze/index.d.ts +15 -1
- package/dist/analyze/index.js +2 -2
- package/dist/index.d.ts +73 -15
- package/dist/index.js +34 -38
- package/dist/interaction/index.d.ts +2 -2
- package/dist/interaction/index.js +2 -2
- package/dist/internals.d.ts +12 -15
- package/dist/internals.js +20 -24
- package/dist/{layout-DDdMtPrB.d.ts → layout-CXwTQBSN.d.ts} +6 -6
- package/dist/{scale-DcFBNLdU.d.ts → scale-CWAa8-uO.d.ts} +52 -52
- package/docs/MKT_AGGREGATE.md +66 -68
- package/package.json +65 -66
package/dist/internals.js
CHANGED
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
var
|
|
1
|
+
var N=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time+Math.round(t*(e.time-a.time)),value:(a.value??0)+t*((e.value??0)-(a.value??0))}}static interpolateAggregatedPoint(a,e,t){let n=(o,r)=>o!==null&&r!==null?o+t*(r-o):null;return {time:a.time+t*(e.time-a.time),min:n(a.min,e.min),max:n(a.max,e.max),avg:n(a.avg,e.avg),count:Math.round(a.count+t*(e.count-a.count))}}static getRuns(a,e,t=0){let n=[...a].sort((m,s)=>m.time-s.time),o=[],r=[],i=null;for(let m of n){let s=e(m),l=t>0&&i&&m.time-i.time>t;(s||l)&&r.length&&(o.push(r),r=[]),s||r.push(m),i=m;}return r.length&&o.push(r),o}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0}];let o=[...e].sort((s,l)=>s-l),r=[],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],c=t(l),d=t(u),p;d>c?p=o.filter(f=>f>c&&f<=d):d<c?p=o.filter(f=>f>=d&&f<c).reverse():p=[];for(let f of p){let g=(f-c)/(d-c),b=n(l,u,g);m.push(b),r.push({data:m,zoneIndex:i((c+f)/2)}),m=[b];}m.push(u);}if(m.length>0){let s=t(m[0]),l=t(m[m.length-1]);r.push({data:m,zoneIndex:i((s+l)/2)});}return r}static splitByThreshold(a,e,t,n){let o=this.splitByBoundaries(a,[e],t,n),r={above:[],below:[]};for(let i of o)i.zoneIndex===0?r.below.push(i.data):r.above.push(i.data);return r}};var ce=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,n=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,r=e.reduce((m,s)=>m+Math.pow(s-n,2),0)/t,i=Math.sqrt(r);return {min:e[0],max:e[t-1],avg:n,mean:n,median:o,stdDev:i,count:t}}static computeInRange(a,e,t){let n=a.filter(o=>o.time>=e&&o.time<=t);return this.compute(n)}};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 de(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n="#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>
|
|
5
|
-
`.trim();let
|
|
6
|
-
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${
|
|
7
|
-
<line x1="0" y1="0" x2="${
|
|
8
|
-
`;break;case "dots":
|
|
9
|
-
<path d="M 0 ${i/2} Q ${
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`;break;case "
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
`;break;case "
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<path d="M 0 0 L ${n/2} 5 L ${n} 0 M 0 16 L ${n/2} 11 L ${n} 16 M 0 16 L 0 32 M ${n/2} 5 L ${n/2} 11 M ${n} 16 L ${n} 32 M 0 32 L ${n/2} 27 L ${n} 32 M ${n/2} 27 L ${n/2} 32"
|
|
22
|
-
fill="none" stroke="${r}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
|
|
23
|
-
`;break}let l=`<rect width="${n}" height="${i}" fill="${t}" />`;return `
|
|
24
|
-
<pattern id="${a}" width="${n}" height="${i}" patternTransform="${m}" patternUnits="userSpaceOnUse">
|
|
5
|
+
`.trim();let r=12,i=12,m="rotate(0)",s="";switch(e){case "classic-diagonal":r=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "dense-steep":r=6,i=6,m="rotate(30)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />`;break;case "crosshatch":r=14,i=14,m="rotate(45)",s=`
|
|
6
|
+
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
|
|
7
|
+
<line x1="0" y1="0" x2="${r}" y2="0" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
|
|
8
|
+
`;break;case "dots":r=12,i=12,s=`<circle cx="${r/2}" cy="${i/2}" r="${o*1.2}" fill="${n}" />`;break;case "waves":r=16,i=16,s=`
|
|
9
|
+
<path d="M 0 ${i/2} Q ${r/4} 0, ${r/2} ${i/2} T ${r} ${i/2}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linecap="round" />
|
|
10
|
+
`;break;case "dashed":r=12,i=12,m="rotate(45)",s=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-dasharray="3,3" />`;break;case "herringbone":r=16,i=16,s=`
|
|
11
|
+
<path d="M 0 0 L ${r/2} ${i/2} L 0 ${i} M ${r} 0 L ${r/2} ${i/2} L ${r} ${i}" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
|
|
12
|
+
`;break;case "brick":r=20,i=20,s=`
|
|
13
|
+
<path d="M 0 ${i/2} L ${r} ${i/2} M 0 ${i} L ${r} ${i} M ${r/2} 0 L ${r/2} ${i/2} M 0 ${i/2} L 0 ${i}" fill="none" stroke="${n}" stroke-width="${o}" />
|
|
14
|
+
`;break;case "double-stripe":r=16,i=16,m="rotate(45)",s=`
|
|
15
|
+
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${n}" stroke-width="${o}" stroke-linecap="square" />
|
|
16
|
+
<line x1="${r/2}" y1="0" x2="${r/2}" y2="${i}" stroke="${n}" stroke-width="${o/2}" stroke-linecap="square" />
|
|
17
|
+
`;break;case "honeycomb":r=18,i=32,s=`
|
|
18
|
+
<path d="M 0 0 L ${r/2} 5 L ${r} 0 M 0 16 L ${r/2} 11 L ${r} 16 M 0 16 L 0 32 M ${r/2} 5 L ${r/2} 11 M ${r} 16 L ${r} 32 M 0 32 L ${r/2} 27 L ${r} 32 M ${r/2} 27 L ${r/2} 32" fill="none" stroke="${n}" stroke-width="${o}" stroke-linejoin="round" stroke-linecap="round" />
|
|
19
|
+
`;break}let l=`<rect width="${r}" height="${i}" fill="${t}" />`;return `
|
|
20
|
+
<pattern id="${a}" width="${r}" height="${i}" patternTransform="${m}" patternUnits="userSpaceOnUse">
|
|
25
21
|
${l}
|
|
26
22
|
${s}
|
|
27
23
|
</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(`
|
|
24
|
+
`.trim()}function B(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 n=[],o=a.reduce((i,m)=>i+m.data.length,0),r=B(t);for(let i=0;i<a.length;i++){let m=a[i];m.data.length>=2?n.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??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:r.line.smoothing,dashed:r.line.dashed,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur,shadowOffsetX:r.shadow.offsetX,shadowOffsetY:r.shadow.offsetY,fill:"none"}):m.data.length===1&&o===1&&n.push({type:"circle",cx:e.timeScale.map(m.data[0].time),cy:e.valueScale.map(m.data[0].value),r:Math.max(r.markers.size,r.line.strokeWidth),fill:m.color??r.line.stroke,shadowColor:r.shadow.color,shadowBlur:r.shadow.blur});}return n}function ve(a){let e=[];for(let t of a)e.length===0?e.push(t):e.push({x:t.x,y:e[e.length-1].y},t);return e}function G(a,e,t){let n=[],o=B(t);for(let r=0;r<a.length;r++){let i=a[r];if(i.data.length<2)continue;let m=ve(i.data.map(s=>({x:e.timeScale.map(s.time),y:e.valueScale.map(s.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${r}`:void 0,points:m,stroke:i.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:false,fill:"none"});}return n}function we(a,e,t,n,o){let r=[],i=B(t);for(let m=0;m<a.length;m++){let s=a[m];if(s.data.length<2)continue;let l=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(o(c))})).reverse();r.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 r}function H(a,e,t,n){if(a.length<2)return [];let o=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),r=[];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(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=m.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();r.push({type:"path",id:n?.id?`${n.id}-fill-${i}`:void 0,points:[...l,...u],fill:s,hatch:t.getHatch?.(m.zoneIndex),stroke:"none"});}return r}function Ce(a,e,t,n){let o=x.splitByThreshold(a,e,i=>i.value,x.interpolateDataPoint),r=[];return n.below&&r.push(...w(o.below.map(i=>({data:i})),t,n.below)),n.above&&r.push(...w(o.above.map(i=>({data:i})),t,n.above)),r}function P(a,e,t,n){let o=B(t);if(!o.markers.type||o.markers.type==="none")return [];let r=[];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=n(m),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${i}`:void 0;z(r,f,o.markers.type,s,l,o.markers.size,c,d,p);}return r}function z(a,e,t,n,o,r,i,m,s){switch(t){case "circle":a.push({type:"circle",cx:n,cy:o,r,fill:m,stroke:i,strokeWidth:s,id:e});break;case "square":a.push({type:"rect",x:n-r,y:o-r,w:r*2,h:r*2,fill:m,stroke:i,strokeWidth:s,id:e});break;case "cross":a.push({type:"line",x1:n-r,y1:o-r,x2:n+r,y2:o+r,stroke:i,strokeWidth:s,id:e},{type:"line",x1:n-r,y1:o+r,x2:n+r,y2:o-r,stroke:i,strokeWidth:s,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o},{x:n,y:o+r},{x:n-r,y:o}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:o-r},{x:n+r,y:o+r},{x:n-r,y:o+r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "star":{let l=[];for(let u=0;u<10;u++){let c=u%2===0?r:r*.5,d=Math.PI/2*3+u*Math.PI/5;l.push({x:n+c*Math.cos(d),y:o+c*Math.sin(d)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-r,y:o+r},{x:n,y:o-r},{x:n+r,y:o+r}],stroke:i,strokeWidth:s,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:i,strokeWidth:s,id:e},{type:"line",x1:n,y1:o-r,x2:n,y2:o+r,stroke:i,strokeWidth:s,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:o+r},{x:n+r,y:o-r},{x:n-r,y:o-r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "hexagon":{let l=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);l.push({x:n+r*Math.cos(c),y:o+r*Math.sin(c)});}a.push({type:"path",points:l,fill:m,stroke:i,strokeWidth:s,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-r,y:o-r},{x:n+r,y:o-r},{x:n-r,y:o+r},{x:n+r,y:o+r}],fill:m,stroke:i,strokeWidth:s,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-r,y1:o,x2:n+r,y2:o,stroke:i,strokeWidth:s,id:e});break;default:a.push({type:"circle",cx:n,cy:o,r,fill:m,stroke:i,strokeWidth:s,id:e});}}var T=12,V=8,Y=20,Te=11,X=18,Z=a=>a.length*Te*.6;function Le(a,e="vertical"){if(e==="horizontal"){let n=0;for(let o of a)n+=T+V+Z(o.name)+X;return {width:Math.max(0,n-X),height:Y}}let t=0;for(let n of a)t=Math.max(t,Z(n.name));return {width:T+V+t,height:a.length*Y}}function De(a){let{items:e,x:t,y:n,orientation:o="vertical"}=a,r=[],i=t;return e.forEach((m,s)=>{let l=o==="horizontal"?i:t,u=o==="horizontal"?n:n+s*Y;r.push({type:"rect",x:l,y:u,w:T,h:T,fill:m.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:m.name,x:l+T+V,y:u+T-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=T+V+Z(m.name)+X);}),{type:"group",cssClass:"chart-legend",commands:r}}function Me(a){let{xTicks:e,yTicks:t,xRange:n,yRange:o,stroke:r=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:n[0],y1:u,x2:n[1],y2:u,stroke:r,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:r,strokeWidth:i,dashed:m,opacity:s});return l}var he=new Map;function _e(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=_e(a,e),n=he.get(t);return n||(n=new Intl.DateTimeFormat(a,e),he.set(t,n)),n}var L=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,o]=this.#e,[r,i]=this.#t;return o===n?r:r+(t-n)/(o-n)*(i-r)}invert(e){let[t,n]=this.#e,[o,r]=this.#t;return r===o?t:t+(e-o)/(r-o)*(n-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,n=12){let[o,r]=this.#e.domain(),i=r-o;if(i<=0)return {interval:k[0].ms};let m=i/e,s=k[0].ms;for(let c of k)if(c.ms>=m){s=c.ms;break}let l=s,u=Math.round(i/l);for(;u>n&&l<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===l);l=k[Math.min(c+1,k.length-1)].ms,u=Math.round(i/l);}for(;u<t&&l>k[0].ms;){let c=k.findIndex(d=>d.ms===l);l=k[Math.max(c-1,0)].ms,u=Math.round(i/l);}return {interval:l}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:o}=this.tickInterval((t+n)/2,t,n),[r,i]=this.#e.domain(),m=[],s=Math.ceil(r/o)*o;for(let l=s;l<=i;l+=o)m.push(l);return m}format(e,t){return A(this.#t,t).format(new Date(e))}},W=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,n=this.#e.length;return n<=1?Math.abs(t-e):Math.abs(t-e)*(1-this.#r*2)/n+Math.abs(t-e)*this.#n*2/n}get bandwidth(){let[e,t]=this.#t,n=this.#e.length;if(n<=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)/n*(1-this.#n)}map(e){let t=this.#e.findIndex(c=>String(c)===String(e));if(t===-1)return this.#t[0];let[n,o]=this.#t,r=this.#e.length;if(r<=1)return (n+o)/2;let i=this.#r*2*Math.abs(o-n),m=Math.abs(o-n)-i,s=o>=n?1:-1,l=m/r;return n+this.#r*Math.abs(o-n)*s+t*l}invert(e){let t=0,n=1/0;for(let o=0;o<this.#e.length;o++){let r=this.map(this.#e[o]),i=Math.abs(e-r);i<n&&(n=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 $e(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Fe(a){let{thresholds:e,valueScale:t,xRange:n}=a,[o,r]=n,[i,m]=t.range(),s=Math.min(i,m),l=Math.max(i,m),u=[],c=[];for(let d of e){let p=d.color??h.thresholdColor,f=t.map(d.value);d.fill==="above"?u.push({type:"rect",x:o,y:s,w:r-o,h:Math.max(0,f-s),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0}):d.fill==="below"&&u.push({type:"rect",x:o,y:f,w:r-o,h:Math.max(0,l-f),fill:p,hatch:d.fillHatch,opacity:d.fillOpacity??.12,id:d.id?`${d.id}-fill`:void 0});let g=d.line??h.thresholdLine;if(g!=="none"){let b=$e(g),y={type:"line",x1:o,y1:f,x2:r,y2:f,stroke:p,strokeWidth:1,...b,id:d.id?`${d.id}-line`:void 0};d.shadowColor&&(y.shadowColor=d.shadowColor,y.shadowBlur=d.shadowBlur??4,y.shadowOffsetX=d.shadowOffsetX??0,y.shadowOffsetY=d.shadowOffsetY??2),u.push(y);}if(d.label!==false){let b=d.label&&typeof d.label=="object"?d.label:void 0,y=typeof d.label=="string"?d.label:b?.text??d.name,S=b?.position??"right";c.push({...Ae(y,S,o,r,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Pe(a){let e=Fe(a);return [...e.inside,...e.labels]}function Ae(a,e,t,n,o,r,i){let m=(t+n)/2,s={type:"text",content:a,fontSize:h.thresholdFontSize,fill:r},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:n+6,y:o+3,anchor:"start",textBaseline:l.textBaseline??"middle"};default:return {...s,...l,x:n-4,y:o-4,anchor:"end"}}}function Re(a){let{gaps:e,timeScale:t,yRange:n,fill:o=h.gapFill,hatch:r,fillOpacity:i=h.gapFillOpacity??.15,stroke:m=h.gapStroke,strokeWidth:s=h.gapStrokeWidth,dashed:l=true,fontSize:u=h.gapFontSize,fontFill:c=h.gapFontColor,labelBaseline:d="middle",labelRotate:p}=a,[f,g]=n,b=[];for(let y of e){let S=t.map(y.startTime),$=t.map(y.endTime),C=y.fill??o,F=y.hatch??r,me=y.fillOpacity??i,ue=y.label??"",xe=y.rotate??p,E=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:$-S,h:g-f,fill:C,hatch:F,opacity:me,stroke:m,strokeWidth:s,dashed:l}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:$-S,h:g-f,fill:C,hatch:F,opacity:me}),ue){let Se=We(f,g,E),ke=E==="above"?"top":E==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+$)/2,y:Se,anchor:"middle",fontSize:u,fill:c,textBaseline:ke,rotate:xe});}}return b}function We(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Oe(a){let{markers:e,timeScale:t,valueScale:n,yRange:o=[0,300]}=a,[r,i]=o,m=[];for(let s of e){let l=t.map(s.time),u=s.color??h.markerColor,c=s.pointStyle??(s.value!==void 0?"circle":"none"),d=s.lineStyle??"full";if(s.value!==void 0){let p=n.map(s.value);if(d==="to-value"?m.push({type:"line",x1:l,y1:i,x2:l,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?m.push({type:"line",x1:l,y1:r,x2:l,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&m.push({type:"line",x1:l,y1:r,x2:l,y2:i,stroke:u,strokeWidth:1}),c!=="none"&&z(m,void 0,c,l,p,h.markerSize,u,u,1.5),s.label){let f=d==="to-value"?p-10:r-6;m.push({type:"text",content:s.label,x:l,y:f,anchor:"middle",fontSize:11,fill:u});}}else m.push({type:"line",x1:l,y1:r,x2:l,y2:i,stroke:u,strokeWidth:1}),s.label&&m.push({type:"text",content:s.label,x:l,y:r-6,anchor:"middle",fontSize:11,fill:u});}return m}function je(a){let{highlights:e,timeScale:t,yRange:n,height:o}=a,[r,i]=n,m=[];for(let s of e){let l=t.map(s.startTime),u=t.map(s.endTime);m.push({type:"rect",x:l,y:r,w:u-l,h:i-r,fill:s.color??h.highlightColor,opacity:s.opacity??h.highlightOpacity}),s.label&&m.push({type:"text",content:s.label,x:(l+u)/2,y:Ie(s.labelPosition??"top",r,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function Ie(a,e,t,n){switch(a){case "above":return e-5;case "below":return n!==void 0?n-5:t+14;case "center":return (e+t)/2+4;case "bottom":return t-6;default:return e+14}}function U(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Be(a){let{annotations:e,timeScale:t,valueScales:n}=a,o=[],r=i=>{let m=n.get(i.axis??0)??n.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=r(i.from),u=r(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=r(i.from),u=r(i.to),c=i.color??h.annotationColor,d=i.headSize??h.annotationHead;s({type:"line",x1:l.x,y1:l.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:i.width??h.annotationWidth});let p=Math.hypot(u.x-l.x,u.y-l.y)||1,f=(u.x-l.x)/p,g=(u.y-l.y)/p,b=u.x-f*d,y=u.y-g*d;s({type:"path",points:[{x:u.x,y:u.y},{x:b-g*d*.5,y:y+f*d*.5},{x:b+g*d*.5,y:y-f*d*.5}],fill:c,stroke:"none"});break}case "rect":{let l=r(i.from),u=r(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=r(i.at),u=i.color??"#334155",c=i.radius??h.annotationRadius,d=i.shape??"circle";d==="circle"?s({type:"circle",cx:l.x,cy:l.y,r:c,fill:u}):d==="square"?s({type:"rect",x:l.x-c,y:l.y-c,w:c*2,h:c*2,fill:u}):(s({type:"line",x1:l.x-c,y1:l.y-c,x2:l.x+c,y2:l.y+c,stroke:u,strokeWidth:1.5}),s({type:"line",x1:l.x-c,y1:l.y+c,x2:l.x+c,y2:l.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let l=r(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=U(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var q=class a{_config;constructor(e){this._config=e;}compute(){let{width:e,height:t,margin:n}=this._config;return {totalWidth:e,totalHeight:t,chartWidth:e-n.left-n.right,chartHeight:t-n.top-n.bottom,chartX:n.left,chartY:n.top,margin:n}}static default(e=800,t=400){return new a({width:e,height:t,margin:{top:20,right:20,bottom:40,left:60}})}};var K=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(n=>e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height)}toSVGClipPath(e="clip"){if(this.#e.length===0)return "";let t=this.#e.map(n=>`<rect x="${n.x}" y="${n.y}" width="${n.width}" height="${n.height}" />`).join(`
|
|
29
25
|
`);return `<clipPath id="${e}">
|
|
30
26
|
${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}}/*!
|
|
27
|
+
</clipPath>`}get regions(){return [...this.#e]}};var O={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??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.minTicks??5,t=this.#t.maxTicks??12,o=this.#e.ticks({minTicks:e,maxTicks:t}).map(r=>({time:r,x:this.#e.map(r),label:this.tickLabel(r)}));return this.antiOverlap(o)}tickLabel(e){if(this.#t.format)return this.#t.format(new Date(e));let t=this.#t.minTicks??5,n=this.#t.maxTicks??12,{interval:o}=this.#e.tickInterval((t+n)/2,t,n),r={};return o<6e4?(r.hour="2-digit",r.minute="2-digit",r.second="2-digit"):o<36e5||o<864e5?(r.hour="2-digit",r.minute="2-digit"):o<31536e6?(r.day="numeric",r.month="short",o>=2592e6&&(r.day=void 0,r.month="long")):(r.year="numeric",o<2*31536e6&&(r.month="short")),this.#e.format(e,r)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let o=1;o<e.length;o++){let r=n[n.length-1].x;Math.abs(e[o].x-r)>=t&&n.push(e[o]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??O,n=this.#t.y??0,o=[],[r,i]=this.#e.range();o.push({type:"line",x1:r,y1:n,x2:i,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let m of e)o.push({type:"line",x1:m.x,y1:n,x2:m.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),o.push({type:"text",content:m.label,x:m.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return o}};var I={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function He(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 Ve(a){let e=new Array(a.length).fill(false),t=0;for(;t<a.length;){let n=t;for(;n+1<a.length&&a[n+1].label===a[t].label;)n++;for(let o=t+1;o<n;o++)e[o]=true;t=n+1;}return e}var J=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??I).axisColor}get tickColor(){return (this.#t.colors??I).tickColor}get textColor(){return (this.#t.colors??I).textColor}get textSize(){return (this.#t.colors??I).textSize}generateTicks(){let e=this.#t.format??He,t=6,[n,o]=this.#e.domain(),r=o-n;if(r===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let i=r/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=[],c=Math.ceil(n/l)*l;for(let d=c;d<=o;d+=l)u.push({value:d,position:this.#e.map(d),label:e(d)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??I,n=this.#t.x??0,o=this.#t.orientation??"vertical",r=this.#t.position??"left",i=this.#t.suppressLabelsNear??[],m=this.#t.suppressTolerancePx??8,s=u=>i.some(c=>Math.abs(c-u)<=m),l=[];if(o==="vertical"){let[u,c]=this.#e.range();l.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=Ve(e);e.forEach((p,f)=>{let g=s(p.position),b=d[f]?{opacity:0}:{};r==="left"?(l.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(l.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||l.push({type:"text",content:p.label,x:n+8,y:p.position+4,anchor:"start",fontSize:11,fill:t.textColor,...b}));});}else {let[u,c]=this.#e.range();l.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)l.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),l.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return l}};var Q=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,o)=>n-o).map(String);this.#t=t,this.#e=new W({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:o}=this.#n,r=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),c=n?h.palette[m%h.palette.length]:void 0;return {value:s,label:l,y:u,color:c,isGap:r.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,n=[];for(let o of e)o.isGap||n.push({type:"text",content:o.label,x:t,y:o.y+4,anchor:"end",fontSize:11,fill:o.color??h.textColor});return n}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??"series-"+ ++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 ee=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,n)=>t.x-n.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},n=e.pointThreshold??h.pointThreshold,o=e.gapThreshold??h.gapThreshold,r=e.id,i=x.getRuns(this.data,c=>c.value===null,o),m=i.reduce((c,d)=>c+d.length,0);if(m===0)return [];let s={timeScale:this.timeScale,valueScale:e.valueScale},l=i.map(c=>({data:c})),u=[];if(u.push(...w(l,s,{...t,id:r?`${r}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&m<=n)for(let c of i)u.push(...P(c,s,{...t,id:r?`${r}-marker`:void 0},()=>t.stroke));return u}};var te=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,r)=>o.time-r.time),n=[];for(let o=0;o<t.length;o++){let r=this.timeScale.map(t[o].time),i=e.map(t[o].value);o===0?n.push({x:r,y:i}):n.push({x:r,y:n[n.length-1].y},{x:r,y:i});}return n}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},n=e.map(o=>({data:o}));return G(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var ne=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}opacity(e){if(!(this.#e.countOpacity??false))return .6;let t=0;for(let n of this.data)n.count>t&&(t=n.count);return t===0?.2:.2+.8*e/t}render(){let e=this.#e,t=e.fill??h.bandFill,n=e.hatch,o=e.avgLine??false,r=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),c=e.valueScale.map(s.min),d=i,p=this.data.indexOf(s);if(m.push({type:"rect",x:l-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(s.count),id:this.id?`${this.id}-slot-${p}`:void 0}),o&&s.avg!==null){let f=e.valueScale.map(s.avg);m.push({type:"line",x1:l-d/2,y1:f,x2:l+d/2,y2:f,stroke:r,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return m}};var re=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}render(){let e=this.#e,t=e.minColor??h.minColor,n=e.maxColor??h.maxColor,o=e.avgColor??h.avgColor,r=e.avgDashed??true,i=e.smoothing??false,m=e.strokeWidth??h.strokeWidth,s=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(s.length===0)return [];let l={timeScale:this.timeScale,valueScale:e.valueScale},u=[];s.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...H(p,l,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.max,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMax,getHatch:()=>e.fillToMaxHatch},{id:this.id?`${this.id}-fillToMax-${f}`:void 0})),e.fillToMin&&u.push(...H(p,l,{boundaries:[],yLow:g=>g.avg,yHigh:g=>g.min,getValue:g=>g.avg,interpolate:x.interpolateAggregatedPoint,getColor:()=>e.fillToMin,getHatch:()=>e.fillToMinHatch},{id:this.id?`${this.id}-fillToMin-${f}`:void 0})));});let c=s.filter(p=>p.length>=2),d=p=>c.map(f=>({data:f.map(g=>({time:g.time,value:p(g)}))}));return u.push(...w(d(p=>p.max),l,{stroke:n,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),l,{stroke:t,strokeWidth:m,smoothing:i,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),l,{stroke:o,strokeWidth:m,smoothing:i,dashed:r,id:this.id?`${this.id}-avg`:void 0})),u}};var oe=class extends v{#e;#t;constructor(e){super(e,e.data),this.#e=e,this.#t=[...e.zones??[]].sort((t,n)=>t.value-n.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,n={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,r=e.pointThreshold??h.pointThreshold,i=x.getRuns(this.data,u=>u.value===null,o),m=i.reduce((u,c)=>u+c.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 f=e.fill.value,g=x.splitByBoundaries(u,[f],y=>y.value,x.interpolateDataPoint),b=e.valueScale.map(f);for(let y=0;y<g.length;y++){let S=g[y],$=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==$>=f){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-${y}`:void 0,points:[...C,{x:C[C.length-1].x,y:b},{x:C[0].x,y:b}],fill:e.fill.color,hatch:e.fill.hatch,stroke:"none"});}}}let c=this.#t.map(f=>f.value),p=x.splitByBoundaries(u,c,f=>f.value,x.interpolateDataPoint).map(f=>({data:f.data,color:this.#n(f.zoneIndex)}));l.push(...w(p,s,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&m<=r&&l.push(...P(u,s,{...n,id:this.id?`${this.id}-marker`:void 0},f=>{let g=t;for(let b of this.#t)f.value>=b.value&&(g=b.color);return g}));}return l}};var ie=class{#e;constructor(e,t,n,o){this.#e={...e,xRange:t,y:n,height:o};}render(){let{items:e,timeScale:t,background:n,hatch:o,showAxis:r,xRange:i,y:m,height:s}=this.#e,l=[];n&&l.push({type:"rect",x:i[0],y:m,w:i[1]-i[0],h:s,fill:n,opacity:.04,stroke:"#ddd",strokeWidth:.25});for(let u of e){let c=t.map(u.startTime),d=t.map(u.endTime);if(!(d-c<1)&&(l.push({type:"rect",x:c,y:m,w:d-c,h:s,hatch:u.hatch??o,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let p=u.labelFontSize??10;l.push({type:"text",content:u.label,x:(c+d)/2,y:this.#t(u.labelBaseline,p),anchor:"middle",fontSize:p,fill:u.labelFill??"#333"});}}if(r){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:n,height:o}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+o-t*.25;default:return n+o/2+t*.35}}};var ae=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:o=false,showMax:r=false,showAvg:i=true,showMedian:m=false,labelPosition:s="end",lineColor:l=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:o},{name:"max",value:c.max,enabled:r},{name:"avg",value:c.avg,enabled:i},{name:"median",value:c.median,enabled:m}],p=[],[f,g]=n;for(let b of d.filter(y=>y.enabled)){let y=t.map(b.value);p.push({type:"line",x1:f,y1:y,x2:g,y2:y,stroke:l,strokeWidth:1});let S=`${b.name}: ${b.value.toFixed(1)}`;(s==="start"||s==="both")&&p.push({type:"text",content:S,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(s==="end"||s==="both")&&p.push({type:"text",content:S,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),s==="center"&&p.push({type:"text",content:S,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};var D=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,n){try{let o=this.#n&&n?this.#r(e,n,t):t;return A(this.#e,o).format(new Date(e))}catch{for(let o of this.#t)try{return A(o,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),o=this.format(t);return `${n} \u2014 ${o}`}#r(e,t,n){let o=Math.abs(e-t),r=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<r?(s.hour="2-digit",s.minute="2-digit"):o<7*r?(s.weekday="short",s.day="numeric"):o<365*r?(s.month="short",s.day="numeric"):(s.month="short",s.year="numeric"),{...n,...s}}};var M=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 n={};return e.forEach((o,r)=>{n[r]=o;}),new a({map:n,showValue:t})}};var Ee={time:new D,value:new M,enum:new _};var Ne={...h};function se(){return Ne}function le(a,e){let t=se();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 pe(a){let e=a.style?.line;return e===false?[]:e===void 0?[le({},a)]:Array.isArray(e)?e.map(t=>le(t,a)):[le(e,a)]}function fe(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=se(),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 ge(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 ye(a){return a.style?.gap}function be(a){return a.style?.fill}function Ge(a){return {lines:pe(a),fill:be(a),markers:fe(a),shadow:ge(a),gap:ye(a),id:a.style?.id??a.id}}/*!
|
|
32
28
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
33
29
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
34
30
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -47,4 +43,4 @@ var E=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
47
43
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
48
44
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
49
45
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
50
|
-
*/export{
|
|
46
|
+
*/export{ie as AnnotationBandSeries,W as BandScale,ne as BandSeries,K as Clip,Q as EnumAxis,_ as EnumFormatter,Ee as Formatters,q as Layout,ee as LineSeries,L as LinearScale,re as MinMaxAvgSeries,N as Renderer,ae as StatsOverlay,te as StepSeries,k as TIME_INTERVALS,j as TimeAxis,D as TimeFormatter,R as TimeScale,J as ValueAxis,M as ValueFormatter,oe as ZonedLineSeries,de as getHatch,Le as measureLegend,Be as renderAnnotations,we as renderArea,Re as renderGaps,Me as renderGrid,je as renderHighlights,De as renderLegend,w as renderLine,Oe as renderMarkers,P as renderSeriesMarkers,Ce as renderSplitLine,G as renderStep,Pe as renderThresholds,H as renderZonedArea,be as resolveFill,ye as resolveGap,pe as resolveLines,fe as resolveMarkers,Ge as resolveSeriesStyle,ge as resolveShadow,U as slugify,h as theme};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as DrawCommand, a1 as DrawGroup, P as PointStyleType } from './scale-CWAa8-uO.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;
|
|
@@ -243,4 +243,4 @@ declare class Layout {
|
|
|
243
243
|
static default(width?: number, height?: number): Layout;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
export {
|
|
246
|
+
export { type LegendOrientation as L, type Marker as M, Renderer as R, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, Layout as d, type LayoutConfig as e, type LegendConfig as f, measureLegend as m, renderLegend as r, theme as t };
|
|
@@ -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,25 @@ 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
|
-
|
|
132
|
+
/** Wird als SVG-Attribut `dominant-baseline` ausgegeben. Achtung: nur
|
|
133
|
+
* "middle" ist dort ein gueltiger Wert -- "top"/"bottom" fallen im Browser
|
|
134
|
+
* auf "auto" zurueck. Der Go-Port reicht sie genauso durch; eine echte
|
|
135
|
+
* Abbildung (top -> text-top, bottom -> text-bottom) waere eine Aenderung
|
|
136
|
+
* in beiden Bibliotheken samt neuer Go-Golden. */
|
|
137
|
+
textBaseline?: "top" | "middle" | "bottom";
|
|
133
138
|
/** Optional SVG `id` attribute for this element. */
|
|
134
139
|
id?: string;
|
|
135
140
|
}
|
|
136
|
-
type DrawDirection_t =
|
|
141
|
+
type DrawDirection_t = "vertical" | "horizontal";
|
|
137
142
|
interface DrawGradient {
|
|
138
|
-
type:
|
|
143
|
+
type: "gradient";
|
|
139
144
|
points: Point[];
|
|
140
145
|
stops: GradientStop[];
|
|
141
146
|
direction: DrawDirection_t;
|
|
142
147
|
}
|
|
143
|
-
type DrawGapType_t$1 =
|
|
148
|
+
type DrawGapType_t$1 = "dashed_border" | "empty" | "label";
|
|
144
149
|
interface DrawGap {
|
|
145
|
-
type:
|
|
150
|
+
type: "gap";
|
|
146
151
|
x1: number;
|
|
147
152
|
y1: number;
|
|
148
153
|
x2: number;
|
|
@@ -153,7 +158,7 @@ interface DrawGap {
|
|
|
153
158
|
id?: string;
|
|
154
159
|
}
|
|
155
160
|
interface DrawGroup {
|
|
156
|
-
type:
|
|
161
|
+
type: "group";
|
|
157
162
|
commands: DrawCommand[];
|
|
158
163
|
cssClass?: string;
|
|
159
164
|
/** Optional SVG `id` attribute for this group. */
|
|
@@ -169,11 +174,11 @@ interface DrawGroup {
|
|
|
169
174
|
}
|
|
170
175
|
/** Union aller Commands */
|
|
171
176
|
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,
|
|
177
|
+
type LineParams = Omit<DrawLine, "type">;
|
|
178
|
+
type PathParams = Omit<DrawPath, "type">;
|
|
179
|
+
type RectParams = Omit<DrawRect, "type">;
|
|
180
|
+
type CircleParams = Omit<DrawCircle, "type">;
|
|
181
|
+
type TextParams = Omit<DrawText, "type">;
|
|
177
182
|
|
|
178
183
|
/*!
|
|
179
184
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
@@ -444,48 +449,48 @@ type SeriesOverlayKind = SeriesOverlay["kind"];
|
|
|
444
449
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
445
450
|
*/
|
|
446
451
|
|
|
447
|
-
/**
|
|
452
|
+
/** Single data point — numeric value or integer enum key. */
|
|
448
453
|
interface DataPoint {
|
|
449
|
-
/**
|
|
454
|
+
/** Time (ms timestamp). */
|
|
450
455
|
time: number;
|
|
451
|
-
/**
|
|
456
|
+
/** Numeric value or integer enum key; null = gap (the line breaks here). */
|
|
452
457
|
value: number | null;
|
|
453
|
-
/**
|
|
458
|
+
/** Optional annotation text. */
|
|
454
459
|
annotation?: string;
|
|
455
460
|
/**
|
|
456
|
-
*
|
|
457
|
-
* `SeriesProcessor`
|
|
458
|
-
*
|
|
459
|
-
*
|
|
461
|
+
* Synthetic point — not a real measurement. Set automatically by the
|
|
462
|
+
* `SeriesProcessor` on interpolated points (threshold intersections, gap
|
|
463
|
+
* edges), but can also be set manually for computed helper points (e.g. a
|
|
464
|
+
* trend line over interpolated values).
|
|
460
465
|
*
|
|
461
|
-
* Renderer
|
|
462
|
-
*
|
|
463
|
-
*
|
|
466
|
+
* Renderer consequences: no point marker, no tooltip snap, no entry in the
|
|
467
|
+
* value table. Scales (Y min/max) still count the point, otherwise the line
|
|
468
|
+
* geometry would be distorted. Defaults to `undefined` = real measurement.
|
|
464
469
|
*
|
|
465
|
-
*
|
|
470
|
+
* See API_DESIGN.md §4.1.
|
|
466
471
|
*/
|
|
467
472
|
synthetic?: boolean;
|
|
468
473
|
}
|
|
469
|
-
/**
|
|
474
|
+
/** Aggregated measurement per time slot (hourly/daily/custom). */
|
|
470
475
|
interface AggregatedPoint {
|
|
471
|
-
/** Slot
|
|
476
|
+
/** Slot start time (ms). */
|
|
472
477
|
time: number;
|
|
473
|
-
/** Minimum
|
|
478
|
+
/** Minimum value; null = gap slot. */
|
|
474
479
|
min: number | null;
|
|
475
|
-
/** Maximum
|
|
480
|
+
/** Maximum value; null = gap slot. */
|
|
476
481
|
max: number | null;
|
|
477
|
-
/**
|
|
482
|
+
/** Average; null = gap slot. */
|
|
478
483
|
avg: number | null;
|
|
479
|
-
/**
|
|
484
|
+
/** Number of raw data points in the slot. */
|
|
480
485
|
count: number;
|
|
481
486
|
}
|
|
482
|
-
/** Sensor
|
|
487
|
+
/** Sensor type */
|
|
483
488
|
type SensorType = "numeric" | "enum";
|
|
484
489
|
/** Map from enum value (number) to human-readable label */
|
|
485
490
|
interface EnumMap {
|
|
486
491
|
[key: number]: string;
|
|
487
492
|
}
|
|
488
|
-
/** Raw
|
|
493
|
+
/** Raw series (numeric or enum) */
|
|
489
494
|
interface TimeSeries {
|
|
490
495
|
name: string;
|
|
491
496
|
data: DataPoint[];
|
|
@@ -510,11 +515,11 @@ interface TimeSeries {
|
|
|
510
515
|
/** Optional SVG id prefix for series elements. */
|
|
511
516
|
id?: string;
|
|
512
517
|
}
|
|
513
|
-
/**
|
|
518
|
+
/** Aggregated series: min/max/avg per slot. */
|
|
514
519
|
interface AggregatedSeries {
|
|
515
520
|
name: string;
|
|
516
521
|
data: AggregatedPoint[];
|
|
517
|
-
/** 'band' =
|
|
522
|
+
/** 'band' = filled rectangle per slot; 'minmaxavg' = min/max/avg lines + optional fill */
|
|
518
523
|
showAs?: "band" | "minmaxavg";
|
|
519
524
|
yAxisIndex?: number;
|
|
520
525
|
avgLine?: boolean;
|
|
@@ -531,20 +536,20 @@ interface AggregatedSeries {
|
|
|
531
536
|
minColor?: string;
|
|
532
537
|
maxColor?: string;
|
|
533
538
|
avgColor?: string;
|
|
534
|
-
/**
|
|
539
|
+
/** Avg line dashed (default: true). */
|
|
535
540
|
avgDashed?: boolean;
|
|
536
|
-
/**
|
|
541
|
+
/** Semi-transparent fill between avg and max */
|
|
537
542
|
fillToMax?: string;
|
|
538
543
|
/** Hatch pattern for fillToMax */
|
|
539
544
|
fillToMaxHatch?: HatchVariant;
|
|
540
|
-
/**
|
|
545
|
+
/** Semi-transparent fill between avg and min */
|
|
541
546
|
fillToMin?: string;
|
|
542
547
|
/** Hatch pattern for fillToMin */
|
|
543
548
|
fillToMinHatch?: HatchVariant;
|
|
544
549
|
/** Optional SVG id prefix for series elements. */
|
|
545
550
|
id?: string;
|
|
546
551
|
}
|
|
547
|
-
/** Series
|
|
552
|
+
/** Series type: raw, enum, or aggregated */
|
|
548
553
|
type AnySeries = TimeSeries | AggregatedSeries;
|
|
549
554
|
/** Time range gap with optional label and style */
|
|
550
555
|
interface Gap {
|
|
@@ -555,7 +560,7 @@ interface Gap {
|
|
|
555
560
|
/** Hatch pattern for gap fill */
|
|
556
561
|
hatch?: HatchVariant;
|
|
557
562
|
fillOpacity?: number;
|
|
558
|
-
labelBaseline?:
|
|
563
|
+
labelBaseline?: "above" | "middle" | "below";
|
|
559
564
|
rotate?: number;
|
|
560
565
|
style?: DrawGapType_t$1;
|
|
561
566
|
}
|
|
@@ -718,9 +723,9 @@ interface AnnotationBandItem {
|
|
|
718
723
|
/** Label fill color (default: inherit from theme). */
|
|
719
724
|
labelFill?: string;
|
|
720
725
|
/**
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
labelBaseline?:
|
|
726
|
+
* Label vertical position: 'top', 'middle' (default), or 'bottom' inside the band.
|
|
727
|
+
*/
|
|
728
|
+
labelBaseline?: "top" | "middle" | "bottom";
|
|
724
729
|
}
|
|
725
730
|
/**
|
|
726
731
|
* Configuration for an annotation band — a horizontal strip below the main chart
|
|
@@ -745,11 +750,6 @@ interface AnnotationBandConfig {
|
|
|
745
750
|
items: AnnotationBandItem[];
|
|
746
751
|
}
|
|
747
752
|
|
|
748
|
-
/*!
|
|
749
|
-
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
750
|
-
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
751
|
-
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
752
|
-
*/
|
|
753
753
|
/** Base scale interface – maps data values to pixel coordinates */
|
|
754
754
|
interface ScaleConfig {
|
|
755
755
|
/** Pixel range (output domain). Defaults to [0, width] or [0, height] */
|
|
@@ -847,4 +847,4 @@ declare class BandScale implements Scale {
|
|
|
847
847
|
positions(): Map<string, number>;
|
|
848
848
|
}
|
|
849
849
|
|
|
850
|
-
export { type
|
|
850
|
+
export { type DrawGapType_t as $, type AnySeries as A, type SensorType as B, type SeriesOverlay as C, type DrawCommand as D, type EnumMap as E, type FillSpec as F, type Gap as G, type Highlight as H, type SeriesOverlayKind as I, type SeriesType as J, type ShadowStyle as K, type LineVariant as L, type MarkerStyle as M, type ThresholdLabelConfig as N, BandScale as O, type PointStyleType as P, type Point as Q, type AxisOrientation as R, type SeriesStyle as S, type Threshold as T, type AxisPosition as U, type BandScaleConfig as V, type CircleParams as W, type Dashstyle_t as X, type DomainScaleConfig as Y, type DrawCircle as Z, type DrawGap as _, type GapsConfig as a, type DrawGradient as a0, type DrawGroup as a1, type DrawLine as a2, type DrawPath as a3, type DrawRect as a4, type DrawText as a5, type LabelAnchor as a6, type LineParams as a7, type LinearScaleConfig as a8, type PathParams as a9, type RectParams as aa, type Scale as ab, type ScaleConfig as ac, TIME_INTERVALS as ad, type TextParams as ae, type TimeScaleConfig as af, getHatch as ag, type Annotation as b, type AnnotationBandConfig as c, TimeScale as d, LinearScale as e, type TimeSeries as f, type HatchVariant as g, type ThresholdLabelPosition as h, type AnnotationBandItem as i, type AggregatedPoint as j, type AggregatedSeries as k, type DataPoint as l, type AggregationConfig as m, type AggregationMode as n, type DataPointRef as o, type FillBound as p, type FillDirectionType as q, type FillRegion as r, type FillSide as s, type FillStyle as t, type GapConfig as u, type GapLabel as v, type GapRegion as w, type GapStyle as x, type LineDashStyle as y, type LineStyle as z };
|