@prometa/sleek 0.0.11 → 0.0.13
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/chartjs-chart.cjs
CHANGED
|
@@ -41,4 +41,4 @@
|
|
|
41
41
|
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
|
|
42
42
|
* (c) 2016-2024 chartjs-plugin-zoom Contributors
|
|
43
43
|
* Released under the MIT License
|
|
44
|
-
*/const Jn=n=>n&&n.enabled&&n.modifierKey,_h=(n,t)=>n&&t[n+"Key"],or=(n,t)=>n&&!t[n+"Key"];function Pe(n,t,e){return n===void 0?!0:typeof n=="string"?n.indexOf(t)!==-1:typeof n=="function"?n({chart:e}).indexOf(t)!==-1:!1}function qs(n,t){return typeof n=="function"&&(n=n({chart:t})),typeof n=="string"?{x:n.indexOf("x")!==-1,y:n.indexOf("y")!==-1}:{x:!1,y:!1}}function Lx(n,t){let e;return function(){return clearTimeout(e),e=setTimeout(n,t),t}}function Rx({x:n,y:t},e){const i=e.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)return r}return null}function wh(n,t,e){const{mode:i="xy",scaleMode:s,overScaleMode:o}=n||{},r=Rx(t,e),a=qs(i,e),l=qs(s,e);if(o){const h=qs(o,e);for(const u of["x","y"])h[u]&&(l[u]=a[u],a[u]=!1)}if(r&&l[r.axis])return[r];const c=[];return Y(e.scales,function(h){a[h.axis]&&c.push(h)}),c}const vo=new WeakMap;function nt(n){let t=vo.get(n);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},vo.set(n,t)),t}function Fx(n){vo.delete(n)}function vh(n,t,e,i){const s=Math.max(0,Math.min(1,(n-t)/e||0)),o=1-s;return{min:i*s,max:i*o}}function Mh(n,t){const e=n.isHorizontal()?t.x:t.y;return n.getValueForPixel(e)}function kh(n,t,e){const i=n.max-n.min,s=i*(t-1),o=Mh(n,e);return vh(o,n.min,i,s)}function Nx(n,t,e){const i=Mh(n,e);if(i===void 0)return{min:n.min,max:n.max};const s=Math.log10(n.min),o=Math.log10(n.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=vh(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function zx(n,t){return t&&(t[n.id]||t[n.axis])||{}}function vl(n,t,e,i,s){let o=e[i];if(o==="original"){const r=n.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function Wx(n,t,e){const i=n.getValueForPixel(t),s=n.getValueForPixel(e);return{min:Math.min(i,s),max:Math.max(i,s)}}function Hx(n,{min:t,max:e,minLimit:i,maxLimit:s},o){const r=(n-e+t)/2;t-=r,e+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=n/1e6;return We(t,a,c)&&(t=a),We(e,l,c)&&(e=l),t<i?(t=i,e=Math.min(i+n,s)):e>s&&(e=s,t=Math.max(s-n,i)),{min:t,max:e}}function Ge(n,{min:t,max:e},i,s=!1){const o=nt(n.chart),{options:r}=n,a=zx(n,i),{minRange:l=0}=a,c=vl(o,n,a,"min",-1/0),h=vl(o,n,a,"max",1/0);if(s==="pan"&&(t<c||e>h))return!0;const u=n.max-n.min,d=s?Math.max(e-t,l):u;if(s&&d===l&&u<=l)return!0;const g=Hx(d,{min:t,max:e,minLimit:c,maxLimit:h},o.originalScaleLimits[n.id]);return r.min=g.min,r.max=g.max,o.updatedScaleLimits[n.id]=g,n.parse(g.min)!==n.min||n.parse(g.max)!==n.max}function Yx(n,t,e,i){const s=kh(n,t,e),o={min:n.min+s.min,max:n.max-s.max};return Ge(n,o,i,!0)}function Bx(n,t,e,i){const s=Nx(n,t,e);return Ge(n,s,i,!0)}function Vx(n,t,e,i){Ge(n,Wx(n,t,e),i,!0)}const Ml=n=>n===0||isNaN(n)?0:n<0?Math.min(Math.round(n),-1):Math.max(Math.round(n),1);function jx(n){const e=n.getLabels().length-1;n.min>0&&(n.min-=1),n.max<e&&(n.max+=1)}function Xx(n,t,e,i){const s=kh(n,t,e);n.min===n.max&&t<1&&jx(n);const o={min:n.min+Ml(s.min),max:n.max-Ml(s.max)};return Ge(n,o,i,!0)}function Ux(n){return n.isHorizontal()?n.width:n.height}function qx(n,t,e){const s=n.getLabels().length-1;let{min:o,max:r}=n;const a=Math.max(r-o,1),l=Math.round(Ux(n)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let h;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,h=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,h=o===0),Ge(n,{min:o,max:r},e)||h}const $x={second:500,minute:30*1e3,hour:30*60*1e3,day:12*60*60*1e3,week:3.5*24*60*60*1e3,month:15*24*60*60*1e3,quarter:60*24*60*60*1e3,year:182*24*60*60*1e3};function Ph(n,t,e,i=!1){const{min:s,max:o,options:r}=n,a=r.time&&r.time.round,l=$x[a]||0,c=n.getValueForPixel(n.getPixelForValue(s+l)-t),h=n.getValueForPixel(n.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(h)?!0:Ge(n,{min:c,max:h},e,i?"pan":!1)}function kl(n,t,e){return Ph(n,t,e,!0)}const Mo={category:Xx,default:Yx,logarithmic:Bx},ko={default:Vx},Po={category:qx,default:Ph,logarithmic:kl,timeseries:kl};function Gx(n,t,e){const{id:i,options:{min:s,max:o}}=n;if(!t[i]||!e[i])return!0;const r=e[i];return r.min!==s||r.max!==o}function Pl(n,t){Y(n,(e,i)=>{t[i]||delete n[i]})}function fn(n,t){const{scales:e}=n,{originalScaleLimits:i,updatedScaleLimits:s}=t;return Y(e,function(o){Gx(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),Pl(i,e),Pl(s,e),i}function Tl(n,t,e,i){const s=Mo[n.type]||Mo.default;L(s,[n,t,e,i])}function Sl(n,t,e,i){const s=ko[n.type]||ko.default;L(s,[n,t,e,i])}function Qx(n){const t=n.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function rr(n,t,e="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Qx(n)}=typeof t=="number"?{x:t,y:t}:t,a=nt(n),{options:{limits:l,zoom:c}}=a;fn(n,a);const h=s!==1,u=o!==1,d=wh(c,r,n);Y(d||n.scales,function(g){g.isHorizontal()&&h?Tl(g,s,r,l):!g.isHorizontal()&&u&&Tl(g,o,r,l)}),n.update(e),L(c.onZoom,[{chart:n,trigger:i}])}function Th(n,t,e,i="none",s="api"){const o=nt(n),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;fn(n,o);const c=Pe(l,"x",n),h=Pe(l,"y",n);Y(n.scales,function(u){u.isHorizontal()&&c?Sl(u,t.x,e.x,r):!u.isHorizontal()&&h&&Sl(u,t.y,e.y,r)}),n.update(i),L(a.onZoom,[{chart:n,trigger:s}])}function Zx(n,t,e,i="none",s="api"){var a;const o=nt(n);fn(n,o);const r=n.scales[t];Ge(r,e,void 0,!0),n.update(i),L((a=o.options.zoom)==null?void 0:a.onZoom,[{chart:n,trigger:s}])}function Kx(n,t="default"){const e=nt(n),i=fn(n,e);Y(n.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete e.updatedScaleLimits[s.id]}),n.update(t),L(e.options.zoom.onZoomComplete,[{chart:n}])}function Jx(n,t){const e=n.originalScaleLimits[t];if(!e)return;const{min:i,max:s}=e;return R(s.options,s.scale)-R(i.options,i.scale)}function t_(n){const t=nt(n);let e=1,i=1;return Y(n.scales,function(s){const o=Jx(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;e=Math.min(e,r),i=Math.max(i,r)}}),e<1?e:i}function Dl(n,t,e,i){const{panDelta:s}=i,o=s[n.id]||0;zt(o)===zt(t)&&(t+=o);const r=Po[n.type]||Po.default;L(r,[n,t,e])?s[n.id]=0:s[n.id]=t}function Sh(n,t,e,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=nt(n),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};fn(n,r);const h=s!==0,u=o!==0;Y(e||n.scales,function(d){d.isHorizontal()&&h?Dl(d,s,l,r):!d.isHorizontal()&&u&&Dl(d,o,l,r)}),n.update(i),L(c,[{chart:n}])}function Dh(n){const t=nt(n);fn(n,t);const e={};for(const i of Object.keys(n.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};e[i]={min:s.scale,max:o.scale}}return e}function e_(n){const t=nt(n),e={};for(const i of Object.keys(n.scales))e[i]=t.updatedScaleLimits[i];return e}function n_(n){const t=Dh(n);for(const e of Object.keys(n.scales)){const{min:i,max:s}=t[e];if(i!==void 0&&n.scales[e].min!==i||s!==void 0&&n.scales[e].max!==s)return!0}return!1}function Ol(n){const t=nt(n);return t.panning||t.dragging}const Cl=(n,t,e)=>Math.min(e,Math.max(t,n));function Tt(n,t){const{handlers:e}=nt(n),i=e[t];i&&i.target&&(i.target.removeEventListener(t,i),delete e[t])}function Un(n,t,e,i){const{handlers:s,options:o}=nt(n),r=s[e];if(r&&r.target===t)return;Tt(n,e),s[e]=l=>i(n,l,o),s[e].target=t;const a=e==="wheel"?!1:void 0;t.addEventListener(e,s[e],{passive:a})}function i_(n,t){const e=nt(n);e.dragStart&&(e.dragging=!0,e.dragEnd=t,n.update("none"))}function s_(n,t){const e=nt(n);!e.dragStart||t.key!=="Escape"||(Tt(n,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=null,n.update("none"))}function To(n,t){if(n.target!==t.canvas){const e=t.canvas.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}return qt(n,t)}function Oh(n,t,e){const{onZoomStart:i,onZoomRejected:s}=e;if(i){const o=To(t,n);if(L(i,[{chart:n,event:t,point:o}])===!1)return L(s,[{chart:n,event:t}]),!1}}function o_(n,t){if(n.legend){const o=qt(t,n);if(Qt(o,n.legend))return}const e=nt(n),{pan:i,zoom:s={}}=e.options;if(t.button!==0||_h(Jn(i),t)||or(Jn(s.drag),t))return L(s.onZoomRejected,[{chart:n,event:t}]);Oh(n,t,s)!==!1&&(e.dragStart=t,Un(n,n.canvas.ownerDocument,"mousemove",i_),Un(n,window.document,"keydown",s_))}function r_({begin:n,end:t},e){let i=t.x-n.x,s=t.y-n.y;const o=Math.abs(i/s);o>e?i=Math.sign(i)*Math.abs(s*e):o<e&&(s=Math.sign(s)*Math.abs(i/e)),t.x=n.x+i,t.y=n.y+s}function El(n,t,e,{min:i,max:s,prop:o}){n[i]=Cl(Math.min(e.begin[o],e.end[o]),t[i],t[s]),n[s]=Cl(Math.max(e.begin[o],e.end[o]),t[i],t[s])}function a_(n,t,e){const i={begin:To(t.dragStart,n),end:To(t.dragEnd,n)};if(e){const s=n.chartArea.width/n.chartArea.height;r_(i,s)}return i}function Ch(n,t,e,i){const s=Pe(t,"x",n),o=Pe(t,"y",n),{top:r,left:a,right:l,bottom:c,width:h,height:u}=n.chartArea,d={top:r,left:a,right:l,bottom:c},g=a_(n,e,i&&s&&o);s&&El(d,n.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&El(d,n.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=d.right-d.left,b=d.bottom-d.top;return{...d,width:p,height:b,zoomX:s&&p?1+(h-p)/h:1,zoomY:o&&b?1+(u-b)/u:1}}function l_(n,t){const e=nt(n);if(!e.dragStart)return;Tt(n,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=e.options.zoom,a=Ch(n,i,{dragStart:e.dragStart,dragEnd:t},r),l=Pe(i,"x",n)?a.width:0,c=Pe(i,"y",n)?a.height:0,h=Math.sqrt(l*l+c*c);if(e.dragStart=e.dragEnd=null,h<=o){e.dragging=!1,n.update("none");return}Th(n,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,L(s,[{chart:n}])}function c_(n,t,e){if(or(Jn(e.wheel),t)){L(e.onZoomRejected,[{chart:n,event:t}]);return}if(Oh(n,t,e)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function h_(n,t){const{handlers:{onZoomComplete:e},options:{zoom:i}}=nt(n);if(!c_(n,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};rr(n,a,"zoom","wheel"),L(e,[{chart:n}])}function u_(n,t,e,i){e&&(nt(n).handlers[t]=Lx(()=>L(e,[{chart:n}]),i))}function d_(n,t){const e=n.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Un(n,e,"wheel",h_),u_(n,"onZoomComplete",o,250)):Tt(n,"wheel"),s.enabled?(Un(n,e,"mousedown",o_),Un(n,e.ownerDocument,"mouseup",l_)):(Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"keydown"))}function f_(n){Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"wheel"),Tt(n,"click"),Tt(n,"keydown")}function g_(n,t){return function(e,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(or(Jn(s),r)||_h(Jn(o.drag),r))?(L(s.onPanRejected,[{chart:n,event:i}]),!1):!0}}function m_(n,t){const e=Math.abs(n.clientX-t.clientX),i=Math.abs(n.clientY-t.clientY),s=e/i;let o,r;return s>.3&&s<1.7?o=r=!0:e>i?o=!0:r=!0,{x:o,y:r}}function Eh(n,t,e){if(t.scale){const{center:i,pointers:s}=e,o=1/t.scale*e.scale,r=e.target.getBoundingClientRect(),a=m_(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&Pe(l,"x",n)?o:1,y:a.y&&Pe(l,"y",n)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};rr(n,c,"zoom","pinch"),t.scale=e.scale}}function p_(n,t,e){if(t.options.zoom.pinch.enabled){const i=qt(e,n);L(t.options.zoom.onZoomStart,[{chart:n,event:e,point:i}])===!1?(t.scale=null,L(t.options.zoom.onZoomRejected,[{chart:n,event:e}])):t.scale=1}}function b_(n,t,e){t.scale&&(Eh(n,t,e),t.scale=null,L(t.options.zoom.onZoomComplete,[{chart:n}]))}function Ah(n,t,e){const i=t.delta;i&&(t.panning=!0,Sh(n,{x:e.deltaX-i.x,y:e.deltaY-i.y},t.panScales),t.delta={x:e.deltaX,y:e.deltaY})}function y_(n,t,e){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=e.target.getBoundingClientRect(),a={x:e.center.x-r.left,y:e.center.y-r.top};if(L(s,[{chart:n,event:e,point:a}])===!1)return L(o,[{chart:n,event:e}]);t.panScales=wh(t.options.pan,a,n),t.delta={x:0,y:0},Ah(n,t,e)}function x_(n,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,L(t.options.pan.onPanComplete,[{chart:n}]))}const So=new WeakMap;function Al(n,t){const e=nt(n),i=n.canvas,{pan:s,zoom:o}=t,r=new Xn.Manager(i);o&&o.pinch.enabled&&(r.add(new Xn.Pinch),r.on("pinchstart",a=>p_(n,e,a)),r.on("pinch",a=>Eh(n,e,a)),r.on("pinchend",a=>b_(n,e,a))),s&&s.enabled&&(r.add(new Xn.Pan({threshold:s.threshold,enable:g_(n,e)})),r.on("panstart",a=>y_(n,e,a)),r.on("panmove",a=>Ah(n,e,a)),r.on("panend",()=>x_(n,e))),So.set(n,r)}function Il(n){const t=So.get(n);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),So.delete(n))}function __(n,t){var r,a,l,c;const{pan:e,zoom:i}=n,{pan:s,zoom:o}=t;return((a=(r=i==null?void 0:i.zoom)==null?void 0:r.pinch)==null?void 0:a.enabled)!==((c=(l=o==null?void 0:o.zoom)==null?void 0:l.pinch)==null?void 0:c.enabled)||(e==null?void 0:e.enabled)!==(s==null?void 0:s.enabled)||(e==null?void 0:e.threshold)!==(s==null?void 0:s.threshold)}var w_="2.2.0";function Fi(n,t,e){const i=e.zoom.drag,{dragStart:s,dragEnd:o}=nt(n);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Ch(n,e.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),h=n.ctx;h.save(),h.beginPath(),h.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",h.fillRect(r,a,l,c),i.borderWidth>0&&(h.lineWidth=i.borderWidth,h.strokeStyle=i.borderColor||"rgba(225,225,225)",h.strokeRect(r,a,l,c)),h.restore()}var v_={id:"zoom",version:w_,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(n,t,e){const i=nt(n);i.options=e,Object.prototype.hasOwnProperty.call(e.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(e.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(e.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Xn&&Al(n,e),n.pan=(s,o,r)=>Sh(n,s,o,r),n.zoom=(s,o)=>rr(n,s,o),n.zoomRect=(s,o,r)=>Th(n,s,o,r),n.zoomScale=(s,o,r)=>Zx(n,s,o,r),n.resetZoom=s=>Kx(n,s),n.getZoomLevel=()=>t_(n),n.getInitialScaleBounds=()=>Dh(n),n.getZoomedScaleBounds=()=>e_(n),n.isZoomedOrPanned=()=>n_(n),n.isZoomingOrPanning=()=>Ol(n)},beforeEvent(n,{event:t}){if(Ol(n))return!1;if(t.type==="click"||t.type==="mouseup"){const e=nt(n);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(n,t,e){const i=nt(n),s=i.options;i.options=e,__(s,e)&&(Il(n),Al(n,e)),d_(n,e)},beforeDatasetsDraw(n,t,e){Fi(n,"beforeDatasetsDraw",e)},afterDatasetsDraw(n,t,e){Fi(n,"afterDatasetsDraw",e)},beforeDraw(n,t,e){Fi(n,"beforeDraw",e)},afterDraw(n,t,e){Fi(n,"afterDraw",e)},stop:function(n){f_(n),Xn&&Il(n),Fx(n)},panFunctions:Po,zoomFunctions:Mo,zoomRectFunctions:ko};Mt.register(i0,v_,Dx);Mt.defaults.maintainAspectRatio=!1;Mt.defaults.datasets.line.spanGaps=!0;var mt,nn;class Ih extends HTMLElement{constructor(){super(...arguments);wn(this,mt,null);wn(this,nn,!1)}connectedCallback(){this.style.display="block",this.style.width="100%",this.style.height="100%";const e=document.createElement("canvas");this.appendChild(e);const i=this.getAttributeNames().filter(s=>s.startsWith("plugins")||s.startsWith("interaction")||s.startsWith("scales")||s==="responsive").reduce((s,o)=>{const r=o.split("."),a=r.pop(),l=this.getAttribute(o),c=r.reduce((h,u)=>(u in h||(h[u]={}),h[u]),s);return c[a]=Ll.trySafeEval(l),s},{});ue(this,mt,new Mt(e,{type:this.getAttribute("type"),data:{datasets:[]},options:i}))}set data(e){gt(this,mt).data=e,this.update()}set options(e){gt(this,mt).options=e}addOrReplaceDataset(e,i){const s=gt(this,mt).data.datasets.findIndex(e);s===-1?gt(this,mt).data.datasets=[...gt(this,mt).data.datasets,i]:gt(this,mt).data.datasets.splice(s,1,i),this.update()}removeDataset(e){gt(this,mt).data.datasets=gt(this,mt).data.datasets.filter(i=>!e(i)),this.update()}addOrReplaceAnnotation(e,i){gt(this,mt).options.plugins||(gt(this,mt).options.plugins={}),gt(this,mt).options.plugins.annotation||(gt(this,mt).options.plugins.annotation={annotations:{}});const s=gt(this,mt).options.plugins.annotation.annotations,o=Object.values(s).findIndex(e);if(o===-1){const r=Object.keys(s).length;s[r]=i}else{const r=Object.keys(s)[o];s[r]=i}}removeAnnotation(e){}update(){gt(this,nn)||(ue(this,nn,!0),setTimeout(()=>{gt(this,mt).update("none"),ue(this,nn,!1)},100))}}mt=new WeakMap,nn=new WeakMap;customElements.define("chartjs-chart",Ih);var ze,ti;class Lh extends HTMLElement{constructor(){super(...arguments);wn(this,ze);wn(this,ti,null)}connectedCallback(){if(this.getAttribute("included")==="false")return;ue(this,ze,this.closest("chartjs-chart")),this.syncDataset(),new MutationObserver(()=>this.syncDataset()).observe(this,{attributes:!0}),this.getAttribute("data-from")&&new MutationObserver(o=>{this.syncDataset()}).observe(this.closest("chartjs-chart"),{childList:!0,attributes:!0,subtree:!0})}disconnectedCallback(){var e;(e=gt(this,ze))==null||e.removeDataset(i=>i.owner===this),ue(this,ze,null)}syncDataset(){var s;const e=this.getAttributeNames().filter(o=>!o.startsWith("data")&&!o.startsWith(":")).map(o=>[M_(Rh(o)),this.getAttribute(o)]).reduce((o,[r,a])=>(o[r]=Ll.trySafeEval(a),o),{}),i=this.data;(s=gt(this,ze))==null||s.addOrReplaceDataset(o=>o.owner===this,{...e,data:i,owner:this})}get data(){const e=this.getAttribute("data");if(e)return ue(this,ti,JSON.parse(e));const i=this.getAttribute("data-from");if(i){const s=this.closest("chartjs-chart").querySelector(`chartjs-dataset${i}`);if(s)return ue(this,ti,s.data)}}}ze=new WeakMap,ti=new WeakMap;customElements.define("chartjs-dataset",Lh);function M_(n){return n==="xAxisId"?"xAxisID":n==="yAxisId"?"yAxisID":n}function Rh(n){return n.replace(/([-_][a-z])/g,t=>t.toUpperCase().replace("-","").replace("_",""))}exports.ChartDataset=Lh;exports.ChartElement=Ih;exports.snakeToCamel=Rh;
|
|
44
|
+
*/const Jn=n=>n&&n.enabled&&n.modifierKey,_h=(n,t)=>n&&t[n+"Key"],or=(n,t)=>n&&!t[n+"Key"];function Pe(n,t,e){return n===void 0?!0:typeof n=="string"?n.indexOf(t)!==-1:typeof n=="function"?n({chart:e}).indexOf(t)!==-1:!1}function qs(n,t){return typeof n=="function"&&(n=n({chart:t})),typeof n=="string"?{x:n.indexOf("x")!==-1,y:n.indexOf("y")!==-1}:{x:!1,y:!1}}function Lx(n,t){let e;return function(){return clearTimeout(e),e=setTimeout(n,t),t}}function Rx({x:n,y:t},e){const i=e.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)return r}return null}function wh(n,t,e){const{mode:i="xy",scaleMode:s,overScaleMode:o}=n||{},r=Rx(t,e),a=qs(i,e),l=qs(s,e);if(o){const h=qs(o,e);for(const u of["x","y"])h[u]&&(l[u]=a[u],a[u]=!1)}if(r&&l[r.axis])return[r];const c=[];return Y(e.scales,function(h){a[h.axis]&&c.push(h)}),c}const vo=new WeakMap;function nt(n){let t=vo.get(n);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},vo.set(n,t)),t}function Fx(n){vo.delete(n)}function vh(n,t,e,i){const s=Math.max(0,Math.min(1,(n-t)/e||0)),o=1-s;return{min:i*s,max:i*o}}function Mh(n,t){const e=n.isHorizontal()?t.x:t.y;return n.getValueForPixel(e)}function kh(n,t,e){const i=n.max-n.min,s=i*(t-1),o=Mh(n,e);return vh(o,n.min,i,s)}function Nx(n,t,e){const i=Mh(n,e);if(i===void 0)return{min:n.min,max:n.max};const s=Math.log10(n.min),o=Math.log10(n.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=vh(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function zx(n,t){return t&&(t[n.id]||t[n.axis])||{}}function vl(n,t,e,i,s){let o=e[i];if(o==="original"){const r=n.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function Wx(n,t,e){const i=n.getValueForPixel(t),s=n.getValueForPixel(e);return{min:Math.min(i,s),max:Math.max(i,s)}}function Hx(n,{min:t,max:e,minLimit:i,maxLimit:s},o){const r=(n-e+t)/2;t-=r,e+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=n/1e6;return We(t,a,c)&&(t=a),We(e,l,c)&&(e=l),t<i?(t=i,e=Math.min(i+n,s)):e>s&&(e=s,t=Math.max(s-n,i)),{min:t,max:e}}function Ge(n,{min:t,max:e},i,s=!1){const o=nt(n.chart),{options:r}=n,a=zx(n,i),{minRange:l=0}=a,c=vl(o,n,a,"min",-1/0),h=vl(o,n,a,"max",1/0);if(s==="pan"&&(t<c||e>h))return!0;const u=n.max-n.min,d=s?Math.max(e-t,l):u;if(s&&d===l&&u<=l)return!0;const g=Hx(d,{min:t,max:e,minLimit:c,maxLimit:h},o.originalScaleLimits[n.id]);return r.min=g.min,r.max=g.max,o.updatedScaleLimits[n.id]=g,n.parse(g.min)!==n.min||n.parse(g.max)!==n.max}function Yx(n,t,e,i){const s=kh(n,t,e),o={min:n.min+s.min,max:n.max-s.max};return Ge(n,o,i,!0)}function Bx(n,t,e,i){const s=Nx(n,t,e);return Ge(n,s,i,!0)}function Vx(n,t,e,i){Ge(n,Wx(n,t,e),i,!0)}const Ml=n=>n===0||isNaN(n)?0:n<0?Math.min(Math.round(n),-1):Math.max(Math.round(n),1);function jx(n){const e=n.getLabels().length-1;n.min>0&&(n.min-=1),n.max<e&&(n.max+=1)}function Xx(n,t,e,i){const s=kh(n,t,e);n.min===n.max&&t<1&&jx(n);const o={min:n.min+Ml(s.min),max:n.max-Ml(s.max)};return Ge(n,o,i,!0)}function Ux(n){return n.isHorizontal()?n.width:n.height}function qx(n,t,e){const s=n.getLabels().length-1;let{min:o,max:r}=n;const a=Math.max(r-o,1),l=Math.round(Ux(n)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let h;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,h=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,h=o===0),Ge(n,{min:o,max:r},e)||h}const $x={second:500,minute:30*1e3,hour:30*60*1e3,day:12*60*60*1e3,week:3.5*24*60*60*1e3,month:15*24*60*60*1e3,quarter:60*24*60*60*1e3,year:182*24*60*60*1e3};function Ph(n,t,e,i=!1){const{min:s,max:o,options:r}=n,a=r.time&&r.time.round,l=$x[a]||0,c=n.getValueForPixel(n.getPixelForValue(s+l)-t),h=n.getValueForPixel(n.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(h)?!0:Ge(n,{min:c,max:h},e,i?"pan":!1)}function kl(n,t,e){return Ph(n,t,e,!0)}const Mo={category:Xx,default:Yx,logarithmic:Bx},ko={default:Vx},Po={category:qx,default:Ph,logarithmic:kl,timeseries:kl};function Gx(n,t,e){const{id:i,options:{min:s,max:o}}=n;if(!t[i]||!e[i])return!0;const r=e[i];return r.min!==s||r.max!==o}function Pl(n,t){Y(n,(e,i)=>{t[i]||delete n[i]})}function fn(n,t){const{scales:e}=n,{originalScaleLimits:i,updatedScaleLimits:s}=t;return Y(e,function(o){Gx(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),Pl(i,e),Pl(s,e),i}function Tl(n,t,e,i){const s=Mo[n.type]||Mo.default;L(s,[n,t,e,i])}function Sl(n,t,e,i){const s=ko[n.type]||ko.default;L(s,[n,t,e,i])}function Qx(n){const t=n.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function rr(n,t,e="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Qx(n)}=typeof t=="number"?{x:t,y:t}:t,a=nt(n),{options:{limits:l,zoom:c}}=a;fn(n,a);const h=s!==1,u=o!==1,d=wh(c,r,n);Y(d||n.scales,function(g){g.isHorizontal()&&h?Tl(g,s,r,l):!g.isHorizontal()&&u&&Tl(g,o,r,l)}),n.update(e),L(c.onZoom,[{chart:n,trigger:i}])}function Th(n,t,e,i="none",s="api"){const o=nt(n),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;fn(n,o);const c=Pe(l,"x",n),h=Pe(l,"y",n);Y(n.scales,function(u){u.isHorizontal()&&c?Sl(u,t.x,e.x,r):!u.isHorizontal()&&h&&Sl(u,t.y,e.y,r)}),n.update(i),L(a.onZoom,[{chart:n,trigger:s}])}function Zx(n,t,e,i="none",s="api"){var a;const o=nt(n);fn(n,o);const r=n.scales[t];Ge(r,e,void 0,!0),n.update(i),L((a=o.options.zoom)==null?void 0:a.onZoom,[{chart:n,trigger:s}])}function Kx(n,t="default"){const e=nt(n),i=fn(n,e);Y(n.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete e.updatedScaleLimits[s.id]}),n.update(t),L(e.options.zoom.onZoomComplete,[{chart:n}])}function Jx(n,t){const e=n.originalScaleLimits[t];if(!e)return;const{min:i,max:s}=e;return R(s.options,s.scale)-R(i.options,i.scale)}function t_(n){const t=nt(n);let e=1,i=1;return Y(n.scales,function(s){const o=Jx(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;e=Math.min(e,r),i=Math.max(i,r)}}),e<1?e:i}function Dl(n,t,e,i){const{panDelta:s}=i,o=s[n.id]||0;zt(o)===zt(t)&&(t+=o);const r=Po[n.type]||Po.default;L(r,[n,t,e])?s[n.id]=0:s[n.id]=t}function Sh(n,t,e,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=nt(n),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};fn(n,r);const h=s!==0,u=o!==0;Y(e||n.scales,function(d){d.isHorizontal()&&h?Dl(d,s,l,r):!d.isHorizontal()&&u&&Dl(d,o,l,r)}),n.update(i),L(c,[{chart:n}])}function Dh(n){const t=nt(n);fn(n,t);const e={};for(const i of Object.keys(n.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};e[i]={min:s.scale,max:o.scale}}return e}function e_(n){const t=nt(n),e={};for(const i of Object.keys(n.scales))e[i]=t.updatedScaleLimits[i];return e}function n_(n){const t=Dh(n);for(const e of Object.keys(n.scales)){const{min:i,max:s}=t[e];if(i!==void 0&&n.scales[e].min!==i||s!==void 0&&n.scales[e].max!==s)return!0}return!1}function Ol(n){const t=nt(n);return t.panning||t.dragging}const Cl=(n,t,e)=>Math.min(e,Math.max(t,n));function Tt(n,t){const{handlers:e}=nt(n),i=e[t];i&&i.target&&(i.target.removeEventListener(t,i),delete e[t])}function Un(n,t,e,i){const{handlers:s,options:o}=nt(n),r=s[e];if(r&&r.target===t)return;Tt(n,e),s[e]=l=>i(n,l,o),s[e].target=t;const a=e==="wheel"?!1:void 0;t.addEventListener(e,s[e],{passive:a})}function i_(n,t){const e=nt(n);e.dragStart&&(e.dragging=!0,e.dragEnd=t,n.update("none"))}function s_(n,t){const e=nt(n);!e.dragStart||t.key!=="Escape"||(Tt(n,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=null,n.update("none"))}function To(n,t){if(n.target!==t.canvas){const e=t.canvas.getBoundingClientRect();return{x:n.clientX-e.left,y:n.clientY-e.top}}return qt(n,t)}function Oh(n,t,e){const{onZoomStart:i,onZoomRejected:s}=e;if(i){const o=To(t,n);if(L(i,[{chart:n,event:t,point:o}])===!1)return L(s,[{chart:n,event:t}]),!1}}function o_(n,t){if(n.legend){const o=qt(t,n);if(Qt(o,n.legend))return}const e=nt(n),{pan:i,zoom:s={}}=e.options;if(t.button!==0||_h(Jn(i),t)||or(Jn(s.drag),t))return L(s.onZoomRejected,[{chart:n,event:t}]);Oh(n,t,s)!==!1&&(e.dragStart=t,Un(n,n.canvas.ownerDocument,"mousemove",i_),Un(n,window.document,"keydown",s_))}function r_({begin:n,end:t},e){let i=t.x-n.x,s=t.y-n.y;const o=Math.abs(i/s);o>e?i=Math.sign(i)*Math.abs(s*e):o<e&&(s=Math.sign(s)*Math.abs(i/e)),t.x=n.x+i,t.y=n.y+s}function El(n,t,e,{min:i,max:s,prop:o}){n[i]=Cl(Math.min(e.begin[o],e.end[o]),t[i],t[s]),n[s]=Cl(Math.max(e.begin[o],e.end[o]),t[i],t[s])}function a_(n,t,e){const i={begin:To(t.dragStart,n),end:To(t.dragEnd,n)};if(e){const s=n.chartArea.width/n.chartArea.height;r_(i,s)}return i}function Ch(n,t,e,i){const s=Pe(t,"x",n),o=Pe(t,"y",n),{top:r,left:a,right:l,bottom:c,width:h,height:u}=n.chartArea,d={top:r,left:a,right:l,bottom:c},g=a_(n,e,i&&s&&o);s&&El(d,n.chartArea,g,{min:"left",max:"right",prop:"x"}),o&&El(d,n.chartArea,g,{min:"top",max:"bottom",prop:"y"});const p=d.right-d.left,b=d.bottom-d.top;return{...d,width:p,height:b,zoomX:s&&p?1+(h-p)/h:1,zoomY:o&&b?1+(u-b)/u:1}}function l_(n,t){const e=nt(n);if(!e.dragStart)return;Tt(n,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=e.options.zoom,a=Ch(n,i,{dragStart:e.dragStart,dragEnd:t},r),l=Pe(i,"x",n)?a.width:0,c=Pe(i,"y",n)?a.height:0,h=Math.sqrt(l*l+c*c);if(e.dragStart=e.dragEnd=null,h<=o){e.dragging=!1,n.update("none");return}Th(n,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,L(s,[{chart:n}])}function c_(n,t,e){if(or(Jn(e.wheel),t)){L(e.onZoomRejected,[{chart:n,event:t}]);return}if(Oh(n,t,e)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function h_(n,t){const{handlers:{onZoomComplete:e},options:{zoom:i}}=nt(n);if(!c_(n,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};rr(n,a,"zoom","wheel"),L(e,[{chart:n}])}function u_(n,t,e,i){e&&(nt(n).handlers[t]=Lx(()=>L(e,[{chart:n}]),i))}function d_(n,t){const e=n.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Un(n,e,"wheel",h_),u_(n,"onZoomComplete",o,250)):Tt(n,"wheel"),s.enabled?(Un(n,e,"mousedown",o_),Un(n,e.ownerDocument,"mouseup",l_)):(Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"keydown"))}function f_(n){Tt(n,"mousedown"),Tt(n,"mousemove"),Tt(n,"mouseup"),Tt(n,"wheel"),Tt(n,"click"),Tt(n,"keydown")}function g_(n,t){return function(e,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(or(Jn(s),r)||_h(Jn(o.drag),r))?(L(s.onPanRejected,[{chart:n,event:i}]),!1):!0}}function m_(n,t){const e=Math.abs(n.clientX-t.clientX),i=Math.abs(n.clientY-t.clientY),s=e/i;let o,r;return s>.3&&s<1.7?o=r=!0:e>i?o=!0:r=!0,{x:o,y:r}}function Eh(n,t,e){if(t.scale){const{center:i,pointers:s}=e,o=1/t.scale*e.scale,r=e.target.getBoundingClientRect(),a=m_(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&Pe(l,"x",n)?o:1,y:a.y&&Pe(l,"y",n)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};rr(n,c,"zoom","pinch"),t.scale=e.scale}}function p_(n,t,e){if(t.options.zoom.pinch.enabled){const i=qt(e,n);L(t.options.zoom.onZoomStart,[{chart:n,event:e,point:i}])===!1?(t.scale=null,L(t.options.zoom.onZoomRejected,[{chart:n,event:e}])):t.scale=1}}function b_(n,t,e){t.scale&&(Eh(n,t,e),t.scale=null,L(t.options.zoom.onZoomComplete,[{chart:n}]))}function Ah(n,t,e){const i=t.delta;i&&(t.panning=!0,Sh(n,{x:e.deltaX-i.x,y:e.deltaY-i.y},t.panScales),t.delta={x:e.deltaX,y:e.deltaY})}function y_(n,t,e){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=e.target.getBoundingClientRect(),a={x:e.center.x-r.left,y:e.center.y-r.top};if(L(s,[{chart:n,event:e,point:a}])===!1)return L(o,[{chart:n,event:e}]);t.panScales=wh(t.options.pan,a,n),t.delta={x:0,y:0},Ah(n,t,e)}function x_(n,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,L(t.options.pan.onPanComplete,[{chart:n}]))}const So=new WeakMap;function Al(n,t){const e=nt(n),i=n.canvas,{pan:s,zoom:o}=t,r=new Xn.Manager(i);o&&o.pinch.enabled&&(r.add(new Xn.Pinch),r.on("pinchstart",a=>p_(n,e,a)),r.on("pinch",a=>Eh(n,e,a)),r.on("pinchend",a=>b_(n,e,a))),s&&s.enabled&&(r.add(new Xn.Pan({threshold:s.threshold,enable:g_(n,e)})),r.on("panstart",a=>y_(n,e,a)),r.on("panmove",a=>Ah(n,e,a)),r.on("panend",()=>x_(n,e))),So.set(n,r)}function Il(n){const t=So.get(n);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),So.delete(n))}function __(n,t){var r,a,l,c;const{pan:e,zoom:i}=n,{pan:s,zoom:o}=t;return((a=(r=i==null?void 0:i.zoom)==null?void 0:r.pinch)==null?void 0:a.enabled)!==((c=(l=o==null?void 0:o.zoom)==null?void 0:l.pinch)==null?void 0:c.enabled)||(e==null?void 0:e.enabled)!==(s==null?void 0:s.enabled)||(e==null?void 0:e.threshold)!==(s==null?void 0:s.threshold)}var w_="2.2.0";function Fi(n,t,e){const i=e.zoom.drag,{dragStart:s,dragEnd:o}=nt(n);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Ch(n,e.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),h=n.ctx;h.save(),h.beginPath(),h.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",h.fillRect(r,a,l,c),i.borderWidth>0&&(h.lineWidth=i.borderWidth,h.strokeStyle=i.borderColor||"rgba(225,225,225)",h.strokeRect(r,a,l,c)),h.restore()}var v_={id:"zoom",version:w_,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(n,t,e){const i=nt(n);i.options=e,Object.prototype.hasOwnProperty.call(e.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(e.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(e.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),Xn&&Al(n,e),n.pan=(s,o,r)=>Sh(n,s,o,r),n.zoom=(s,o)=>rr(n,s,o),n.zoomRect=(s,o,r)=>Th(n,s,o,r),n.zoomScale=(s,o,r)=>Zx(n,s,o,r),n.resetZoom=s=>Kx(n,s),n.getZoomLevel=()=>t_(n),n.getInitialScaleBounds=()=>Dh(n),n.getZoomedScaleBounds=()=>e_(n),n.isZoomedOrPanned=()=>n_(n),n.isZoomingOrPanning=()=>Ol(n)},beforeEvent(n,{event:t}){if(Ol(n))return!1;if(t.type==="click"||t.type==="mouseup"){const e=nt(n);if(e.filterNextClick)return e.filterNextClick=!1,!1}},beforeUpdate:function(n,t,e){const i=nt(n),s=i.options;i.options=e,__(s,e)&&(Il(n),Al(n,e)),d_(n,e)},beforeDatasetsDraw(n,t,e){Fi(n,"beforeDatasetsDraw",e)},afterDatasetsDraw(n,t,e){Fi(n,"afterDatasetsDraw",e)},beforeDraw(n,t,e){Fi(n,"beforeDraw",e)},afterDraw(n,t,e){Fi(n,"afterDraw",e)},stop:function(n){f_(n),Xn&&Il(n),Fx(n)},panFunctions:Po,zoomFunctions:Mo,zoomRectFunctions:ko};Mt.register(i0,v_,Dx);Mt.defaults.maintainAspectRatio=!1;Mt.defaults.datasets.line.spanGaps=!0;var mt,nn;class Ih extends HTMLElement{constructor(){super(...arguments);wn(this,mt,null);wn(this,nn,!1)}connectedCallback(){this.style.display="block",this.style.width="100%",this.style.height="100%";const e=document.createElement("canvas");this.appendChild(e);const i=this.getAttributeNames().filter(s=>s.startsWith("plugins")||s.startsWith("interaction")||s.startsWith("scales")||s==="responsive").reduce((s,o)=>{const r=o.split("."),a=r.pop(),l=this.getAttribute(o),c=r.reduce((h,u)=>(u in h||(h[u]={}),h[u]),s);return c[a]=Ll.trySafeEval(l),s},{});ue(this,mt,new Mt(e,{type:this.getAttribute("type"),data:{datasets:[],labels:this.labels},options:i}))}get labels(){const e=this.getAttribute("labels");return e?JSON.parse(e):[]}set data(e){gt(this,mt).data=e,this.update()}set options(e){gt(this,mt).options=e}addOrReplaceDataset(e,i){const s=gt(this,mt).data.datasets.findIndex(e);s===-1?gt(this,mt).data.datasets=[...gt(this,mt).data.datasets,i]:gt(this,mt).data.datasets.splice(s,1,i),this.update()}removeDataset(e){gt(this,mt).data.datasets=gt(this,mt).data.datasets.filter(i=>!e(i)),this.update()}addOrReplaceAnnotation(e,i){gt(this,mt).options.plugins||(gt(this,mt).options.plugins={}),gt(this,mt).options.plugins.annotation||(gt(this,mt).options.plugins.annotation={annotations:{}});const s=gt(this,mt).options.plugins.annotation.annotations,o=Object.values(s).findIndex(e);if(o===-1){const r=Object.keys(s).length;s[r]=i}else{const r=Object.keys(s)[o];s[r]=i}}removeAnnotation(e){}update(){gt(this,nn)||(ue(this,nn,!0),setTimeout(()=>{gt(this,mt).update("none"),ue(this,nn,!1)},100))}}mt=new WeakMap,nn=new WeakMap;customElements.define("chartjs-chart",Ih);var ze,ti;class Lh extends HTMLElement{constructor(){super(...arguments);wn(this,ze);wn(this,ti,null)}connectedCallback(){if(this.getAttribute("included")==="false")return;ue(this,ze,this.closest("chartjs-chart")),this.syncDataset(),new MutationObserver(()=>this.syncDataset()).observe(this,{attributes:!0}),this.getAttribute("data-from")&&new MutationObserver(o=>{this.syncDataset()}).observe(this.closest("chartjs-chart"),{childList:!0,attributes:!0,subtree:!0})}disconnectedCallback(){var e;(e=gt(this,ze))==null||e.removeDataset(i=>i.owner===this),ue(this,ze,null)}syncDataset(){var s;const e=this.getAttributeNames().filter(o=>!o.startsWith("data")&&!o.startsWith(":")).map(o=>[M_(Rh(o)),this.getAttribute(o)]).reduce((o,[r,a])=>(o[r]=Ll.trySafeEval(a),o),{}),i=this.data;(s=gt(this,ze))==null||s.addOrReplaceDataset(o=>o.owner===this,{...e,data:i,owner:this})}get data(){const e=this.getAttribute("data");if(e)return ue(this,ti,JSON.parse(e));const i=this.getAttribute("data-from");if(i){const s=this.closest("chartjs-chart").querySelector(`chartjs-dataset${i}`);if(s)return ue(this,ti,s.data)}}}ze=new WeakMap,ti=new WeakMap;customElements.define("chartjs-dataset",Lh);function M_(n){return n==="xAxisId"?"xAxisID":n==="yAxisId"?"yAxisID":n}function Rh(n){return n.replace(/([-_][a-z])/g,t=>t.toUpperCase().replace("-","").replace("_",""))}exports.ChartDataset=Lh;exports.ChartElement=Ih;exports.snakeToCamel=Rh;
|
package/dist/chartjs-chart.js
CHANGED
|
@@ -15897,10 +15897,14 @@ class __ extends HTMLElement {
|
|
|
15897
15897
|
}, {});
|
|
15898
15898
|
ue(this, mt, new Mt(e, {
|
|
15899
15899
|
type: this.getAttribute("type"),
|
|
15900
|
-
data: { datasets: [] },
|
|
15900
|
+
data: { datasets: [], labels: this.labels },
|
|
15901
15901
|
options: i
|
|
15902
15902
|
}));
|
|
15903
15903
|
}
|
|
15904
|
+
get labels() {
|
|
15905
|
+
const e = this.getAttribute("labels");
|
|
15906
|
+
return e ? JSON.parse(e) : [];
|
|
15907
|
+
}
|
|
15904
15908
|
set data(e) {
|
|
15905
15909
|
gt(this, mt).data = e, this.update();
|
|
15906
15910
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartjs-chart.d.ts","sourceRoot":"","sources":["../../src/components/chartjs-chart.ts"],"names":[],"mappings":"AAIA,OAAO,0BAA0B,CAAA;AAYjC,qBAAa,YAAa,SAAQ,WAAW;;IAG3C,iBAAiB;IAiCjB,IAAI,IAAI,CAAC,IAAI,KAAA,EAGZ;IAED,IAAI,OAAO,CAAC,OAAO,KAAA,EAElB;IAED,mBAAmB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA;IAUtC,aAAa,CAAC,SAAS,KAAA;IAKvB,sBAAsB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA;IAkB5C,gBAAgB,CAAC,SAAS,KAAA;IAM1B;;;;;OAKG;IACH,MAAM;CAQP;AAGD,qBAAa,YAAa,SAAQ,WAAW;;IAI3C,iBAAiB;IAqBjB,oBAAoB;IAKpB,WAAW;IAcX,IAAI,IAAI,QAWP;CACF;AASD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAOvC"}
|
|
1
|
+
{"version":3,"file":"chartjs-chart.d.ts","sourceRoot":"","sources":["../../src/components/chartjs-chart.ts"],"names":[],"mappings":"AAIA,OAAO,0BAA0B,CAAA;AAYjC,qBAAa,YAAa,SAAQ,WAAW;;IAG3C,iBAAiB;IAiCjB,IAAI,MAAM,QAGT;IAED,IAAI,IAAI,CAAC,IAAI,KAAA,EAGZ;IAED,IAAI,OAAO,CAAC,OAAO,KAAA,EAElB;IAED,mBAAmB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA;IAUtC,aAAa,CAAC,SAAS,KAAA;IAKvB,sBAAsB,CAAC,SAAS,KAAA,EAAE,UAAU,KAAA;IAkB5C,gBAAgB,CAAC,SAAS,KAAA;IAM1B;;;;;OAKG;IACH,MAAM;CAQP;AAGD,qBAAa,YAAa,SAAQ,WAAW;;IAI3C,iBAAiB;IAqBjB,oBAAoB;IAKpB,WAAW;IAcX,IAAI,IAAI,QAWP;CACF;AASD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,UAOvC"}
|