ml-time-graph 1.3.3 → 1.5.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.de.md +9 -0
- package/README.md +9 -0
- package/SKILLS.md +183 -0
- package/USAGE.md +91 -4
- package/dist/index.d.ts +21 -5
- package/dist/index.js +34 -34
- package/dist/interaction/index.d.ts +1 -1
- package/dist/internals.d.ts +5 -93
- package/dist/internals.js +22 -22
- package/dist/{scale-CWAa8-uO.d.ts → scale-ByGpczxS.d.ts} +30 -1
- package/dist/{layout-3caueyKS.d.ts → series_renderer-BxGvCHMY.d.ts} +107 -2
- package/package.json +10 -8
package/dist/internals.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
var G=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
|
|
1
|
+
var G=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=(r,o)=>r!==null&&o!==null?r+t*(o-r):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((s,i)=>s.time-i.time),r=[],o=[],l=null;for(let s of n){let i=e(s),m=t>0&&l&&s.time-l.time>t;(i||m)&&o.length&&(r.push(o),o=[]),i||o.push(s),l=s;}return o.length&&r.push(o),r}static splitByBoundaries(a,e,t,n){if(a.length===0)return [];if(e.length===0)return [{data:a,zoneIndex:0}];let r=[...e].sort((i,m)=>i-m),o=[],l=i=>{let m=0;for(let u=0;u<r.length&&i>=r[u];u++)m=u+1;return m},s=[a[0]];for(let i=1;i<a.length;i++){let m=a[i-1],u=a[i],c=t(m),d=t(u),p;d>c?p=r.filter(f=>f>c&&f<=d):d<c?p=r.filter(f=>f>=d&&f<c).reverse():p=[];for(let f of p){let g=(f-c)/(d-c),b=n(m,u,g);s.push(b),o.push({data:s,zoneIndex:l((c+f)/2)}),s=[b];}s.push(u);}if(s.length>0){let i=t(s[0]),m=t(s[s.length-1]);o.push({data:s,zoneIndex:l((i+m)/2)});}return o}static splitByThreshold(a,e,t,n){let r=this.splitByBoundaries(a,[e],t,n),o={above:[],below:[]};for(let l of r)l.zoneIndex===0?o.below.push(l.data):o.above.push(l.data);return o}};var ce=class{static compute(a){let e=a.map(s=>s.value).filter(s=>s!==null).sort((s,i)=>s-i);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((s,i)=>s+i,0)/t,r=t%2===1?e[Math.floor(t/2)]:(e[t/2-1]+e[t/2])/2,o=e.reduce((s,i)=>s+Math.pow(i-n,2),0)/t,l=Math.sqrt(o);return {min:e[0],max:e[t-1],avg:n,mean:n,median:r,stdDev:l,count:t}}static computeInRange(a,e,t){let n=a.filter(r=>r.time>=e&&r.time<=t);return this.compute(n)}};var de={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"]};var we={...de};function C(){return we}function Ce(a){let e=a.trim();if(e.startsWith("#"))return e.length===9?e.slice(0,7):e.length===5?e.slice(0,4):e;if(e.toLowerCase().startsWith("rgba(")){let n=e.slice(5,e.lastIndexOf(")")).split(",");if(n.length===4)return `rgb(${n[0].trim()}, ${n[1].trim()}, ${n[2].trim()})`}return e}function Te(a){let e=a.trim().toLowerCase();return e.startsWith("#")?e.length===9||e.length===5:e.startsWith("rgba(")||e.startsWith("hsla(")}function he(a,e="classic-diagonal",t="rgba(200, 220, 255, 0.3)",n,r=2){let o=n??Ce(t),l=Te(t)?"":' fill-opacity="0.3"';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
|
-
`;break;case "dashed":
|
|
11
|
-
<path d="M 0 0 L ${
|
|
12
|
-
`;break;case "brick":
|
|
13
|
-
<path d="M 0 ${i/2} L ${
|
|
14
|
-
`;break;case "double-stripe":
|
|
15
|
-
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${
|
|
16
|
-
<line x1="${
|
|
17
|
-
`;break;case "honeycomb":
|
|
18
|
-
<path d="M 0 0 L ${
|
|
19
|
-
`;break}let
|
|
20
|
-
<pattern id="${a}" width="${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
5
|
+
`.trim();let s=12,i=12,m="rotate(0)",u="";switch(e){case "classic-diagonal":s=12,i=12,m="rotate(45)",u=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "dense-steep":s=6,i=6,m="rotate(30)",u=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />`;break;case "crosshatch":s=14,i=14,m="rotate(45)",u=`
|
|
6
|
+
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
7
|
+
<line x1="0" y1="0" x2="${s}" y2="0" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
8
|
+
`;break;case "dots":s=12,i=12,u=`<circle cx="${s/2}" cy="${i/2}" r="${r*1.2}" fill="${o}" />`;break;case "waves":s=16,i=16,u=`
|
|
9
|
+
<path d="M 0 ${i/2} Q ${s/4} 0, ${s/2} ${i/2} T ${s} ${i/2}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linecap="round" />
|
|
10
|
+
`;break;case "dashed":s=12,i=12,m="rotate(45)",u=`<line x1="0" y1="0" x2="0" y2="${i}" stroke="${o}" stroke-width="${r}" stroke-dasharray="3,3" />`;break;case "herringbone":s=16,i=16,u=`
|
|
11
|
+
<path d="M 0 0 L ${s/2} ${i/2} L 0 ${i} M ${s} 0 L ${s/2} ${i/2} L ${s} ${i}" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
12
|
+
`;break;case "brick":s=20,i=20,u=`
|
|
13
|
+
<path d="M 0 ${i/2} L ${s} ${i/2} M 0 ${i} L ${s} ${i} M ${s/2} 0 L ${s/2} ${i/2} M 0 ${i/2} L 0 ${i}" fill="none" stroke="${o}" stroke-width="${r}" />
|
|
14
|
+
`;break;case "double-stripe":s=16,i=16,m="rotate(45)",u=`
|
|
15
|
+
<line x1="0" y1="0" x2="0" y2="${i}" stroke="${o}" stroke-width="${r}" stroke-linecap="square" />
|
|
16
|
+
<line x1="${s/2}" y1="0" x2="${s/2}" y2="${i}" stroke="${o}" stroke-width="${r/2}" stroke-linecap="square" />
|
|
17
|
+
`;break;case "honeycomb":s=18,i=32,u=`
|
|
18
|
+
<path d="M 0 0 L ${s/2} 5 L ${s} 0 M 0 16 L ${s/2} 11 L ${s} 16 M 0 16 L 0 32 M ${s/2} 5 L ${s/2} 11 M ${s} 16 L ${s} 32 M 0 32 L ${s/2} 27 L ${s} 32 M ${s/2} 27 L ${s/2} 32" fill="none" stroke="${o}" stroke-width="${r}" stroke-linejoin="round" stroke-linecap="round" />
|
|
19
|
+
`;break}let c=`<rect width="${s}" height="${i}" fill="${t}"${l} />`;return `
|
|
20
|
+
<pattern id="${a}" width="${s}" height="${i}" patternTransform="${m}" patternUnits="userSpaceOnUse">
|
|
21
|
+
${c}
|
|
22
|
+
${u}
|
|
23
23
|
</pattern>
|
|
24
|
-
`.trim()}var h=new Proxy({},{get:(a,e)=>C()[e],has:(a,e)=>e in C(),ownKeys:()=>Reflect.ownKeys(C()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(C(),e)});function H(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=H(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 Ce(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 z(a,e,t){let n=[],o=H(t);for(let r=0;r<a.length;r++){let i=a[r];if(i.data.length<2)continue;let m=Ce(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 Te(a,e,t,n,o){let r=[],i=H(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 V(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 Le(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 R(a,e,t,n){let o=H(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;Y(r,f,o.markers.type,s,l,o.markers.size,c,d,p);}return r}function Y(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 L=12,E=8,X=20,De=11,Z=18,U=a=>a.length*De*.6;function Me(a,e="vertical"){if(e==="horizontal"){let n=0;for(let o of a)n+=L+E+U(o.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:L+E+t,height:a.length*X}}function _e(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*X;r.push({type:"rect",x:l,y:u,w:L,h:L,fill:m.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:m.name,x:l+L+E,y:u+L-2,fontSize:h.legendFont,fill:h.legendText}),o==="horizontal"&&(i+=L+E+U(m.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:r}}function $e(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 pe=new Map;function Fe(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=Fe(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var D=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}],W=class{#e;#t;constructor(e){this.#e=new D({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))}},O=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 Pe(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(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=Pe(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({...We(y,S,o,r,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Ae(a){let e=Re(a);return [...e.inside,...e.labels]}function We(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 Oe(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),F=t.map(y.endTime),T=y.fill??o,P=y.hatch??r,me=y.fillOpacity??i,ue=y.label??"",Se=y.rotate??p,N=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me,stroke:m,strokeWidth:s,dashed:l}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me}),ue){let ke=je(f,g,N),ve=N==="above"?"top":N==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+F)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function je(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function Ie(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"&&Y(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 Be(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:He(s.labelPosition??"top",r,i,o),anchor:"middle",fontSize:h.annotationFontSize,fill:s.color??h.highlightLabelColor,rotate:s.rotate});}return m}function He(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 q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ve(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=q(i.id);o.push({type:"group",cssClass:`annotation annotation--${l}`,commands:m});}else o.push(...m);}return o}var K=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 J=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(`
|
|
24
|
+
`.trim()}var h=new Proxy({},{get:(a,e)=>C()[e],has:(a,e)=>e in C(),ownKeys:()=>Reflect.ownKeys(C()),getOwnPropertyDescriptor:(a,e)=>Reflect.getOwnPropertyDescriptor(C(),e)});function H(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=[],r=a.reduce((l,s)=>l+s.data.length,0),o=H(t);for(let l=0;l<a.length;l++){let s=a[l];s.data.length>=2?n.push({type:"path",id:t.id?`${t.id}-line-${l}`:void 0,points:s.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})),stroke:s.color??o.line.stroke,strokeWidth:o.line.strokeWidth,smoothing:o.line.smoothing,dashed:o.line.dashed,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur,shadowOffsetX:o.shadow.offsetX,shadowOffsetY:o.shadow.offsetY,fill:"none"}):s.data.length===1&&r===1&&n.push({type:"circle",cx:e.timeScale.map(s.data[0].time),cy:e.valueScale.map(s.data[0].value),r:Math.max(o.markers.size,o.line.strokeWidth),fill:s.color??o.line.stroke,shadowColor:o.shadow.color,shadowBlur:o.shadow.blur});}return n}function Le(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 z(a,e,t){let n=[],r=H(t);for(let o=0;o<a.length;o++){let l=a[o];if(l.data.length<2)continue;let s=Le(l.data.map(i=>({x:e.timeScale.map(i.time),y:e.valueScale.map(i.value)})));n.push({type:"path",id:t.id?`${t.id}-line-${o}`:void 0,points:s,stroke:l.color??r.line.stroke,strokeWidth:r.line.strokeWidth,smoothing:false,fill:"none"});}return n}function De(a,e,t,n,r){let o=[],l=H(t);for(let s=0;s<a.length;s++){let i=a[s];if(i.data.length<2)continue;let m=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(n(c))})),u=i.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(r(c))})).reverse();o.push({type:"path",id:t.id?`${t.id}-fill-${s}`:void 0,points:[...m,...u],fill:i.color??l.fill,hatch:t.hatch,stroke:"none"});}return o}function V(a,e,t,n){if(a.length<2)return [];let r=x.splitByBoundaries(a,t.boundaries,t.getValue,t.interpolate),o=[];for(let l=0;l<r.length;l++){let s=r[l];if(s.data.length<2)continue;let i=t.getColor(s.zoneIndex);if(!i)continue;let m=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yLow(c))})),u=s.data.map(c=>({x:e.timeScale.map(c.time),y:e.valueScale.map(t.yHigh(c))})).reverse();o.push({type:"path",id:n?.id?`${n.id}-fill-${l}`:void 0,points:[...m,...u],fill:i,hatch:t.getHatch?.(s.zoneIndex),stroke:"none"});}return o}function Me(a,e,t,n){let r=x.splitByThreshold(a,e,l=>l.value,x.interpolateDataPoint),o=[];return n.below&&o.push(...w(r.below.map(l=>({data:l})),t,n.below)),n.above&&o.push(...w(r.above.map(l=>({data:l})),t,n.above)),o}function W(a,e,t,n){let r=H(t);if(!r.markers.type||r.markers.type==="none")return [];let o=[];for(let l=0;l<a.length;l++){let s=a[l],i=e.timeScale.map(s.time),m=e.valueScale.map(s.value),u=n(s),c=t.pointStroke??u,d=t.pointFill??u,p=t.pointStrokeWidth??1.5,f=t.id?`${t.id}-marker-${l}`:void 0;Y(o,f,r.markers.type,i,m,r.markers.size,c,d,p);}return o}function Y(a,e,t,n,r,o,l,s,i){switch(t){case "circle":a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});break;case "square":a.push({type:"rect",x:n-o,y:r-o,w:o*2,h:o*2,fill:s,stroke:l,strokeWidth:i,id:e});break;case "cross":a.push({type:"line",x1:n-o,y1:r-o,x2:n+o,y2:r+o,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n-o,y1:r+o,x2:n+o,y2:r-o,stroke:l,strokeWidth:i,id:e});break;case "diamond":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r},{x:n,y:r+o},{x:n-o,y:r}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "triangle":a.push({type:"path",points:[{x:n,y:r-o},{x:n+o,y:r+o},{x:n-o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "star":{let m=[];for(let u=0;u<10;u++){let c=u%2===0?o:o*.5,d=Math.PI/2*3+u*Math.PI/5;m.push({x:n+c*Math.cos(d),y:r+c*Math.sin(d)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "arrow":a.push({type:"path",points:[{x:n-o,y:r+o},{x:n,y:r-o},{x:n+o,y:r+o}],stroke:l,strokeWidth:i,fill:"none",id:e});break;case "plus":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e},{type:"line",x1:n,y1:r-o,x2:n,y2:r+o,stroke:l,strokeWidth:i,id:e});break;case "triangle-down":a.push({type:"path",points:[{x:n,y:r+o},{x:n+o,y:r-o},{x:n-o,y:r-o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "hexagon":{let m=[];for(let u=0;u<6;u++){let c=u*(Math.PI/3);m.push({x:n+o*Math.cos(c),y:r+o*Math.sin(c)});}a.push({type:"path",points:m,fill:s,stroke:l,strokeWidth:i,id:e});break}case "hourglass":a.push({type:"path",points:[{x:n-o,y:r-o},{x:n+o,y:r-o},{x:n-o,y:r+o},{x:n+o,y:r+o}],fill:s,stroke:l,strokeWidth:i,id:e});break;case "line-horizontal":a.push({type:"line",x1:n-o,y1:r,x2:n+o,y2:r,stroke:l,strokeWidth:i,id:e});break;default:a.push({type:"circle",cx:n,cy:r,r:o,fill:s,stroke:l,strokeWidth:i,id:e});}}var L=12,E=8,X=20,_e=11,Z=18,U=a=>a.length*_e*.6;function $e(a,e="vertical"){if(e==="horizontal"){let n=0;for(let r of a)n+=L+E+U(r.name)+Z;return {width:Math.max(0,n-Z),height:X}}let t=0;for(let n of a)t=Math.max(t,U(n.name));return {width:L+E+t,height:a.length*X}}function Fe(a){let{items:e,x:t,y:n,orientation:r="vertical"}=a,o=[],l=t;return e.forEach((s,i)=>{let m=r==="horizontal"?l:t,u=r==="horizontal"?n:n+i*X;o.push({type:"rect",x:m,y:u,w:L,h:L,fill:s.color,stroke:h.legendStroke,strokeWidth:1},{type:"text",content:s.name,x:m+L+E,y:u+L-2,fontSize:h.legendFont,fill:h.legendText}),r==="horizontal"&&(l+=L+E+U(s.name)+Z);}),{type:"group",cssClass:"chart-legend",commands:o}}function Pe(a){let{xTicks:e,yTicks:t,xRange:n,yRange:r,stroke:o=h.gridStroke,strokeWidth:l=h.gridStrokeWidth,dashed:s=false,opacity:i=h.gridOpacity}=a,m=[];if(t)for(let u of t)m.push({type:"line",x1:n[0],y1:u,x2:n[1],y2:u,stroke:o,strokeWidth:l,dashed:s,opacity:i});if(e)for(let u of e)m.push({type:"line",x1:u,y1:r[0],x2:u,y2:r[1],stroke:o,strokeWidth:l,dashed:s,opacity:i});return m}var pe=new Map;function We(a,e){return `${a}|${JSON.stringify(e??{})}`}function A(a,e){let t=We(a,e),n=pe.get(t);return n||(n=new Intl.DateTimeFormat(a,e),pe.set(t,n)),n}var D=class{#e;#t;constructor(e){this.#e=[...e.domain],this.#t=[...e.range];}map(e){let t=Number(e),[n,r]=this.#e,[o,l]=this.#t;return r===n?o:o+(t-n)/(r-n)*(l-o)}invert(e){let[t,n]=this.#e,[r,o]=this.#t;return o===r?t:t+(e-r)/(o-r)*(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 D({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[r,o]=this.#e.domain(),l=o-r;if(l<=0)return {interval:k[0].ms};let s=l/e,i=k[0].ms;for(let c of k)if(c.ms>=s){i=c.ms;break}let m=i,u=Math.round(l/m);for(;u>n&&m<k[k.length-1].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.min(c+1,k.length-1)].ms,u=Math.round(l/m);}for(;u<t&&m>k[0].ms;){let c=k.findIndex(d=>d.ms===m);m=k[Math.max(c-1,0)].ms,u=Math.round(l/m);}return {interval:m}}ticks(e){let t=e?.minTicks??5,n=e?.maxTicks??12,{interval:r}=this.tickInterval((t+n)/2,t,n),[o,l]=this.#e.domain(),s=[],i=Math.ceil(o/r)*r;for(let m=i;m<=l;m+=r)s.push(m);return s}format(e,t){return A(this.#t,t).format(new Date(e))}},O=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 r=this.#r*2*Math.abs(t-e);return (Math.abs(t-e)-r)/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,r]=this.#t,o=this.#e.length;if(o<=1)return (n+r)/2;let l=this.#r*2*Math.abs(r-n),s=Math.abs(r-n)-l,i=r>=n?1:-1,m=s/o;return n+this.#r*Math.abs(r-n)*i+t*m}invert(e){let t=0,n=1/0;for(let r=0;r<this.#e.length;r++){let o=this.map(this.#e[r]),l=Math.abs(e-o);l<n&&(n=l,t=r);}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 Ae(a){return a==="dotted"?{dash:"dotted"}:a==="dashed"?{dash:"dashed"}:{}}function Re(a){let{thresholds:e,valueScale:t,xRange:n}=a,[r,o]=n,[l,s]=t.range(),i=Math.min(l,s),m=Math.max(l,s),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:r,y:i,w:o-r,h:Math.max(0,f-i),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:r,y:f,w:o-r,h:Math.max(0,m-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=Ae(g),y={type:"line",x1:r,y1:f,x2:o,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!==void 0&&d.label!==null&&d.label!==false){let b=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({...je(y,S,r,o,f,p,b),id:d.id?`${d.id}-label`:void 0});}}return {inside:u,labels:c}}function Oe(a){let e=Re(a);return [...e.inside,...e.labels]}function je(a,e,t,n,r,o,l){let s=(t+n)/2,i={type:"text",content:a,fontSize:h.thresholdFontSize,fill:o},m=l?{...l.rotate!==void 0&&{rotate:l.rotate},...l.textBaseline!==void 0&&{textBaseline:l.textBaseline}}:{};switch(e){case "left":return {...i,...m,x:t+4,y:r-4,anchor:"start"};case "above":return {...i,...m,x:s,y:r-6,anchor:"middle"};case "below":return {...i,...m,x:s,y:r+14,anchor:"middle"};case "center":return {...i,...m,x:s,y:r-4,anchor:"middle"};case "outside-left":return {...i,...m,x:t-6,y:r+3,anchor:"end",textBaseline:m.textBaseline??"middle"};case "outside-right":return {...i,...m,x:n+6,y:r+3,anchor:"start",textBaseline:m.textBaseline??"middle"};default:return {...i,...m,x:n-4,y:r-4,anchor:"end"}}}function Ie(a){let{gaps:e,timeScale:t,yRange:n,fill:r=h.gapFill,hatch:o,fillOpacity:l=h.gapFillOpacity??.15,stroke:s=h.gapStroke,strokeWidth:i=h.gapStrokeWidth,dashed:m=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),F=t.map(y.endTime),T=y.fill??r,P=y.hatch??o,me=y.fillOpacity??l,ue=y.label??"",Se=y.rotate??p,N=y.labelBaseline??d;if(y.style==="dashed_border"||!y.style?b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me,stroke:s,strokeWidth:i,dashed:m}):y.style==="empty"&&b.push({type:"rect",x:S,y:f,w:F-S,h:g-f,fill:T,hatch:P,opacity:me}),ue){let ke=Be(f,g,N),ve=N==="above"?"top":N==="below"?"bottom":"middle";b.push({type:"text",content:ue,x:(S+F)/2,y:ke,anchor:"middle",fontSize:u,fill:c,textBaseline:ve,rotate:Se});}}return b}function Be(a,e,t){switch(t){case "above":return a-12;case "below":return e+4;default:return (a+e)/2}}function He(a){let{markers:e,timeScale:t,valueScale:n,yRange:r=[0,300]}=a,[o,l]=r,s=[];for(let i of e){let m=t.map(i.time),u=i.color??h.markerColor,c=i.pointStyle??(i.value!==void 0?"circle":"none"),d=i.lineStyle??"full";if(i.value!==void 0){let p=n.map(i.value);if(d==="to-value"?s.push({type:"line",x1:m,y1:l,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="to-top"?s.push({type:"line",x1:m,y1:o,x2:m,y2:p,stroke:u,strokeWidth:1,dashed:true}):d==="full"&&s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),c!=="none"&&Y(s,void 0,c,m,p,h.markerSize,u,u,1.5),i.label){let f=d==="to-value"?p-10:o-6;s.push({type:"text",content:i.label,x:m,y:f,anchor:"middle",fontSize:11,fill:u});}}else s.push({type:"line",x1:m,y1:o,x2:m,y2:l,stroke:u,strokeWidth:1}),i.label&&s.push({type:"text",content:i.label,x:m,y:o-6,anchor:"middle",fontSize:11,fill:u});}return s}function Ve(a){let{highlights:e,timeScale:t,yRange:n,height:r}=a,[o,l]=n,s=[];for(let i of e){let m=t.map(i.startTime),u=t.map(i.endTime);s.push({type:"rect",x:m,y:o,w:u-m,h:l-o,fill:i.color??h.highlightColor,opacity:i.opacity??h.highlightOpacity}),i.label&&s.push({type:"text",content:i.label,x:(m+u)/2,y:Ee(i.labelPosition??"top",o,l,r),anchor:"middle",fontSize:h.annotationFontSize,fill:i.color??h.highlightLabelColor,rotate:i.rotate});}return s}function Ee(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 q(a){return a&&a.toString().normalize("NFKD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,50)||"unnamed"}function Ne(a){let{annotations:e,timeScale:t,valueScales:n}=a,r=[],o=l=>{let s=n.get(l.axis??0)??n.values().next().value;return {x:t.map(l.time),y:s?s.map(l.value):0}};for(let l of e){let s=[],i=m=>s.push(m);switch(l.type){case "line":{let m=o(l.from),u=o(l.to);i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:l.color??h.annotationColor,strokeWidth:l.width??h.annotationWidth,dash:l.dash});break}case "arrow":{let m=o(l.from),u=o(l.to),c=l.color??h.annotationColor,d=l.headSize??h.annotationHead;i({type:"line",x1:m.x,y1:m.y,x2:u.x,y2:u.y,stroke:c,strokeWidth:l.width??h.annotationWidth});let p=Math.hypot(u.x-m.x,u.y-m.y)||1,f=(u.x-m.x)/p,g=(u.y-m.y)/p,b=u.x-f*d,y=u.y-g*d;i({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 m=o(l.from),u=o(l.to);i({type:"rect",x:Math.min(m.x,u.x),y:Math.min(m.y,u.y),w:Math.abs(u.x-m.x),h:Math.abs(u.y-m.y),fill:l.fill??"none",stroke:l.stroke,opacity:l.opacity});break}case "point":{let m=o(l.at),u=l.color??"#334155",c=l.radius??h.annotationRadius,d=l.shape??"circle";d==="circle"?i({type:"circle",cx:m.x,cy:m.y,r:c,fill:u}):d==="square"?i({type:"rect",x:m.x-c,y:m.y-c,w:c*2,h:c*2,fill:u}):(i({type:"line",x1:m.x-c,y1:m.y-c,x2:m.x+c,y2:m.y+c,stroke:u,strokeWidth:1.5}),i({type:"line",x1:m.x-c,y1:m.y+c,x2:m.x+c,y2:m.y-c,stroke:u,strokeWidth:1.5}));break}case "label":{let m=o(l.at);i({type:"text",content:l.text,x:m.x+(l.dx??0),y:m.y+(l.dy??0),anchor:l.anchor??"middle",fontSize:h.annotationFontSize,fill:l.color??h.annotationColor,rotate:l.rotate});break}}if(l.id&&s.length>0){let m=q(l.id);r.push({type:"group",cssClass:`annotation annotation--${m}`,commands:s});}else r.push(...s);}return r}var K=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 J=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(`
|
|
25
25
|
`);return `<clipPath id="${e}">
|
|
26
26
|
${t}
|
|
27
|
-
</clipPath>`}get regions(){return [...this.#e]}};var j={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},I=class{#e;#t;constructor(e){this.#e=new W({domain:e.domain,range:e.xRange,locale:e.locale}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??j).axisColor}get tickColor(){return (this.#t.colors??j).tickColor}get textColor(){return (this.#t.colors??j).textColor}get textSize(){return (this.#t.colors??j).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??j,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 B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ee(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 Ne(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 Q=class{#e;#t;constructor(e){this.#e=new D({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??Ee,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??B,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=Ne(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 ee=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 O({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 te=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(...R(c,s,{...t,id:r?`${r}-marker`:void 0},()=>t.stroke));return u}};var ne=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 z(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=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 oe=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(...V(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(...V(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 ie=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],F=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==F>=f){let T=S.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));l.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...T,{x:T[T.length-1].x,y:b},{x:T[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(...R(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 ae=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 I({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 se=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 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,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 _=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 Ge={time:new M,value:new _,enum:new $};function le(a,e){let t=C();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 fe(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 ge(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=C(),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 ye(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 be(a){return a.style?.gap}function xe(a){return a.style?.fill}function ze(a){return {lines:fe(a),fill:xe(a),markers:ge(a),shadow:ye(a),gap:be(a),id:a.style?.id??a.id}}/*!
|
|
27
|
+
</clipPath>`}get regions(){return [...this.#e]}};var j={axisColor:h.axisColor,tickColor:h.tickColor,textColor:h.textColor,textSize:h.textSize},I=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??j).axisColor}get tickColor(){return (this.#t.colors??j).tickColor}get textColor(){return (this.#t.colors??j).textColor}get textSize(){return (this.#t.colors??j).textSize}generateTicks(){let e=this.#t.minTicks??5,t=this.#t.maxTicks??12,r=this.#e.ticks({minTicks:e,maxTicks:t}).map(o=>({time:o,x:this.#e.map(o),label:this.tickLabel(o)}));return this.antiOverlap(r)}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:r}=this.#e.tickInterval((t+n)/2,t,n),o={};return r<6e4?(o.hour="2-digit",o.minute="2-digit",o.second="2-digit"):r<36e5||r<864e5?(o.hour="2-digit",o.minute="2-digit"):r<31536e6?(o.day="numeric",o.month="short",r>=2592e6&&(o.day=void 0,o.month="long")):(o.year="numeric",r<2*31536e6&&(o.month="short")),this.#e.format(e,o)}antiOverlap(e){if(e.length<=1)return e;let t=60,n=[e[0]];for(let r=1;r<e.length;r++){let o=n[n.length-1].x;Math.abs(e[r].x-o)>=t&&n.push(e[r]);}return n}render(){let e=this.generateTicks(),t=this.#t.colors??j,n=this.#t.y??0,r=[],[o,l]=this.#e.range();r.push({type:"line",x1:o,y1:n,x2:l,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let s of e)r.push({type:"line",x1:s.x,y1:n,x2:s.x,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),r.push({type:"text",content:s.label,x:s.x,y:n+t.textSize+6,anchor:"middle",fontSize:t.textSize,fill:t.textColor});return r}};var B={axisColor:"#ccc",tickColor:"#ddd",textColor:"#777",textSize:12};function Ge(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 ze(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 r=t+1;r<n;r++)e[r]=true;t=n+1;}return e}var Q=class{#e;#t;constructor(e){this.#e=new D({domain:e.domain,range:e.range}),this.#t=e;}get scale(){return this.#e}get axisColor(){return (this.#t.colors??B).axisColor}get tickColor(){return (this.#t.colors??B).tickColor}get textColor(){return (this.#t.colors??B).textColor}get textSize(){return (this.#t.colors??B).textSize}generateTicks(){let e=this.#t.format??Ge,t=6,[n,r]=this.#e.domain(),o=r-n;if(o===0)return [{value:n,position:this.#e.map(n),label:e(n)}];let l=o/t,s=Math.pow(10,Math.floor(Math.log10(l))),i=l/s,m;i<=1.5?m=s:i<=3?m=2*s:i<=7?m=5*s:m=10*s;let u=[],c=Math.ceil(n/m)*m;for(let d=c;d<=r;d+=m)u.push({value:d,position:this.#e.map(d),label:e(d)});return u}render(){let e=this.generateTicks(),t=this.#t.colors??B,n=this.#t.x??0,r=this.#t.orientation??"vertical",o=this.#t.position??"left",l=this.#t.suppressLabelsNear??[],s=this.#t.suppressTolerancePx??8,i=u=>l.some(c=>Math.abs(c-u)<=s),m=[];if(r==="vertical"){let[u,c]=this.#e.range();m.push({type:"line",x1:n,y1:u,x2:n,y2:c,stroke:t.axisColor,strokeWidth:t.axisWidth});let d=ze(e);e.forEach((p,f)=>{let g=i(p.position),b=d[f]?{opacity:0}:{};o==="left"?(m.push({type:"line",x1:n-4,y1:p.position,x2:n,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.push({type:"text",content:p.label,x:n-8,y:p.position+4,anchor:"end",fontSize:11,fill:t.textColor,...b})):(m.push({type:"line",x1:n,y1:p.position,x2:n+4,y2:p.position,stroke:t.tickColor,strokeWidth:t.axisWidth}),g||m.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();m.push({type:"line",x1:u,y1:n,x2:c,y2:n,stroke:t.axisColor,strokeWidth:t.axisWidth});for(let d of e)m.push({type:"line",x1:d.position,y1:n,x2:d.position,y2:n+6,stroke:t.tickColor,strokeWidth:t.axisWidth}),m.push({type:"text",content:d.label,x:d.position,y:n+18,anchor:"middle",fontSize:t.textSize,fill:t.textColor});}return m}};var ee=class{#e;#t;#n;constructor(e){let t=Object.keys(e.enumMap).map(Number).sort((n,r)=>n-r).map(String);this.#t=t,this.#e=new O({domain:t,range:e.range}),this.#n=e;}get scale(){return this.#e}generateTicks(){let{enumMap:e,showLabels:t=true,autoColor:n=true,gapValues:r}=this.#n,o=new Set(r??[]);return this.#t.map((l,s)=>{let i=Number(l),m=t?e[i]??String(i):String(i),u=this.#e.map(i),c=n?h.palette[s%h.palette.length]:void 0;return {value:i,label:m,y:u,color:c,isGap:o.has(i)}})}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 r of e)r.isGap||n.push({type:"text",content:r.label,x:t,y:r.y+4,anchor:"end",fontSize:11,fill:r.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 te=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,r=e.gapThreshold??h.gapThreshold,o=e.id,l=x.getRuns(this.data,c=>c.value===null,r),s=l.reduce((c,d)=>c+d.length,0);if(s===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=l.map(c=>({data:c})),u=[];if(u.push(...w(m,i,{...t,id:o?`${o}-line`:void 0})),t.pointStyle&&t.pointStyle!=="none"&&s<=n)for(let c of l)u.push(...W(c,i,{...t,id:o?`${o}-marker`:void 0},()=>t.stroke));return u}};var ne=class extends v{#e;constructor(e){super(e,e.data),this.#e=e;}points(){let e=this.#e.valueScale,t=[...this.data].filter(r=>r.value!==null).sort((r,o)=>r.time-o.time),n=[];for(let r=0;r<t.length;r++){let o=this.timeScale.map(t[r].time),l=e.map(t[r].value);r===0?n.push({x:o,y:l}):n.push({x:o,y:n[n.length-1].y},{x:o,y:l});}return n}render(){let e=x.getRuns(this.data,r=>r.value===null);if(e.length===0)return [];let t={timeScale:this.timeScale,valueScale:this.#e.valueScale},n=e.map(r=>({data:r}));return z(n,t,{stroke:this.#e.stroke??h.stroke,strokeWidth:this.#e.strokeWidth??h.strokeWidth,id:this.id?`${this.id}-line`:void 0})}};var re=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,r=e.avgLine??false,o=e.avgLineColor??h.bandAvgLine,l=e.bandWidth??10,s=[];for(let i of this.data){if(i.min===null||i.max===null)continue;let m=this.timeScale.map(i.time),u=e.valueScale.map(i.max),c=e.valueScale.map(i.min),d=l,p=this.data.indexOf(i);if(s.push({type:"rect",x:m-d/2,y:u,w:d,h:c-u,fill:t,hatch:n,opacity:this.opacity(i.count),id:this.id?`${this.id}-slot-${p}`:void 0}),r&&i.avg!==null){let f=e.valueScale.map(i.avg);s.push({type:"line",x1:m-d/2,y1:f,x2:m+d/2,y2:f,stroke:o,strokeWidth:1,id:this.id?`${this.id}-avg-${p}`:void 0});}}return s}};var oe=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,r=e.avgColor??h.avgColor,o=e.avgDashed??true,l=e.smoothing??false,s=e.strokeWidth??h.strokeWidth,i=x.getRuns(this.data,p=>p.min===null||p.max===null||p.avg===null);if(i.length===0)return [];let m={timeScale:this.timeScale,valueScale:e.valueScale},u=[];i.forEach((p,f)=>{p.length<2||(e.fillToMax&&u.push(...V(p,m,{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(...V(p,m,{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=i.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),m,{stroke:n,strokeWidth:s,smoothing:l,id:this.id?`${this.id}-max`:void 0}),...w(d(p=>p.min),m,{stroke:t,strokeWidth:s,smoothing:l,id:this.id?`${this.id}-min`:void 0}),...w(d(p=>p.avg),m,{stroke:r,strokeWidth:s,smoothing:l,dashed:o,id:this.id?`${this.id}-avg`:void 0})),u}};var ie=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},r=e.gapThreshold??h.gapThreshold,o=e.pointThreshold??h.pointThreshold,l=x.getRuns(this.data,u=>u.value===null,r),s=l.reduce((u,c)=>u+c.length,0);if(s===0)return [];let i={timeScale:this.timeScale,valueScale:e.valueScale},m=[];for(let u of l){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],F=(S.data[0].value+S.data[S.data.length-1].value)/2;if(e.fill.side==="above"==F>=f){let T=S.data.map(P=>({x:this.timeScale.map(P.time),y:e.valueScale.map(P.value)}));m.push({type:"path",id:this.id?`${this.id}-fill-${y}`:void 0,points:[...T,{x:T[T.length-1].x,y:b},{x:T[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)}));m.push(...w(p,i,{...n,id:this.id?`${this.id}-line`:void 0})),n.pointStyle&&n.pointStyle!=="none"&&s<=o&&m.push(...W(u,i,{...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 m}};var ae=class{#e;constructor(e,t,n,r){this.#e={...e,xRange:t,y:n,height:r};}render(){let{items:e,timeScale:t,background:n,hatch:r,showAxis:o,xRange:l,y:s,height:i}=this.#e,m=[];n&&m.push({type:"rect",x:l[0],y:s,w:l[1]-l[0],h:i,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)&&(m.push({type:"rect",x:c,y:s,w:d-c,h:i,hatch:u.hatch??r,fill:u.fill??"#6b728044",stroke:u.stroke,strokeWidth:u.strokeWidth??0}),u.label)){let p=u.labelFontSize??10;m.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(o){let u=new I({domain:t.domain(),xRange:l,y:s+i+4});m.push({type:"group",cssClass:"annotation-band-axis",commands:u.render()});}return m}#t(e,t){let{y:n,height:r}=this.#e;switch(e){case "top":return n+t*.9;case "bottom":return n+r-t*.25;default:return n+r/2+t*.35}}};var se=class{#e;constructor(e){this.#e=e;}render(){let{data:e,valueScale:t,xRange:n,showMin:r=false,showMax:o=false,showAvg:l=true,showMedian:s=false,labelPosition:i="end",lineColor:m=h.statsLineColor,labelColor:u=h.statsLabelColor}=this.#e,c=ce.compute(e),d=[{name:"min",value:c.min,enabled:r},{name:"max",value:c.max,enabled:o},{name:"avg",value:c.avg,enabled:l},{name:"median",value:c.median,enabled:s}],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:m,strokeWidth:1});let S=`${b.name}: ${b.value.toFixed(1)}`;(i==="start"||i==="both")&&p.push({type:"text",content:S,x:f+4,y:y-4,anchor:"start",fontSize:10,fill:u}),(i==="end"||i==="both")&&p.push({type:"text",content:S,x:g-4,y:y-4,anchor:"end",fontSize:10,fill:u}),i==="center"&&p.push({type:"text",content:S,x:(f+g)/2,y:y-4,anchor:"middle",fontSize:10,fill:u});}return p}};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,n){try{let r=this.#n&&n?this.#r(e,n,t):t;return A(this.#e,r).format(new Date(e))}catch{for(let r of this.#t)try{return A(r,t).format(new Date(e))}catch{}return new Date(e).toISOString()}}formatRange(e,t){let n=this.format(e),r=this.format(t);return `${n} \u2014 ${r}`}#r(e,t,n){let r=Math.abs(e-t),o=864e5,l=36e5,s=6e4,i={};return r<s?(i.second="2-digit",i.minute="2-digit",i.hour="2-digit"):r<l?(i.minute="2-digit",i.hour="2-digit"):r<o?(i.hour="2-digit",i.minute="2-digit"):r<7*o?(i.weekday="short",i.day="numeric"):r<365*o?(i.month="short",i.day="numeric"):(i.month="short",i.year="numeric"),{...n,...i}}};var _=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((r,o)=>{n[o]=r;}),new a({map:n,showValue:t})}};var Ye={time:new M,value:new _,enum:new $};function le(a,e){let t=C();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 fe(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 ge(a){let e=a.style?.markers;if(!e?.type||e.type==="none")return;let t=C(),r=(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??r,fill:e.fill??"#ffffff",strokeWidth:e.strokeWidth??1,threshold:e.threshold}}function ye(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 be(a){return a.style?.gap}function xe(a){return a.style?.fill}function Xe(a){return {lines:fe(a),fill:xe(a),markers:ge(a),shadow:ye(a),gap:be(a),id:a.style?.id??a.id}}/*!
|
|
28
28
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
29
29
|
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
30
30
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
@@ -43,4 +43,4 @@ var G=class{};var x=class{static interpolateDataPoint(a,e,t){return {time:a.time
|
|
|
43
43
|
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
44
44
|
* MIT with Attribution: free use incl. commercial must have visible credit to
|
|
45
45
|
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
46
|
-
*/export{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,$ as EnumFormatter,
|
|
46
|
+
*/export{ae as AnnotationBandSeries,O as BandScale,re as BandSeries,J as Clip,ee as EnumAxis,$ as EnumFormatter,Ye as Formatters,K as Layout,te as LineSeries,D as LinearScale,oe as MinMaxAvgSeries,G as Renderer,se as StatsOverlay,ne as StepSeries,k as TIME_INTERVALS,I as TimeAxis,M as TimeFormatter,R as TimeScale,Q as ValueAxis,_ as ValueFormatter,ie as ZonedLineSeries,he as getHatch,$e as measureLegend,Ne as renderAnnotations,De as renderArea,Ie as renderGaps,Pe as renderGrid,Ve as renderHighlights,Fe as renderLegend,w as renderLine,He as renderMarkers,W as renderSeriesMarkers,Me as renderSplitLine,z as renderStep,Oe as renderThresholds,V as renderZonedArea,xe as resolveFill,be as resolveGap,fe as resolveLines,ge as resolveMarkers,Xe as resolveSeriesStyle,ye as resolveShadow,q as slugify,h as theme};
|
|
@@ -40,6 +40,35 @@ interface Point {
|
|
|
40
40
|
*/
|
|
41
41
|
/** All available line-stroke variants. */
|
|
42
42
|
type LineVariant = "solid" | "dotted" | "sparse-dots" | "dashed" | "long-dash" | "dense-dash" | "dash-dot" | "dash-dot-dot" | "loose-dash";
|
|
43
|
+
/** Renderer-ready stroke attributes. */
|
|
44
|
+
interface SVGLineStyle {
|
|
45
|
+
strokeDasharray: string;
|
|
46
|
+
strokeLinecap: "butt" | "round" | "square";
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What the renderer ACTUALLY draws for a line — including the two historical
|
|
50
|
+
* exceptions.
|
|
51
|
+
*
|
|
52
|
+
* `dashed` and `dotted` predate the variant table and kept their fixed patterns
|
|
53
|
+
* ("4,4" and "2,4", not scaled by stroke width) so that existing charts did not
|
|
54
|
+
* change appearance when the other variants arrived. That is a deliberate
|
|
55
|
+
* difference from {@link getLineStyle}, and it is the reason this function
|
|
56
|
+
* exists: anyone drawing a legend swatch outside the renderer has to reproduce
|
|
57
|
+
* what the chart draws, not what the table says. Getting this wrong is nearly
|
|
58
|
+
* invisible — a swatch dashed 6-on-4 next to a curve dashed 4-on-4 — which is
|
|
59
|
+
* exactly why it should not be re-derived by hand.
|
|
60
|
+
*
|
|
61
|
+
* Returns `null` for a solid line (no dash attributes at all).
|
|
62
|
+
*/
|
|
63
|
+
declare function resolveDash(variant: LineVariant | undefined, strokeWidth?: number, dashed?: boolean): {
|
|
64
|
+
strokeDasharray: string;
|
|
65
|
+
strokeLinecap?: SVGLineStyle["strokeLinecap"];
|
|
66
|
+
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* Build SVG stroke attributes for a given line variant.
|
|
69
|
+
* All dash patterns scale proportionally with the stroke width.
|
|
70
|
+
*/
|
|
71
|
+
declare function getLineStyle(variant: LineVariant, strokeWidth?: number): SVGLineStyle;
|
|
43
72
|
|
|
44
73
|
/**
|
|
45
74
|
* Stroke pattern for path / line draw commands. Widened to {@link LineVariant}
|
|
@@ -847,4 +876,4 @@ declare class BandScale implements Scale {
|
|
|
847
876
|
positions(): Map<string, number>;
|
|
848
877
|
}
|
|
849
878
|
|
|
850
|
-
export { type
|
|
879
|
+
export { type DomainScaleConfig as $, type AnySeries as A, type SVGLineStyle as B, type SensorType as C, type DrawCommand as D, type EnumMap as E, type FillSpec as F, type Gap as G, type Highlight as H, type SeriesOverlay as I, type SeriesOverlayKind as J, type SeriesType as K, type LineVariant as L, type MarkerStyle as M, type ShadowStyle as N, type ThresholdLabelConfig as O, type PointStyleType as P, getLineStyle as Q, resolveDash as R, type SeriesStyle as S, type Threshold as T, BandScale as U, type Point as V, type AxisOrientation as W, type AxisPosition as X, type BandScaleConfig as Y, type CircleParams as Z, type Dashstyle_t as _, type GapsConfig as a, type DrawCircle as a0, type DrawGap as a1, type DrawGapType_t as a2, type DrawGradient as a3, type DrawGroup as a4, type DrawLine as a5, type DrawPath as a6, type DrawRect as a7, type DrawText as a8, type LabelAnchor as a9, type LineParams as aa, type LinearScaleConfig as ab, type PathParams as ac, type RectParams as ad, type Scale as ae, type ScaleConfig as af, TIME_INTERVALS as ag, type TextParams as ah, type TimeScaleConfig as ai, getHatch as aj, 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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DrawCommand,
|
|
1
|
+
import { D as DrawCommand, L as LineVariant, P as PointStyleType, a4 as DrawGroup, j as AggregatedPoint, d as TimeScale, e as LinearScale, l as DataPoint } from './scale-ByGpczxS.js';
|
|
2
2
|
|
|
3
3
|
/** Output format type for the renderer (SVG string, Canvas, or nothing). */
|
|
4
4
|
type RenderType = "svg" | "canvas" | "none";
|
|
@@ -198,6 +198,21 @@ declare function resetDefaultTheme(): void;
|
|
|
198
198
|
interface LegendItem {
|
|
199
199
|
name: string;
|
|
200
200
|
color: string;
|
|
201
|
+
/**
|
|
202
|
+
* The series' line variant, for a caller drawing its own legend: the swatch
|
|
203
|
+
* has to show the same dashes as the curve it names, or it is wrong the moment
|
|
204
|
+
* two series differ by anything but colour — a black-and-white print.
|
|
205
|
+
* Undefined for a series with several lines (no single answer) or none.
|
|
206
|
+
* Turn it into SVG attributes with `getLineStyle()`.
|
|
207
|
+
*/
|
|
208
|
+
line?: LineVariant;
|
|
209
|
+
/**
|
|
210
|
+
* The marker shape — but only when markers are actually drawn. A series with
|
|
211
|
+
* `markers.threshold` hides them above that many samples, and a symbol in the
|
|
212
|
+
* legend that is missing from the chart states something untrue.
|
|
213
|
+
* Draw it with `drawMarker()`.
|
|
214
|
+
*/
|
|
215
|
+
marker?: Exclude<PointStyleType, "none">;
|
|
201
216
|
}
|
|
202
217
|
/** Layout direction for legend items. */
|
|
203
218
|
type LegendOrientation = "vertical" | "horizontal";
|
|
@@ -273,4 +288,94 @@ declare class Layout {
|
|
|
273
288
|
static default(width?: number, height?: number): Layout;
|
|
274
289
|
}
|
|
275
290
|
|
|
276
|
-
|
|
291
|
+
/*!
|
|
292
|
+
* MLTimeGraph — Copyright (c) 2026 Michael Lechner
|
|
293
|
+
* MIT with Attribution: free use incl. commercial requires visible credit to
|
|
294
|
+
* "Michael Lechner". Commercial license (no attribution) on request. See LICENSE.
|
|
295
|
+
*/
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Flat style configuration for series rendering.
|
|
299
|
+
* All fields are optional — defaults are applied internally via `resolveStyle()`.
|
|
300
|
+
*/
|
|
301
|
+
interface SeriesStyle {
|
|
302
|
+
/** Stroke color. */
|
|
303
|
+
stroke?: string;
|
|
304
|
+
/** Stroke width in pixels. */
|
|
305
|
+
strokeWidth?: number;
|
|
306
|
+
/** Enable Catmull-Rom smoothing. */
|
|
307
|
+
smoothing?: boolean;
|
|
308
|
+
/** Enable dashed line style. */
|
|
309
|
+
dashed?: boolean;
|
|
310
|
+
/** Fill colour (hex, rgba, or `url(#gradient-id)`). */
|
|
311
|
+
fill?: string;
|
|
312
|
+
/** Hatch pattern for fill (default: none). */
|
|
313
|
+
hatch?: string;
|
|
314
|
+
/** Data-point marker style. */
|
|
315
|
+
pointStyle?: PointStyleType;
|
|
316
|
+
/** Marker size (radius or half-width). */
|
|
317
|
+
pointSize?: number;
|
|
318
|
+
/** Marker outline colour. Default: same as the line's stroke (per-point). */
|
|
319
|
+
pointStroke?: string;
|
|
320
|
+
/** Marker fill colour. Default: same as the line's stroke. */
|
|
321
|
+
pointFill?: string;
|
|
322
|
+
/** Marker outline width. Default: 1.5. */
|
|
323
|
+
pointStrokeWidth?: number;
|
|
324
|
+
/** Shadow color. */
|
|
325
|
+
shadowColor?: string;
|
|
326
|
+
/** Shadow blur in pixels. */
|
|
327
|
+
shadowBlur?: number;
|
|
328
|
+
/** Shadow X offset. */
|
|
329
|
+
shadowOffsetX?: number;
|
|
330
|
+
/** Shadow Y offset. */
|
|
331
|
+
shadowOffsetY?: number;
|
|
332
|
+
/** SVG id prefix for all elements generated by this style. */
|
|
333
|
+
id?: string;
|
|
334
|
+
}
|
|
335
|
+
interface RenderingContext {
|
|
336
|
+
timeScale: TimeScale;
|
|
337
|
+
valueScale: LinearScale;
|
|
338
|
+
}
|
|
339
|
+
/** Render segments as continuous lines (standard or smoothed). */
|
|
340
|
+
declare function renderLine(segments: {
|
|
341
|
+
data: DataPoint[];
|
|
342
|
+
color?: string;
|
|
343
|
+
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
344
|
+
declare function renderStep(segments: {
|
|
345
|
+
data: DataPoint[];
|
|
346
|
+
color?: string;
|
|
347
|
+
}[], ctx: RenderingContext, style: SeriesStyle): DrawCommand[];
|
|
348
|
+
/** Render segments as a filled area between two values (e.g. min/max band). */
|
|
349
|
+
declare function renderArea(segments: {
|
|
350
|
+
data: AggregatedPoint[];
|
|
351
|
+
color?: string;
|
|
352
|
+
}[], ctx: RenderingContext, style: SeriesStyle, yLow: (p: AggregatedPoint) => number, yHigh: (p: AggregatedPoint) => number): DrawCommand[];
|
|
353
|
+
/**
|
|
354
|
+
* Complex area renderer that splits a run by value boundaries (thresholds)
|
|
355
|
+
* and renders the resulting zones as separate filled areas.
|
|
356
|
+
*/
|
|
357
|
+
declare function renderZonedArea<T extends {
|
|
358
|
+
time: number;
|
|
359
|
+
}>(run: T[], ctx: RenderingContext, options: {
|
|
360
|
+
boundaries: number[];
|
|
361
|
+
yLow: (p: T) => number;
|
|
362
|
+
yHigh: (p: T) => number;
|
|
363
|
+
getValue: (p: T) => number;
|
|
364
|
+
interpolate: (p1: T, p2: T, t: number) => T;
|
|
365
|
+
getColor: (zoneIndex: number) => string | undefined;
|
|
366
|
+
getHatch?: (zoneIndex: number) => string | undefined;
|
|
367
|
+
}, style?: SeriesStyle): DrawCommand[];
|
|
368
|
+
/**
|
|
369
|
+
* Render a line series split by a threshold value, allowing different styles
|
|
370
|
+
* for parts above and below that value.
|
|
371
|
+
*/
|
|
372
|
+
declare function renderSplitLine(run: DataPoint[], threshold: number, ctx: RenderingContext, styles: {
|
|
373
|
+
above?: SeriesStyle;
|
|
374
|
+
below?: SeriesStyle;
|
|
375
|
+
}): DrawCommand[];
|
|
376
|
+
/** Render point markers for segments. */
|
|
377
|
+
declare function renderMarkers(points: DataPoint[], ctx: RenderingContext, style: SeriesStyle, getColor: (p: DataPoint) => string): DrawCommand[];
|
|
378
|
+
declare function drawMarker(// NOSONAR
|
|
379
|
+
commands: DrawCommand[], id: string | undefined, shape: Exclude<PointStyleType, "none">, x: number, y: number, size: number, stroke: string, fill: string, sw: number): void;
|
|
380
|
+
|
|
381
|
+
export { type LegendOrientation as L, type Marker as M, Renderer as R, type Theme as T, type LegendItem as a, type LayoutResult as b, type RenderOutput as c, drawMarker as d, Layout as e, type LayoutConfig as f, getDefaultTheme as g, type LegendConfig as h, renderArea as i, renderLegend as j, renderLine as k, renderMarkers as l, measureLegend as m, renderSplitLine as n, renderStep as o, renderZonedArea as p, resetDefaultTheme as r, setDefaultTheme as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ml-time-graph",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "TypeScript library for time-series chart rendering — DOM-free SVG output (works in the browser and on the server).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,12 +27,19 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"dist",
|
|
29
29
|
"docs",
|
|
30
|
+
"SKILLS.md",
|
|
30
31
|
"README.md",
|
|
31
32
|
"README.de.md",
|
|
32
33
|
"USAGE.md",
|
|
33
34
|
"API_DESIGN.md",
|
|
34
35
|
"LICENSE"
|
|
35
36
|
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"prepublishOnly": "tsup"
|
|
42
|
+
},
|
|
36
43
|
"keywords": [
|
|
37
44
|
"chart",
|
|
38
45
|
"time-series",
|
|
@@ -46,7 +53,7 @@
|
|
|
46
53
|
"mkt"
|
|
47
54
|
],
|
|
48
55
|
"devDependencies": {
|
|
49
|
-
"ml-time-analyze": "
|
|
56
|
+
"ml-time-analyze": "workspace:*"
|
|
50
57
|
},
|
|
51
58
|
"author": "Michael Lechner",
|
|
52
59
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -61,10 +68,5 @@
|
|
|
61
68
|
},
|
|
62
69
|
"engines": {
|
|
63
70
|
"node": ">=18"
|
|
64
|
-
},
|
|
65
|
-
"scripts": {
|
|
66
|
-
"build": "tsup",
|
|
67
|
-
"test": "vitest run",
|
|
68
|
-
"typecheck": "tsc --noEmit"
|
|
69
71
|
}
|
|
70
|
-
}
|
|
72
|
+
}
|