@canplot/react 0.1.17 → 0.1.18
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/dist/canplot.cjs +1 -1
- package/dist/canplot.cjs.map +1 -1
- package/dist/canplot.mjs +3 -5
- package/dist/canplot.mjs.map +1 -1
- package/dist/frameContext.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/canplot.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),v=require("react"),Q=require("zustand"),O=(e,s,t)=>Math.min(Math.max(e,s),t),ke=e=>e.reduce((s,t)=>s+(t??0),0),Me=(e,s)=>{let t=0;for(let n=0;n<e.length;n++)Math.abs(e[n]-s)<Math.abs(e[t]-s)&&(t=n);return t},ve=(e,s,t,n)=>{const{min:o,max:i,origin:r}=D(e,t),u=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,d=(r==="x"?u.width:u.height)/(i-o);return s/d},D=(e,s)=>{const t=e.scales.find(n=>n.id===s);if(!t)throw new Error(`Scale ${s} not found`);return t},A=(e,s)=>{const t=window.devicePixelRatio||1;e.lineCap=s?.lineCap??"butt",e.lineDashOffset=t*(s?.lineDashOffset??0),e.lineJoin=s?.lineJoin??"miter",e.lineWidth=t*(s?.lineWidth??1),e.miterLimit=t*(s?.miterLimit??10),e.strokeStyle=s?.strokeStyle??"black",e.fillStyle=s?.fillStyle??e.strokeStyle,e.font=s?.font??`${10*t}px sans-serif`,e.textAlign=s?.textAlign??"start",e.direction=s?.direction??"inherit",e.textBaseline=s?.textBaseline??"alphabetic",e.fontKerning=s?.fontKerning??"auto"},ee=(e,s,t,n)=>{const o=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,{min:i,max:r,origin:u}=D(e,t),d=(u==="x"?o.width:o.height)/(r-i);return s*d},B=(e,s,t,n)=>{const{min:o,origin:i}=D(e,t),r=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,u=ee(e,s-o,t,n);return i==="x"?O(r.x+u,r.x-10*r.width,r.x+11*r.width):O(r.y+r.height-u,r.y-10*r.height,r.y+11*r.height)},Re=(e,s,t)=>{const{min:n,max:o}=D(e,t);return O(s,n,o)},Y=(e,s,t)=>{const n=t==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS;return O(s,n.x,n.x+n.width)},j=(e,s,t)=>{const n=t==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS;return O(s,n.y,n.y+n.height)},Z=(e,s,t)=>{const{min:n,max:o}=D(e,t);return s>=n&&s<=o},U=(e,s,t,n)=>{const{min:o,max:i,origin:r}=D(e,t),u=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,d=r==="x"?(s-u.x)/u.width:(u.height-s+u.y)/u.height;return o+d*(i-o)},Ae=e=>{const{ctx:s,scales:t}=e;for(const n of t){if(!n.axis)continue;s.save(),A(s,{strokeStyle:"black",fillStyle:"black",lineWidth:1,...n.axis.style});const o=n.axis.canvasRect;if(n.origin==="x"){if(n.axis.position==="bottom")s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(o.x+o.width,o.y),s.stroke();else if(n.axis.position==="top"){const i=o.y+o.height;s.beginPath(),s.moveTo(o.x,i),s.lineTo(o.x+o.width,i),s.stroke()}}else if(n.axis.position==="left"){const i=o.x+o.width;s.beginPath(),s.moveTo(i,o.y),s.lineTo(i,o.y+o.height),s.stroke()}else n.axis.position==="right"&&(s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(o.x,o.y+o.height),s.stroke());s.restore()}},Ie=()=>Q.createStore((e,s)=>{const t=()=>{const n=s()._frame;if(!n)throw new Error("No frame set in frame store");return n};return{_frame:null,getFrame:t,getCtx:()=>t().ctx,clampXPosToChartArea:(n,o)=>Y(t(),n,o??"canvas"),clampYPosToChartArea:(n,o)=>j(t(),n,o??"canvas"),valToPos:(n,o,i)=>B(t(),n,o,i??"canvas"),valToPxDistance:(n,o,i)=>ee(t(),n,o,i??"canvas"),valFits:(n,o)=>Z(t(),n,o),getScale:n=>D(t(),n)}}),Le=()=>Q.createStore(e=>({notify:()=>{e(s=>({version:s.version+1}))},version:0})),ue=v.createContext(null),ge=v.createContext(null),F=(e,s)=>{const t=v.useContext(ue),n=v.useContext(ge);if(!t||!n)throw new Error("useFrame must be used within a CanPlot component");const o=v.useRef(e);o.current=e,v.useLayoutEffect(()=>{o.current(t.getState()),t.subscribe(i=>{i._frame&&o.current(i)})},[t]),v.useEffect(()=>{n.getState().notify()},[n,...s])},te=e=>{const s=v.useContext(ue);if(!s)throw new Error("useFrame must be used within a CanPlot component");return Q.useStore(s,e??(t=>t.getFrame()))};function Ue(e){return s=>{for(const t of e)le(t,s)}}function De(e){return s=>{const t=[];for(const n of e){const o=le(n,s),i=typeof o=="function";t.push(i?o:()=>le(n,null))}return()=>{for(const n of t)n()}}}function le(e,s){if(typeof e=="function")return e(s);e&&(e.current=s)}var _e=parseInt(v.version.split(".")[0],10)>=19?De:Ue;const Xe=v.forwardRef(({configuration:e,children:s,style:t,className:n},o)=>{const i=v.useRef(null),r=v.useRef(null),u=Ke(r),d=v.useMemo(Ie,[]),c=v.useMemo(Le,[]);v.useLayoutEffect(()=>{d.setState({_frame:ze(e,u,i.current)})},[e,u,i,d]),v.useLayoutEffect(()=>d.subscribe(m=>{m._frame&&Ye(m._frame)}),[d]),v.useLayoutEffect(()=>{let m=!1;return c.subscribe(()=>{m||(m=!0,window.requestAnimationFrame(()=>{m=!1,d.setState(f=>({_frame:f._frame?{...f._frame}:null}))}))})},[c,d]);const a=window.devicePixelRatio||1;return k.jsxs("div",{ref:_e([o,r]),className:n,style:{position:"relative",overflow:"hidden",...t},"data-canplotroot":!0,children:[k.jsx("canvas",{ref:i,width:u.width*a,height:u.height*a,style:{inset:0,position:"absolute",width:`${u.width}px`,height:`${u.height}px`}}),k.jsx(Fe,{frameStore:d,updateRequestStore:c,children:s})]})}),Fe=({frameStore:e,updateRequestStore:s,children:t})=>Q.useStore(e,o=>!!o._frame)?k.jsx(ge.Provider,{value:s,children:k.jsx(ue.Provider,{value:e,children:t})}):null,Ke=e=>{const[s,t]=v.useState({width:0,height:0}),[n]=v.useState(()=>new ResizeObserver(o=>{for(const i of o){const r=Math.round(i.contentRect.width),u=Math.round(i.contentRect.height);t(d=>d.width!==r||d.height!==u?{...d,width:r,height:u}:d)}}));return v.useLayoutEffect(()=>{if(!e.current)return;const o=e.current.clientWidth,i=e.current.clientHeight;return t(r=>r.width!==o||r.height!==i?{...r,width:o,height:i}:r),n.observe(e.current,{box:"border-box"}),()=>n.disconnect()},[n,e]),s},ze=(e,s,t)=>{const n=t?.getContext("2d");if(!n)return null;const o=window.devicePixelRatio||1;if(s.width===0||s.height===0)return null;const i={x:e.padding.left,y:e.padding.top,width:s.width-e.padding.left-e.padding.right,height:s.height-e.padding.top-e.padding.bottom};for(const h of e.scales)h.axis&&(h.origin==="x"?(h.axis.position==="bottom"||h.axis.position==="top")&&(i.height=Math.max(0,i.height-h.axis.size),h.axis.position==="top"&&(i.y+=h.axis.size)):(h.axis.position==="left"||h.axis.position==="right")&&(i.width=Math.max(0,i.width-h.axis.size),h.axis.position==="left"&&(i.x+=h.axis.size)));const r={x:i.x*o,y:i.y*o,width:i.width*o,height:i.height*o},u=[];let d=e.padding.left*o,c=n.canvas.width-e.padding.right*o,a=n.canvas.height-e.padding.bottom*o,m=e.padding.top*o;for(const h of e.scales){if(!h.axis){u.push({...h,axis:null});continue}let l;if(h.origin==="x")switch(h.axis.position){case"bottom":a-=h.axis.size*o,l={x:i.x,y:a/o,width:i.width,height:h.axis.size};break;case"top":m+=h.axis.size*o,l={x:i.x,y:m/o-h.axis.size,width:i.width,height:h.axis.size};break;case"left":case"right":throw new Error("Invalid axis position for x origin")}else switch(h.axis.position){case"left":d+=h.axis.size*o,l={x:d/o-h.axis.size,y:i.y,width:h.axis.size,height:i.height};break;case"right":c-=h.axis.size*o,l={x:c/o,y:i.y,width:h.axis.size,height:i.height};break;case"top":case"bottom":throw new Error("Invalid axis position for y origin")}const p={x:l.x*o,y:l.y*o,width:l.width*o,height:l.height*o};u.push({...h,axis:{...h.axis,cssRect:l,canvasRect:p}})}return{ctx:n,dpr:o,padding:e.padding,scales:u,chartAreaCSS:i,chartAreaCanvasPX:r}},Ye=e=>{e.ctx.clearRect(0,0,e.ctx.canvas.width,e.ctx.canvas.height),Ae(e)},je=({data:e,xScaleId:s,yScaleId:t,style:n})=>(F(({getCtx:o,clampXPosToChartArea:i,clampYPosToChartArea:r,valToPos:u})=>{const d=o();d.save(),d.beginPath(),A(d,n);for(const c of e){const a=i(u(c.x,s)),m=r(u(c.y,t));d.lineTo(a,m)}d.stroke(),d.restore()},[e,s,t,n]),null),Oe=({data:e,xScaleId:s,yScaleId:t,radius:n=5,style:o})=>(F(({getCtx:i,valToPos:r,valFits:u})=>{const d=i();d.save(),d.beginPath(),A(d,o);for(const c of e){if(!u(c.x,s)||!u(c.y,t))continue;const a=r(c.x,s),m=r(c.y,t);d.moveTo(a+n,m),d.arc(a,m,n,0,Math.PI*2)}d.stroke(),d.fill(),d.restore()},[e,s,t,n,o]),null),Be=({data:e,xScaleId:s,yScaleId:t,style:n,barWidth:o,xPositionOffset:i,radius:r})=>(F(({getCtx:u,valToPxDistance:d,valToPos:c,clampXPosToChartArea:a,clampYPosToChartArea:m})=>{if(e.length===0)return;const f=u();f.save(),A(f,n);const h=d(o,s);f.beginPath();for(const l of e){const x=c(l.x,s)-h/2+i*h,g=m(c(0,t)),S=m(c(l.y,t)),y=g-S,w=a(x),T=a(x+h)-w;r?f.roundRect(w,S,T,y,r):f.rect(w,S,T,y)}f.closePath(),f.fill(),n?.strokeStyle&&f.stroke(),f.restore()},[e,s,t,n,o,i,r]),null),Ne=({data:e,xScaleId:s,yScaleId:t,style:n})=>(F(({getCtx:o,clampXPosToChartArea:i,clampYPosToChartArea:r,valToPos:u})=>{const d=[];for(const a of e){const m=i(u(a.x,s)),f=r(u(a.y[0],t)),h=r(u(a.y[1],t));d.push({x:m,y:f}),d.unshift({x:m,y:h})}const c=o();if(d.length>0){c.save(),c.beginPath(),A(c,n),c.moveTo(d[0].x,d[0].y);for(const a of d)c.lineTo(a.x,a.y);c.closePath(),c.fill(),c.restore()}},[e,s,t,n]),null),$e=({data:e,stroked:s,xScaleId:t,yScaleId:n,style:o})=>(F(({getCtx:i,clampXPosToChartArea:r,clampYPosToChartArea:u,valToPos:d})=>{const c=[],a=i();for(const l of e){const p=r(d(l.x,t)),x=u(d(l.y,n));c.push({x:p,y:x})}const m=c.at(0),f=c.at(-1);if(!m||!f)return;const h=u(d(0,n));a.save(),a.beginPath(),A(a,o),a.moveTo(m.x,h);for(const l of c)a.lineTo(l.x,l.y);if(a.lineTo(f.x,h),a.closePath(),a.fill(),s){a.beginPath(),a.moveTo(m.x,m.y);for(const l of c)a.lineTo(l.x,l.y);a.stroke()}a.restore()},[e,s,t,n,o]),null),Ve=(e,s)=>te(({clampXPosToChartArea:t,clampYPosToChartArea:n,getScale:o,valToPos:i,valFits:r})=>{const u={};for(const d in e){const c=e[d];switch(c.exceeding){case"discard":{if(r(c.value,c.scaleId)){const a=i(c.value,c.scaleId,s);u[d]=a}break}case"clamp":{const a=i(c.value,c.scaleId,s);u[d]=o(c.scaleId)?.origin==="x"?t(a,s):n(a,s);break}}}return u}),He=({scaleId:e,tickStyle:s,labelStyle:t,labelGap:n,tickSize:o,ticks:i})=>(F(({getCtx:r,valToPos:u,getScale:d,getFrame:c})=>{const a=r(),m=d(e);if(!m||!m.axis||m.origin!=="x")return;const f=m.axis,h=f.position==="top"?f.canvasRect.y+f.canvasRect.height:f.canvasRect.y,l=window.devicePixelRatio||1,p=h,x=(o??6)*l,g=f.position==="top"?h-x:h+x,S=(n??12)*l;a.save(),a.fontKerning="auto",A(a,{...s}),a.beginPath();const y=Array.isArray(i)?i:i({...m,axis:f},c());for(const{value:w}of y){const T=u(w,e,"canvas");a.moveTo(T,p),a.lineTo(T,g)}a.stroke(),a.restore(),a.save(),A(a,{textBaseline:f.position==="top"?"bottom":"top",textAlign:"center",...s,...t});for(const{value:w,label:T}of y){const C=u(w,e,"canvas"),b=T.split(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),v=require("react"),Q=require("zustand"),O=(e,s,t)=>Math.min(Math.max(e,s),t),ke=e=>e.reduce((s,t)=>s+(t??0),0),Me=(e,s)=>{let t=0;for(let n=0;n<e.length;n++)Math.abs(e[n]-s)<Math.abs(e[t]-s)&&(t=n);return t},ve=(e,s,t,n)=>{const{min:o,max:i,origin:r}=D(e,t),u=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,d=(r==="x"?u.width:u.height)/(i-o);return s/d},D=(e,s)=>{const t=e.scales.find(n=>n.id===s);if(!t)throw new Error(`Scale ${s} not found`);return t},A=(e,s)=>{const t=window.devicePixelRatio||1;e.lineCap=s?.lineCap??"butt",e.lineDashOffset=t*(s?.lineDashOffset??0),e.lineJoin=s?.lineJoin??"miter",e.lineWidth=t*(s?.lineWidth??1),e.miterLimit=t*(s?.miterLimit??10),e.strokeStyle=s?.strokeStyle??"black",e.fillStyle=s?.fillStyle??e.strokeStyle,e.font=s?.font??`${10*t}px sans-serif`,e.textAlign=s?.textAlign??"start",e.direction=s?.direction??"inherit",e.textBaseline=s?.textBaseline??"alphabetic",e.fontKerning=s?.fontKerning??"auto"},ee=(e,s,t,n)=>{const o=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,{min:i,max:r,origin:u}=D(e,t),d=(u==="x"?o.width:o.height)/(r-i);return s*d},B=(e,s,t,n)=>{const{min:o,origin:i}=D(e,t),r=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,u=ee(e,s-o,t,n);return i==="x"?O(r.x+u,r.x-10*r.width,r.x+11*r.width):O(r.y+r.height-u,r.y-10*r.height,r.y+11*r.height)},Re=(e,s,t)=>{const{min:n,max:o}=D(e,t);return O(s,n,o)},Y=(e,s,t)=>{const n=t==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS;return O(s,n.x,n.x+n.width)},j=(e,s,t)=>{const n=t==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS;return O(s,n.y,n.y+n.height)},Z=(e,s,t)=>{const{min:n,max:o}=D(e,t);return s>=n&&s<=o},U=(e,s,t,n)=>{const{min:o,max:i,origin:r}=D(e,t),u=n==="canvas"?e.chartAreaCanvasPX:e.chartAreaCSS,d=r==="x"?(s-u.x)/u.width:(u.height-s+u.y)/u.height;return o+d*(i-o)},Ae=e=>{const{ctx:s,scales:t}=e;for(const n of t){if(!n.axis)continue;s.save(),A(s,{strokeStyle:"black",fillStyle:"black",lineWidth:1,...n.axis.style});const o=n.axis.canvasRect;if(n.origin==="x"){if(n.axis.position==="bottom")s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(o.x+o.width,o.y),s.stroke();else if(n.axis.position==="top"){const i=o.y+o.height;s.beginPath(),s.moveTo(o.x,i),s.lineTo(o.x+o.width,i),s.stroke()}}else if(n.axis.position==="left"){const i=o.x+o.width;s.beginPath(),s.moveTo(i,o.y),s.lineTo(i,o.y+o.height),s.stroke()}else n.axis.position==="right"&&(s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(o.x,o.y+o.height),s.stroke());s.restore()}},Ie=()=>Q.createStore((e,s)=>{const t=()=>{const n=s()._frame;if(!n)throw new Error("No frame set in frame store");return n};return{_frame:null,getFrame:t,getCtx:()=>t().ctx,clampXPosToChartArea:(n,o)=>Y(t(),n,o??"canvas"),clampYPosToChartArea:(n,o)=>j(t(),n,o??"canvas"),valToPos:(n,o,i)=>B(t(),n,o,i??"canvas"),valToPxDistance:(n,o,i)=>ee(t(),n,o,i??"canvas"),valFits:(n,o)=>Z(t(),n,o),getScale:n=>D(t(),n)}}),Le=()=>Q.createStore(e=>({notify:()=>{e(s=>({version:s.version+1}))},version:0})),ue=v.createContext(null),ge=v.createContext(null),F=(e,s)=>{const t=v.useContext(ue),n=v.useContext(ge);if(!t||!n)throw new Error("useFrame must be used within a CanPlot component");const o=v.useRef(e);o.current=e,v.useLayoutEffect(()=>(o.current(t.getState()),t.subscribe(i=>{i._frame&&o.current(i)})),[t]),v.useEffect(()=>{n.getState().notify()},[n,...s])},te=e=>{const s=v.useContext(ue);if(!s)throw new Error("useFrame must be used within a CanPlot component");return Q.useStore(s,e??(t=>t.getFrame()))};function Ue(e){return s=>{for(const t of e)le(t,s)}}function De(e){return s=>{const t=[];for(const n of e){const o=le(n,s),i=typeof o=="function";t.push(i?o:()=>le(n,null))}return()=>{for(const n of t)n()}}}function le(e,s){if(typeof e=="function")return e(s);e&&(e.current=s)}var _e=parseInt(v.version.split(".")[0],10)>=19?De:Ue;const Xe=v.forwardRef(({configuration:e,children:s,style:t,className:n},o)=>{const i=v.useRef(null),r=v.useRef(null),u=Ke(r),d=v.useMemo(Ie,[]),c=v.useMemo(Le,[]);v.useLayoutEffect(()=>{d.setState({_frame:ze(e,u,i.current)})},[e,u,i,d]),v.useLayoutEffect(()=>d.subscribe(m=>{m._frame&&Ye(m._frame)}),[d]),v.useLayoutEffect(()=>{let m=!1;return c.subscribe(()=>{m||(m=!0,window.requestAnimationFrame(()=>{m=!1,d.setState(f=>({_frame:f._frame?{...f._frame}:null}))}))})},[c,d]);const a=window.devicePixelRatio||1;return k.jsxs("div",{ref:_e([o,r]),className:n,style:{position:"relative",overflow:"hidden",...t},"data-canplotroot":!0,children:[k.jsx("canvas",{ref:i,width:u.width*a,height:u.height*a,style:{inset:0,position:"absolute",width:`${u.width}px`,height:`${u.height}px`}}),k.jsx(Fe,{frameStore:d,updateRequestStore:c,children:s})]})}),Fe=({frameStore:e,updateRequestStore:s,children:t})=>Q.useStore(e,o=>!!o._frame)?k.jsx(ge.Provider,{value:s,children:k.jsx(ue.Provider,{value:e,children:t})}):null,Ke=e=>{const[s,t]=v.useState({width:0,height:0}),[n]=v.useState(()=>new ResizeObserver(o=>{for(const i of o){const r=Math.round(i.contentRect.width),u=Math.round(i.contentRect.height);t(d=>d.width!==r||d.height!==u?{...d,width:r,height:u}:d)}}));return v.useLayoutEffect(()=>{if(!e.current)return;const o=e.current.clientWidth,i=e.current.clientHeight;return t(r=>r.width!==o||r.height!==i?{...r,width:o,height:i}:r),n.observe(e.current,{box:"border-box"}),()=>n.disconnect()},[n,e]),s},ze=(e,s,t)=>{const n=t?.getContext("2d");if(!n)return null;const o=window.devicePixelRatio||1;if(s.width===0||s.height===0)return null;const i={x:e.padding.left,y:e.padding.top,width:s.width-e.padding.left-e.padding.right,height:s.height-e.padding.top-e.padding.bottom};for(const h of e.scales)h.axis&&(h.origin==="x"?(h.axis.position==="bottom"||h.axis.position==="top")&&(i.height=Math.max(0,i.height-h.axis.size),h.axis.position==="top"&&(i.y+=h.axis.size)):(h.axis.position==="left"||h.axis.position==="right")&&(i.width=Math.max(0,i.width-h.axis.size),h.axis.position==="left"&&(i.x+=h.axis.size)));const r={x:i.x*o,y:i.y*o,width:i.width*o,height:i.height*o},u=[];let d=e.padding.left*o,c=n.canvas.width-e.padding.right*o,a=n.canvas.height-e.padding.bottom*o,m=e.padding.top*o;for(const h of e.scales){if(!h.axis){u.push({...h,axis:null});continue}let l;if(h.origin==="x")switch(h.axis.position){case"bottom":a-=h.axis.size*o,l={x:i.x,y:a/o,width:i.width,height:h.axis.size};break;case"top":m+=h.axis.size*o,l={x:i.x,y:m/o-h.axis.size,width:i.width,height:h.axis.size};break;case"left":case"right":throw new Error("Invalid axis position for x origin")}else switch(h.axis.position){case"left":d+=h.axis.size*o,l={x:d/o-h.axis.size,y:i.y,width:h.axis.size,height:i.height};break;case"right":c-=h.axis.size*o,l={x:c/o,y:i.y,width:h.axis.size,height:i.height};break;case"top":case"bottom":throw new Error("Invalid axis position for y origin")}const p={x:l.x*o,y:l.y*o,width:l.width*o,height:l.height*o};u.push({...h,axis:{...h.axis,cssRect:l,canvasRect:p}})}return{ctx:n,dpr:o,padding:e.padding,scales:u,chartAreaCSS:i,chartAreaCanvasPX:r}},Ye=e=>{e.ctx.clearRect(0,0,e.ctx.canvas.width,e.ctx.canvas.height),Ae(e)},je=({data:e,xScaleId:s,yScaleId:t,style:n})=>(F(({getCtx:o,clampXPosToChartArea:i,clampYPosToChartArea:r,valToPos:u})=>{const d=o();d.save(),d.beginPath(),A(d,n);for(const c of e){const a=i(u(c.x,s)),m=r(u(c.y,t));d.lineTo(a,m)}d.stroke(),d.restore()},[e,s,t,n]),null),Oe=({data:e,xScaleId:s,yScaleId:t,radius:n=5,style:o})=>(F(({getCtx:i,valToPos:r,valFits:u})=>{const d=i();d.save(),d.beginPath(),A(d,o);for(const c of e){if(!u(c.x,s)||!u(c.y,t))continue;const a=r(c.x,s),m=r(c.y,t);d.moveTo(a+n,m),d.arc(a,m,n,0,Math.PI*2)}d.stroke(),d.fill(),d.restore()},[e,s,t,n,o]),null),Be=({data:e,xScaleId:s,yScaleId:t,style:n,barWidth:o,xPositionOffset:i,radius:r})=>(F(({getCtx:u,valToPxDistance:d,valToPos:c,clampXPosToChartArea:a,clampYPosToChartArea:m})=>{if(e.length===0)return;const f=u();f.save(),A(f,n);const h=d(o,s);f.beginPath();for(const l of e){const x=c(l.x,s)-h/2+i*h,g=m(c(0,t)),S=m(c(l.y,t)),y=g-S,w=a(x),T=a(x+h)-w;r?f.roundRect(w,S,T,y,r):f.rect(w,S,T,y)}f.closePath(),f.fill(),n?.strokeStyle&&f.stroke(),f.restore()},[e,s,t,n,o,i,r]),null),Ne=({data:e,xScaleId:s,yScaleId:t,style:n})=>(F(({getCtx:o,clampXPosToChartArea:i,clampYPosToChartArea:r,valToPos:u})=>{const d=[];for(const a of e){const m=i(u(a.x,s)),f=r(u(a.y[0],t)),h=r(u(a.y[1],t));d.push({x:m,y:f}),d.unshift({x:m,y:h})}const c=o();if(d.length>0){c.save(),c.beginPath(),A(c,n),c.moveTo(d[0].x,d[0].y);for(const a of d)c.lineTo(a.x,a.y);c.closePath(),c.fill(),c.restore()}},[e,s,t,n]),null),$e=({data:e,stroked:s,xScaleId:t,yScaleId:n,style:o})=>(F(({getCtx:i,clampXPosToChartArea:r,clampYPosToChartArea:u,valToPos:d})=>{const c=[],a=i();for(const l of e){const p=r(d(l.x,t)),x=u(d(l.y,n));c.push({x:p,y:x})}const m=c.at(0),f=c.at(-1);if(!m||!f)return;const h=u(d(0,n));a.save(),a.beginPath(),A(a,o),a.moveTo(m.x,h);for(const l of c)a.lineTo(l.x,l.y);if(a.lineTo(f.x,h),a.closePath(),a.fill(),s){a.beginPath(),a.moveTo(m.x,m.y);for(const l of c)a.lineTo(l.x,l.y);a.stroke()}a.restore()},[e,s,t,n,o]),null),Ve=(e,s)=>te(({clampXPosToChartArea:t,clampYPosToChartArea:n,getScale:o,valToPos:i,valFits:r})=>{const u={};for(const d in e){const c=e[d];switch(c.exceeding){case"discard":{if(r(c.value,c.scaleId)){const a=i(c.value,c.scaleId,s);u[d]=a}break}case"clamp":{const a=i(c.value,c.scaleId,s);u[d]=o(c.scaleId)?.origin==="x"?t(a,s):n(a,s);break}}}return u}),He=({scaleId:e,tickStyle:s,labelStyle:t,labelGap:n,tickSize:o,ticks:i})=>(F(({getCtx:r,valToPos:u,getScale:d,getFrame:c})=>{const a=r(),m=d(e);if(!m||!m.axis||m.origin!=="x")return;const f=m.axis,h=f.position==="top"?f.canvasRect.y+f.canvasRect.height:f.canvasRect.y,l=window.devicePixelRatio||1,p=h,x=(o??6)*l,g=f.position==="top"?h-x:h+x,S=(n??12)*l;a.save(),a.fontKerning="auto",A(a,{...s}),a.beginPath();const y=Array.isArray(i)?i:i({...m,axis:f},c());for(const{value:w}of y){const T=u(w,e,"canvas");a.moveTo(T,p),a.lineTo(T,g)}a.stroke(),a.restore(),a.save(),A(a,{textBaseline:f.position==="top"?"bottom":"top",textAlign:"center",...s,...t});for(const{value:w,label:T}of y){const C=u(w,e,"canvas"),b=T.split(`
|
|
2
2
|
`);for(let E=0;E<b.length;E++)a.fillText(b[E],C,g+l*2+E*S)}a.restore()},[i,e,s,t]),null),qe=({scaleId:e,tickStyle:s,labelStyle:t,labelGap:n,tickSize:o,ticks:i})=>(F(({getCtx:r,valToPos:u,getScale:d,getFrame:c})=>{const a=r(),m=d(e);if(!m||!m.axis||m.origin!=="y")return;const f=m.axis,h=f.position==="left"?f.canvasRect.x+f.canvasRect.width:f.canvasRect.x,l=h,p=o??6,x=f.position==="left"?h-p:h+p,g=n??12,S=Array.isArray(i)?i:i({...m,axis:f},c());a.save(),a.fontKerning="auto",A(a,{...s}),a.beginPath();for(const{value:y}of S){const w=u(y,e,"canvas");a.moveTo(l,w),a.lineTo(x,w)}a.stroke(),a.restore(),a.save(),A(a,{textBaseline:"middle",textAlign:f.position==="left"?"right":"left",...s,...t});for(const{value:y,label:w}of S){const T=u(y,e,"canvas"),C=w.split(`
|
|
3
3
|
`);for(let b=0;b<C.length;b++)a.fillText(` ${C[b]} `,x,T+b*g)}a.restore()},[i,e,s,t]),null),I=()=>{const e=[];return{addEventListener:(s,t)=>(e.push({syncKey:s,callback:t}),()=>{const n=e.findIndex(o=>o.callback===t);n!==-1&&e.splice(n,1)}),dispatchEvent:(s,t)=>{for(const n of e)n.syncKey===s&&n.callback(s,t)}}},P={dblclick:I(),click:I(),contextmenu:I(),move:I(),mousedown:I(),mouseup:I(),spanselect:I(),documentmouseup:I(),pressandwheel:I(),sync_move:I()},L=(e,s,t)=>{const n=v.useRef(t);n.current=t,v.useEffect(()=>P[e].addEventListener(s,(i,r)=>{n.current(r,i)}),[s,e,n])},de=v.createContext(""),se=(e,s)=>{const t=v.useContext(de);return L(e,t,s)},We=(e,s,t,n,o)=>{if(!s)return;const i=n??t.scales.find(m=>m.origin==="x")?.id,r=o??t.scales.find(m=>m.origin==="y")?.id;if(!i||!r)return;const u=e.clientX-s.left,d={scaleId:i,value:U(t,u,i,"css")},c=e.clientY-s.top,a={scaleId:r,value:U(t,c,r,"css")};return{pointerSyncPosition:{x:d,y:a},cssX:u,cssY:c}},z=(e,s)=>{const{x:t,y:n}=e,o=t&&s.scales.some(r=>r.id===t.scaleId)?B(s,t.value,t.scaleId,"css"):null,i=n&&s.scales.some(r=>r.id===n.scaleId)?B(s,n.value,n.scaleId,"css"):null;return{cssX:o,cssY:i,scaled:Object.fromEntries(s.scales.flatMap(r=>{const u=r.origin==="y"?i:o;return u===null?[]:[[r.id,U(s,u,r.id,"css")]]}))}},xe=(e,s,t)=>{const n=B(t,s.from,s.scaleId,"css"),o=B(t,s.to,s.scaleId,"css"),i=t.scales.flatMap(r=>{if(r.origin!==e)return[];const u=U(t,n,r.id,"css"),d=U(t,o,r.id,"css");return[{scaleId:r.id,from:u,to:d}]});return{fromCSS:n,toCSS:o,scaled:i}},Ge=({id:e,onClick:s,onDblClick:t,onMouseMove:n,onMouseDown:o,onMouseUp:i,onDocumentMouseUp:r,onSpanSelect:u,onContextMenu:d,className:c,style:a,sync:m,children:f})=>{const h=v.useId(),l=e||h;return L("dblclick",l,p=>{t?.(p)}),L("click",l,p=>{s?.(p)}),L("move",l,p=>{n?.(p)}),L("mousedown",l,p=>{o?.(p)}),L("mouseup",l,p=>{i?.(p)}),L("documentmouseup",l,p=>{r?.(p)}),L("spanselect",l,p=>{u?.(p)}),L("contextmenu",l,p=>{d?.(p)}),k.jsxs(de.Provider,{value:l,children:[k.jsx(Ze,{className:c,style:a,sync:m}),f]})},Ze=({className:e,style:s,sync:t})=>{const n=v.useRef(null),o=te(),i=v.useRef(o);i.current=o;const r=v.useContext(de),u=t?.key||r,d=v.useRef(null),c=v.useRef(null),a=v.useRef(null),m=()=>{const l=n.current?.parentElement;if(l){if(l.dataset.canplotroot===void 0)throw new Error("ChartAreaInteractions must be used within a CanPlot component");return l.getBoundingClientRect()}},f=(l,p)=>{const x=We(l,m(),i.current,t?.xViaScaleId,t?.yViaScaleId);x&&p(x.pointerSyncPosition,{cssX:x.cssX,cssY:x.cssY},{ctrlKey:l.ctrlKey,altKey:l.altKey,shiftKey:l.shiftKey,metaKey:l.metaKey})},h=v.useRef(f);return h.current=f,v.useEffect(()=>{const l=y=>{const w=c.current;w&&P.spanselect.dispatchEvent(r,{...w,completed:!0}),P.documentmouseup.dispatchEvent(r,{frame:i.current,keys:{ctrlKey:y.ctrlKey,altKey:y.altKey,shiftKey:y.shiftKey,metaKey:y.metaKey}})},p=y=>{const w={ctrlKey:y.ctrlKey,altKey:y.altKey,shiftKey:y.shiftKey,metaKey:y.metaKey},T=a.current;if(T&&Object.entries(w).some(([b,E])=>T.keys[b]!==E)){const b={...T,keys:w};a.current=b,P.sync_move.dispatchEvent(u,b)}const C=c.current;if(C&&Object.entries(w).some(([b,E])=>C.keys[b]!==E)){y.stopPropagation(),y.preventDefault();const b={...C,keys:w};c.current=b,P.spanselect.dispatchEvent(r,b)}},x=y=>{h.current(y,(w,{cssX:T,cssY:C},b)=>{const E=d.current;if(!E||!w.x||!w.y)return;const M=i.current,R=E.xRangeCss.start,N=T,K=E.yRangeCss.start,oe=C,ie=D(M,w.x.scaleId),re=D(M,w.y.scaleId);d.current={xRangeCss:{start:R,end:N},yRangeCss:{start:K,end:oe}};let $="below_threshold";const ce=Math.abs(K-oe),ae=Math.abs(R-N);ce<10&&ae<10?$="below_threshold":ce>30&&ae>30?$="box":ce>ae?$="y":$="x";const fe={scaleId:ie.id,from:U(M,Y(i.current,R,"css"),ie.id,"css"),to:U(M,Y(i.current,N,"css"),ie.id,"css")},me={scaleId:re.id,from:U(M,j(i.current,K,"css"),re.id,"css"),to:U(M,j(i.current,oe,"css"),re.id,"css")},V=fe&&xe("x",fe,i.current),H=me&&xe("y",me,i.current),Pe=V?.scaled,Ee=H?.scaled,pe={mode:$,frame:i.current,completed:!1,x:{css:V&&{from:V.fromCSS,to:V.toCSS},scaled:Pe??[]},y:{css:H&&{from:H.fromCSS,to:H.toCSS},scaled:Ee??[]},keys:b};c.current=pe,P.spanselect.dispatchEvent(r,pe)})},g=y=>{h.current(y,(w,T,C)=>{const b=z(w,i.current);if(!b)return;if(Object.values(C).some(M=>M)){y.preventDefault();const M=Math.abs(y.deltaY)>Math.abs(y.deltaX)?y.deltaY:y.deltaX;P.pressandwheel.dispatchEvent(r,{pointer:b,frame:i.current,keys:C,deltaX:y.deltaX,deltaY:y.deltaY,deltaAbs:M})}})};document.addEventListener("mouseup",l),document.addEventListener("keydown",p),document.addEventListener("keyup",p),document.addEventListener("mousemove",x);const S=n.current;return S?.addEventListener("wheel",g,{passive:!1}),()=>{document.removeEventListener("mouseup",l),document.removeEventListener("keydown",p),document.removeEventListener("keyup",p),document.removeEventListener("mousemove",x),S?.removeEventListener("wheel",g)}},[i,r,u,h]),L("sync_move",u,l=>{const p=l.positions?z(l.positions,i.current):null;a.current=l,P.move.dispatchEvent(r,{frame:i.current,pointer:p??null,keys:l.keys})}),k.jsx("div",{ref:n,id:"interactions",className:e,style:{position:"absolute",left:o.chartAreaCSS.x,top:o.chartAreaCSS.y,width:o.chartAreaCSS.width,height:o.chartAreaCSS.height,zIndex:25,...s},onDragStart:l=>{l.preventDefault()},onClick:l=>{f(l,(p,x,g)=>{const S=z(p,i.current);S&&P.click.dispatchEvent(r,{pointer:S,frame:i.current,keys:g})})},onMouseLeave:l=>{f(l,(p,x,g)=>{P.sync_move.dispatchEvent(u,{positions:null,keys:g})})},onMouseMove:l=>{f(l,(p,x,g)=>{P.sync_move.dispatchEvent(u,{positions:p,keys:g})})},onMouseDown:l=>{f(l,(p,{cssX:x,cssY:g},S)=>{const y=z(p,i.current);y&&(P.mousedown.dispatchEvent(r,{pointer:y,frame:i.current,keys:S}),d.current={xRangeCss:{start:x,end:x},yRangeCss:{start:g,end:g}})})},onMouseUp:l=>{f(l,(p,x,g)=>{const S=z(p,i.current);if(!S)return;P.mouseup.dispatchEvent(r,{frame:i.current,pointer:S,keys:g});const y=c.current;c.current=null;const w=d.current;if(d.current=null,w&&y){const T={...y,keys:g,completed:!0};c.current=null,P.spanselect.dispatchEvent(r,T)}})},onContextMenu:l=>{l.preventDefault(),f(l,(p,x,g)=>{const S=z(p,i.current);S&&P.contextmenu.dispatchEvent(r,{frame:i.current,pointer:S,keys:g})})},onDoubleClick:l=>{f(l,(p,x,g)=>{const S=z(p,i.current);S&&P.dblclick.dispatchEvent(r,{frame:i.current,pointer:S,keys:g})})}})},Je=({data:e,renderTooltip:s,xScaleId:t})=>{const[n,o]=v.useState(null);se("move",r=>{o(r)});const i=v.useMemo(()=>{if(!n)return null;const{frame:r,pointer:u}=n,d=u?.scaled[t];if(d===void 0)return null;const c=[];let a=d;for(const m of e){let f=null,h=1/0;for(const[p,x]of m.points.entries()){if(!Z(r,x.x,t)||!Z(r,x.y,m.yScaleId))continue;const g=Math.abs(x.x-d);g<h&&(h=g,f=p)}const l=m.points[f??-1];if(!l||ee(r,h,t,"css")>30){c.push({seriesId:m.seriesId,y:null});continue}a=l.x,c.push({seriesId:m.seriesId,y:l.y})}return{frame:r,x:a,points:c}},[e,n,t]);return s(i)},Qe=({makeXStyle:e,makeXClassName:s,makeYStyle:t,makeYClassName:n})=>{const[o,i]=v.useState(null);if(se("move",f=>{i(f)}),!o)return null;const{frame:r,pointer:u}=o,d=u?.cssX??null,c=u?.cssY??null,a=d?Y(r,d,"css"):0,m=c?j(r,c,"css"):0;return k.jsxs(k.Fragment,{children:[k.jsx("div",{"data-show":!!u,className:s?.(o),style:{position:"absolute",left:0,visibility:d===null?"hidden":"visible",top:r.chartAreaCSS.y,height:r.chartAreaCSS.height,borderColor:"red",borderLeftWidth:"1px",borderLeftStyle:"solid",pointerEvents:"none",opacity:u?1:0,transform:`translateX(${a}px)`,...e?.(o)}}),k.jsx("div",{className:n?.(o),"data-show":!!u,style:{position:"absolute",visibility:c===null?"hidden":"visible",top:0,height:0,borderTop:"solid 1px red",left:r.chartAreaCSS.x,width:r.chartAreaCSS.width,pointerEvents:"none",opacity:u?1:0,transform:`translateY(${m}px)`,...t?.(o)}})]})},et=({makeClassName:e,makeStyle:s})=>{const[t,n]=v.useState(null);se("spanselect",i=>{n(i.mode==="below_threshold"||i.completed?null:i)});const o=v.useMemo(()=>{if(!t||t.mode==="below_threshold")return null;const i=t.mode==="y"?-1/0:t.x.css?.from??-1/0,r=t.mode==="y"?1/0:t.x.css?.to??1/0,u=t.mode==="x"?-1/0:t.y.css?.from??-1/0,d=t.mode==="x"?1/0:t.y.css?.to??1/0,c=Y(t.frame,i,"css"),a=Y(t.frame,r,"css"),m=j(t.frame,u,"css"),f=j(t.frame,d,"css"),h=Math.min(c,a),l=Math.min(m,f),p=Math.abs(a-c),x=Math.abs(f-m);return{leftPx:h,topPx:l,widthPx:p,heightPx:x}},[t]);return k.jsx("div",{className:t?e?.(t):void 0,style:{position:"absolute",visibility:t?"visible":"hidden",left:`${o?.leftPx??0}px`,top:`${o?.topPx??0}px`,width:`${o?.widthPx??0}px`,height:`${o?.heightPx??0}px`,pointerEvents:"none",...t?s?.(t):void 0}})},tt=({style:e,children:s,scaleId:t,...n})=>{const o=te(i=>i.getScale(t)?.axis);return o?k.jsx("div",{style:{position:"absolute",backgroundColor:"#0000ff11",left:o.cssRect.x,top:o.cssRect.y,height:o.cssRect.height,width:o.cssRect.width,...e},...n,children:s}):null},Se=60,st=30,we="UTC",nt="en-GB",ot=({space:e,formatter:s,acceptableIncrements:t}={})=>(n,o)=>{const{min:i,max:r}=n,u=[],d=window.devicePixelRatio||1,c=(e??(n.origin==="x"?Se:st))*d,a=ve(o,c,n.id,"canvas"),m=t??q,f=m.find(l=>l>a)??m.at(-1)??1;let h=i;if(Math.abs(h%f)>Number.EPSILON){const l=(f-h%f)%f;h+=l}for(;h<=r&&u.length<1e3;)u.push(h),h+=f;return(s??be)(u)},be=e=>{const s=Math.max(0,Math.ceil(-Math.log10(e[1]-e[0])));return e.map(t=>({value:t,label:t.toFixed(s)}))},q=[];for(let e=-12;e<=12;e++)q.push(1*10**e),q.push(2*10**e),q.push(5*10**e);const it=1,Te=1e3*it,he=60*Te,J=60*he,ne=24*J,rt=30*ne,ct=365*ne,at=[[1,"milliseconds"],[2,"milliseconds"],[5,"milliseconds"],[10,"milliseconds"],[20,"milliseconds"],[50,"milliseconds"],[100,"milliseconds"],[200,"milliseconds"],[500,"milliseconds"],[1,"seconds"],[5,"seconds"],[10,"seconds"],[15,"seconds"],[30,"seconds"],[1,"minutes"],[5,"minutes"],[10,"minutes"],[15,"minutes"],[30,"minutes"],[1,"hours"],[2,"hours"],[3,"hours"],[4,"hours"],[6,"hours"],[8,"hours"],[12,"hours"],[1,"days"],[3,"days"],[5,"days"],[7,"days"],[10,"days"],[15,"days"],[1,"months"],[2,"months"],[3,"months"],[4,"months"],[6,"months"],[1,"years"],[2,"years"],[5,"years"],[10,"years"],[25,"years"],[50,"years"],[100,"years"]],W=e=>{const[s,t]=e;switch(t){case"milliseconds":return s;case"seconds":return s*Te;case"minutes":return s*he;case"hours":return s*J;case"days":return s*ne;case"months":return s*rt;case"years":return s*ct}},lt=(e,s)=>{const t=new Date(e);return t.setUTCMilliseconds(t.getUTCMilliseconds()+s),t.getTime()},ut=(e,s)=>{const t=new Date(e);return t.setUTCSeconds(t.getUTCSeconds()+s),t.getTime()},dt=(e,s)=>{const t=new Date(e);return t.setUTCMinutes(t.getUTCMinutes()+s),t.getTime()},ht=(e,s)=>{const t=new Date(e);return t.setUTCHours(t.getUTCHours()+s),t.getTime()},ft=(e,s)=>{const t=new Date(e);return t.setUTCDate(t.getUTCDate()+s),t.getTime()},ye=(e,s)=>{const t=new Date(e);return t.setUTCMonth(t.getUTCMonth()+s),t.getTime()},X=(e,s)=>{const[t,n]=s;switch(n){case"milliseconds":return lt(e,t);case"seconds":return ut(e,t);case"minutes":return dt(e,t);case"hours":return ht(e,t);case"days":return ft(e,t);case"months":return ye(e,t);case"years":return ye(e,t*12)}};function G(e,s){const t=new Date(e),n=new Date(t.toLocaleString("en-US",{timeZone:s})),o=new Date(t.toLocaleString("en-US",{timeZone:"UTC"}));return(n.getTime()-o.getTime())/(3600*1e3)}const mt=(e,s,t="UTC")=>{const[n,o]=s;let i=new Date(e);const r=()=>{i.setUTCHours(-G(i,t),0,0,0)};switch(o){case"milliseconds":i.setUTCMilliseconds(Math.ceil(i.getUTCMilliseconds()/n)*n);break;case"seconds":i.setUTCSeconds(Math.ceil(i.getUTCSeconds()/n)*n,0);break;case"minutes":i.setUTCMinutes(Math.ceil(i.getTime()%J/he/n)*n,0,0);break;case"hours":i.setUTCHours(Math.ceil(i.getTime()%ne/J/n)*n,0,0,0);break;case"days":case"months":case"years":o==="months"?i.setUTCDate(1):o==="years"&&i.setUTCMonth(0,1),r(),i.getTime()<e&&(i=new Date(X(i,[1,o])));break}return i.getTime()},pt=({timeZone:e=we,space:s=Se,formatter:t,locale:n,showTimezone:o}={})=>(i,r)=>{const{min:u,max:d}=i,c=Math.floor(r.chartAreaCanvasPX.width/s)+1,m=(d-u)/c,[f,h]=at.find(S=>W(S)>=m)??[1,"milliseconds"],l=mt(u,[f,h],e),p=G(l,e),x=[l];let g;for(;;){switch(h){case"milliseconds":case"seconds":case"minutes":case"hours":{g=X(l,[x.length*f,h]);break}case"days":{const S=X(l,[x.length*f,h]);g=X(S,[p-G(S,e),"hours"]);break}case"months":case"years":{const S=X(X(X(l,[p,"hours"]),[x.length*f,h]),[-p,"hours"]);g=X(S,[p-G(S,e),"hours"]);break}}if(g>d)break;x.push(g)}return(t??Ce({locale:n,showTimezone:o,timeZone:e}))(x)},_=(e,s,t)=>e.find(n=>n.type===t)?.value!==s.find(n=>n.type===t)?.value,Ce=({timeZone:e=we,locale:s=nt,showTimezone:t=!0})=>{const n=new Intl.DateTimeFormat(s,{year:"numeric",day:"numeric",month:"short",hour:"numeric",hourCycle:"h23",minute:"numeric",second:"numeric",fractionalSecondDigits:3,timeZoneName:"short",timeZone:e});return o=>{const i=o[1]-o[0],r=i<W([1,"days"]),u=i<W([1,"minutes"]),d=i<W([1,"seconds"]);return o.map(c=>({value:c,label:n.formatToParts(new Date(c))})).map((c,a,m)=>{const f=m[a-1],h=a===0||_(c.label,f.label,"year"),l=a===0||_(c.label,f.label,"day"),p=a===0||_(c.label,f.label,"month"),x=a===0||_(c.label,f.label,"hour"),g=a===0||_(c.label,f.label,"timeZoneName"),S=a===0||_(c.label,f.label,"minute"),y=a===0||_(c.label,f.label,"second"),w=a===0||_(c.label,f.label,"fractionalSecond"),T=[];if(r&&(x||S||g||y||w)){const C=c.label.find(R=>R.type==="hour")?.value,b=c.label.find(R=>R.type==="minute")?.value,E=c.label.find(R=>R.type==="timeZoneName")?.value;let M="";if(u){const R=c.label.find(K=>K.type==="second")?.value,N=c.label.find(K=>K.type==="fractionalSecond")?.value;M=`:${R}`+(d?`.${N}`:"")}T.push(`${C}:${b}${M}`+(t&&g?` ${E}`:""))}return(l||p)&&T.push([c.label.find(C=>C.type==="month")?.value,l&&c.label.find(C=>C.type==="day")?.value].filter(Boolean).join(" ")),h&&T.push(c.label.find(C=>C.type==="year")?.value),{value:c.value,label:T.filter(C=>C).join(`
|
|
4
4
|
`)}})}};exports.AreaPlot=Ne;exports.AxisOverlay=tt;exports.BarPlot=Be;exports.CanPlot=Xe;exports.ChartAreaInteractions=Ge;exports.Crosshair=Qe;exports.LinePlot=je;exports.ScatterPlot=Oe;exports.SelectBox=et;exports.SparklinePlot=$e;exports.TooltipsX=Je;exports.XTicks=He;exports.YTicks=qe;exports.applyStyles=A;exports.clamp=O;exports.clampUnfit=Re;exports.clampXPosToChartArea=Y;exports.clampYPosToChartArea=j;exports.defaultNumericalTicksFormatter=be;exports.findClosestIndex=Me;exports.getScale=D;exports.makeLinearTicks=ot;exports.makeTimeTickFormat=Ce;exports.makeTimeTicks=pt;exports.posToVal=U;exports.pxToValDistance=ve;exports.sum=ke;exports.useDrawEffect=F;exports.useFrameState=te;exports.useInteractionsEvent=se;exports.useXPositioned=Ve;exports.valFits=Z;exports.valToPos=B;exports.valToPxDistance=ee;
|