csat-chart.js 1.2.0 → 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/CHANGELOG.md +255 -0
- package/README.md +189 -16
- package/dist/csat-chart.cjs +931 -304
- package/dist/csat-chart.cjs.map +1 -1
- package/dist/csat-chart.d.cts +235 -7
- package/dist/csat-chart.d.mts +235 -7
- package/dist/csat-chart.mjs +926 -304
- package/dist/csat-chart.mjs.map +1 -1
- package/dist/csat-chart.umd.min.js +1 -1
- package/dist/csat-chart.umd.min.js.map +1 -1
- package/package.json +66 -66
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
(function(){
|
|
2
|
-
"use strict";var __csat=(()=>{var Ut=Object.defineProperty;var to=Object.getOwnPropertyDescriptor;var no=Object.getOwnPropertyNames;var oo=Object.prototype.hasOwnProperty;var ro=(e,o)=>{for(var r in o)Ut(e,r,{get:o[r],enumerable:!0})},io=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of no(o))!oo.call(e,n)&&n!==r&&Ut(e,n,{get:()=>o[n],enumerable:!(t=to(o,n))||t.enumerable});return e};var lo=e=>io(Ut({},"__esModule",{value:!0}),e);var kr={};ro(kr,{AGE_GROUPS:()=>cr,CHART_TYPES:()=>lt,CsatChart:()=>Nt,CsatChartError:()=>Z,DOT_MARKER_ORDER:()=>yr,LINE_DASH:()=>Dr,LINE_MARKER_ORDER:()=>Sr,LINE_STYLE_ORDER:()=>Lr,MONTH_LABELS_EN:()=>Tr,MONTH_LABELS_NUM:()=>vr,autoRange:()=>J,createDefaultAbsBarData:()=>Dt,createDefaultCategoryDotData:()=>zt,createDefaultClimateData:()=>St,createDefaultCubeData:()=>At,createDefaultDataTableData:()=>Ft,createDefaultDeviationAData:()=>ct,createDefaultDeviationBData:()=>yt,createDefaultGraphOptions:()=>pt,createDefaultHythergraphData:()=>Ct,createDefaultLineData:()=>Wt,createDefaultMatrixTableData:()=>Gt,createDefaultPyramidData:()=>Lt,createDefaultRadarData:()=>Pt,createDefaultScatterData:()=>kt,createDefaultStackedData:()=>vt,createDefaultTernaryData:()=>Tt,createDefaultTreemapData:()=>Bt,ensureFonts:()=>Ot,installRoundRectPolyfill:()=>Ht,isCsatChartType:()=>Et,niceStep:()=>Ae,renderAbsBarGraph:()=>_e,renderCategoryDotGraph:()=>$e,renderClimateGraph:()=>Ve,renderCubeGraph:()=>qe,renderDataTable:()=>Ke,renderDeviationAGraph:()=>Je,renderDeviationBGraph:()=>Ze,renderHythergraph:()=>Qe,renderLineGraph:()=>Ye,renderMatrixTable:()=>Xe,renderPyramidGraph:()=>et,renderRadarChart:()=>tt,renderScatterGraph:()=>nt,renderStackedGraph:()=>rt,renderTernaryGraph:()=>it,renderTreemapGraph:()=>je});function I(e,o="serif",r,t="normal"){return`${t} ${e}px ${{serif:"'Noto Serif KR', 'NanumMyeongjo', serif",sans:"'Noto Sans KR', sans-serif",custom:r||"'Noto Serif KR', serif"}[o]}`}function $(e,o,r){e.fillStyle="#fff",e.fillRect(0,0,o,r)}function rn(e,o,r,t,n){let i=o.split("\\n");if(i.length<=1){e.fillText(o,r,t);return}let l=(i.length-1)*n,s=t-l/2;for(let b=0;b<i.length;b++)e.fillText(i[b],r,s+b*n)}function Ae(e,o=8){if(!Number.isFinite(e)||e<=0)return 1;let r=e/o,t=Math.pow(10,Math.floor(Math.log10(r))),n=r/t,i;return n<=1.5?i=1:n<=3?i=2:n<=7?i=5:i=10,i*t}function J(e,o=8){if(e.length===0)return{min:0,max:100,step:20};let r=Math.min(...e),t=Math.max(...e);t-r>Math.max(Math.abs(r),Math.abs(t))*1e-9||(r-=10,t+=10);let n=(t-r)*.1;r=r-n,t=t+n;let i=Ae(t-r,o);return r=Math.floor(r/i)*i,t=Math.ceil(t/i)*i,{min:r,max:t,step:i}}var ft="'Noto Sans KR', sans-serif";function Pe(e,o,r,t,n){if(t<=0)return r;e.font=n(r);let i=e.measureText(o).width;if(i<=t)return r;let l=Math.max(r*.6,r*(t/i));return Math.floor(l)}function j({ctx:e,plotX:o,plotW:r,title:t,fontSize:n,canvasWidth:i}){if(!t)return;e.save(),e.fillStyle="#000";let l=p=>`bold ${p}px ${ft}`,s=o+r/2,b=i!=null?Math.max(0,Math.min(s,i-s)*2-12):r,g=Pe(e,t,n,b,l);e.font=l(g),e.textAlign="center",e.textBaseline="top",e.fillText(t,s,10,b>0?b:void 0),e.restore()}var ln=10;function K({ctx:e,plotX:o,plotW:r,height:t,source:n,sourceLeft:i,sourceInline:l,footnotes:s,fontSize:b,canvasWidth:g}){e.save();let p=o,f=o+r;g!=null&&(p=ln,f=g-ln);let h=s.filter(F=>F.trim()),y=h.length*(b*.9+4),a=!!i,m=!!l&&!!n&&!a&&h.length>0,c=(n||i)&&!m?b+4:0,d=t-6-y-(a?c:0),S=g!=null?f:o+r,D=Math.max(0,S-p),A=F=>`bold ${F}px ${ft}`;if(n&&!a&&!m){e.fillStyle="#555";let F=Pe(e,n,b,D,A);e.font=A(F),e.textAlign="right",e.textBaseline="bottom",e.fillText(n,f,d,D>0?D:void 0),d+=c}e.font=A(b);let v=m?e.measureText(n).width+16:0,k=Math.max(0,D-v),P=d;for(let F=0;F<h.length;F++){let w="* "+h[F];e.fillStyle="#555";let T=C=>`${C}px ${ft}`,z=Pe(e,w,b*.9,k,T);e.font=T(z),e.textAlign="left",e.textBaseline="bottom",e.fillText(w,p,d,k>0?k:void 0),P=d,d+=b*.9+4}if(m){e.fillStyle="#555";let F=Pe(e,n,b,v,A);e.font=A(F),e.textAlign="right",e.textBaseline="bottom",e.fillText(n,f,P,v>0?v:void 0)}if(a){let F=T=>`bold ${T}px ${ft}`,w=D>0?D/2:0;e.fillStyle="#555",e.textBaseline="bottom",e.font=F(Pe(e,i,b,w,F)),e.textAlign="left",e.fillText(i,p,t-6,w>0?w:void 0),n&&(e.font=F(Pe(e,n,b,w,F)),e.textAlign="right",e.fillText(n,f,t-6,w>0?w:void 0))}e.restore()}var we=class{constructor(){this.used=[]}reserve(o){this.used.push(o)}reserveCircle(o,r,t){this.used.push({left:o-t,right:o+t,top:r-t,bottom:r+t})}overlaps(o){return this.used.some(r=>!(o.right<r.left||o.left>r.right||o.bottom<r.top||o.top>r.bottom))}placeInColumn(o,r,t,n,i){let l=o.measureText(r).width,s=i.lineHeight,{bounds:b}=i,g=s+2;for(let p=0;p<40;p++){let f=Math.ceil(p/2)*g*(p%2===0?1:-1),h=n+f;if(h<b.top||h+s>b.bottom)continue;let y={left:t,right:t+l,top:h,bottom:h+s};if(!this.overlaps(y)){this.used.push(y),o.textAlign="left",o.textBaseline="top",o.fillText(r,t,h);return}}this.used.push({left:t,right:t+l,top:n,bottom:n+s}),o.textAlign="left",o.textBaseline="top",o.fillText(r,t,n)}place(o,r,t,n,i){let l=o.measureText(r).width,s=i.lineHeight,{gap:b,bounds:g}=i,p=[[1,-1],[1,0],[0,-1],[-1,-1],[-1,0],[0,1],[1,1],[-1,1]],f=null;for(let a of[b,b*2,b*3.5])for(let[m,c]of p){let d=t+m*a-(m<0?l:m===0?l/2:0),S=n+c*a-(c>0?0:c===0?s/2:s),D={left:d,right:d+l,top:S,bottom:S+s};if(!(D.left<g.left||D.right>g.right)&&!(D.top<g.top||D.bottom>g.bottom)){if(!this.overlaps(D)){this.used.push(D),o.textAlign="left",o.textBaseline="top",o.fillText(r,d,S);return}f||(f={x:d,y:S})}}let h=f??{x:t+b,y:n-s},y={left:h.x,right:h.x+l,top:h.y,bottom:h.y+s};this.used.push(y),o.save(),o.strokeStyle="#666",o.lineWidth=.8,o.beginPath(),o.moveTo(t,n),o.lineTo(h.x+l/2,h.y+s/2),o.stroke(),o.restore(),o.textAlign="left",o.textBaseline="top",o.fillText(r,h.x,h.y)}};function ie(e,o,r=6){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.ceil((o+r)/e))}function oe(e,o){return o.length===0?0:Math.max(...o.map(r=>e.measureText(r).width))}function be(e,o){let r=e.measureText(o),t=r.width,n=e.textAlign==="right"||e.textAlign==="end"?t:e.textAlign==="center"?t/2:0,i=ao(e.font),l=e.textBaseline==="top"?0:e.textBaseline==="middle"?i*.5:i*.8,s=i-l;if(r.actualBoundingBoxAscent!=null){l=0,s=0;for(let b of o){if(!b.trim())continue;let g=e.measureText(b);l=Math.max(l,g.actualBoundingBoxAscent),s=Math.max(s,g.actualBoundingBoxDescent)}}return{left:n,right:t-n,up:l,down:s}}function ao(e){let o=/(\d+(?:\.\d+)?)px/.exec(e);return o?parseFloat(o[1]):16}function fe(e,o,r,t,n,i,l=1){let s=be(e,o),b=r,g=t;return r-s.left<l?b=l+s.left:r+s.right>n-l&&(b=n-l-s.right),t-s.up<l?g=l+s.up:t+s.down>i-l&&(g=i-l-s.down),{x:b,y:g}}function Le(e,o,r,t,n,i=.7){if(t<=0||o.length===0)return r;let l=e.font;e.font=n(r);let s=Math.max(...o.map(b=>e.measureText(b).width));return e.font=l,s<=t?r:Math.max(r*i,r*(t/s))}function re(e,o,r){if(r<=0||!o)return[o];if(e.measureText(o).width<=r)return[o];let t=[],n="",i=()=>{n&&(t.push(n),n="")};for(let l of o.split(/(\s+)/)){if(/^\s+$/.test(l)){n&&(n+=l);continue}let s=n?n+l:l;if(e.measureText(s).width<=r){n=s;continue}if(i(),e.measureText(l).width<=r){n=l;continue}for(let b of l){let g=n+b;n&&e.measureText(g).width>r?(i(),n=b):n=g}}return i(),t.length>0?t:[o]}function $t(e,o){return o.length===0?0:Math.max(...o.map(r=>e.measureText(r).width))}function pe(e,o,r,t,n){let i=t-(o.length-1)*n/2;for(let l=0;l<o.length;l++)e.fillText(o[l],r,i+l*n)}function le(e,o,r,t,n,i,l,s){if(!o)return;e.font=s(Le(e,[o],l,n-2,s));let b=fe(e,o,r,t,n,i);e.fillText(o,b.x,b.y)}function an(e,o,r,t,n,i,l,s=1){if(o.length===0)return{x:r,y:t};let b=o.map(c=>be(e,c)),g=(o.length-1)*n/2,p=Math.max(...b.map(c=>c.left)),f=Math.max(...b.map(c=>c.right)),h=g+Math.max(...b.map(c=>c.up)),y=g+Math.max(...b.map(c=>c.down)),a=r,m=t;return r-p<s?a=s+p:r+f>i-s&&(a=i-s-f),t-h<s?m=s+h:t+y>l-s&&(m=l-s-y),{x:a,y:m}}function sn(e,o,r,t,n,i=1){if(o.length===0)return r;let l=(o.length-1)*t/2,s=Math.max(...o.map(g=>be(e,g).up)),b=Math.max(...o.map(g=>be(e,g).down));return r-l-s<i?i+l+s:r+l+b>n-i?n-i-l-b:r}function se(e,o,r,t=24){if(r(o))return o;let n=e,i=o;for(let l=0;l<t;l++){let s=(n+i)/2;r(s)?n=s:i=s}return n}var fn=(e,o,r)=>({x:e.left,y:e.top,w:o-e.left-e.right,h:r-e.top-e.bottom});function ge({ctx:e,padding:o,width:r,height:t,min:n,max:i,step:l,label:s,side:b,fontFamily:g,customFont:p,tickFontSize:f,labelFontSize:h,drawGrid:y=!1}){let a=fn(o,r,t),m=b==="left"?a.x:a.x+a.w;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(m,a.y),e.lineTo(m,a.y+a.h),e.stroke(),e.fillStyle="#000",e.font=I(f,g,p,"bold"),e.textBaseline="middle",e.textAlign=b==="left"?"right":"left";let c=[];for(let S=n;S<i-l*1e-9;S+=l)c.push(Math.abs(S)<1e-9?0:S);(c.length===0||Math.abs(c[c.length-1]-i)>1e-9)&&c.push(i);let d=ie(a.h/Math.max(1,c.length-1),f*1.1);for(let S=0;S<c.length;S++){let D=c[S],A=a.y+a.h-(D-n)/(i-n)*a.h;if(e.lineWidth=1.5,e.beginPath(),b==="left"?(e.moveTo(m-6,A),e.lineTo(m,A)):(e.moveTo(m,A),e.lineTo(m+6,A)),e.stroke(),y&&S>0&&S<c.length-1&&(e.save(),e.strokeStyle="#ccc",e.lineWidth=.5,e.setLineDash([4,4]),e.beginPath(),e.moveTo(a.x,A),e.lineTo(a.x+a.w,A),e.stroke(),e.restore()),S%d===0){let v=b==="left"?m-12:m+12;e.fillText(so(D),v,A)}}if(s){e.save();let S=v=>I(v,g,p,"bold");e.fillStyle="#000",e.textBaseline="bottom",e.textAlign=b==="left"?"right":"left",e.font=S(Le(e,[s],h,r-2,S));let D=b==="left"?m-12:m+12,A=fe(e,s,D,a.y-f*.5-8,r,t);e.fillText(s,A.x,A.y),e.restore()}}function Yt({ctx:e,padding:o,width:r,height:t,labels:n,indices:i,fontFamily:l,customFont:s,tickFontSize:b}){let g=fn(o,r,t),p=g.y+g.h;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(g.x,p),e.lineTo(g.x+g.w,p),e.stroke(),e.fillStyle="#000",e.font=I(b,l,s,"bold"),e.textAlign="center",e.textBaseline="top";let f=i??n.map((m,c)=>c),h=g.w/n.length,y=ie(h,oe(e,n)),a=0;for(let m of f){if(m<0||m>=n.length)continue;let c=g.x+h*m+h/2;e.lineWidth=1.5,e.beginPath(),e.moveTo(c,p),e.lineTo(c,p+6),e.stroke(),a%y===0&&e.fillText(n[m],c,p+12),a++}}function so(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}var mt=11;function un(e,o){return e.replace(/(\d*\.?\d+)px/,`${Math.round(o*100)/100}px`)}function bt({ctx:e,items:o,corner:r,plotX:t,plotY:n,plotW:i,plotH:l,canvasW:s,canvasH:b,fontSize:g,font:p,avoid:f=[]}){if(o.length===0)return;e.save(),e.font=p;let h=8,y=8,a=L=>{e.font=L===g?p:un(p,L);let B=L*.95,R=Math.max(...o.map(u=>u.type==="line"?B*2:B)),W=Math.max(...o.map(u=>e.measureText(u.label).width));return{swatch:B,maxIconW:R,boxW:h*2+R+8+W,rowH:L*1.5}},m=g,c=a(m),d=i-y*2;for(;m>mt&&c.boxW>d;)m=Math.max(mt,m-.5),c=a(m);let{swatch:S,maxIconW:D,boxW:A,rowH:v}=c,k=v*o.length+8,P=L=>({x:L.endsWith("right")?t+i-A-y:t+y,y:L.startsWith("top")?n+y:n+l-k-y}),T=[r,...["top-right","top-left","bottom-right","bottom-left"].filter(L=>L!==r)].map(P),z=L=>!f.some(B=>B.x0<L.x+A&&B.x1>L.x&&B.y0<L.y+k&&B.y1>L.y),C=T.find(z)??T[0],M={x:Math.max(1,Math.min(C.x,s-A-1)),y:Math.max(1,Math.min(C.y,b-k-1))};e.fillStyle="#fff",e.fillRect(M.x,M.y,A,k),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([]),e.strokeRect(M.x,M.y,A,k);for(let L=0;L<o.length;L++){let B=o[L],R=M.y+4+v*(L+.5);fo(e,B,M.x+h,R,S),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(B.label,M.x+h+D+8,R)}e.restore()}function fo(e,o,r,t,n){if(o.type==="line"){let i=n*2;e.strokeStyle=typeof o.fillStyle=="string"?o.fillStyle:"#000",e.lineWidth=o.lineWidth??2,e.setLineDash(o.dash&&o.dash.length>0?o.dash:[]),e.beginPath(),e.moveTo(r,t),e.lineTo(r+i,t),e.stroke(),e.setLineDash([]),e.fillStyle=o.fillStyle;let l=n*.3;o.marker==="square"?e.fillRect(r+i/2-l,t-l,l*2,l*2):(e.beginPath(),e.arc(r+i/2,t,l,0,Math.PI*2),e.fill());return}e.fillStyle=o.fillStyle,e.fillRect(r,t-n/2,n,n),e.strokeStyle=o.strokeStyle??"#000",e.lineWidth=1,e.strokeRect(r,t-n/2,n,n)}var Kt=36,Ee="'Noto Sans KR', sans-serif",hn=10,gn=12,Xt=30,mn=6;function Q(e,o,r,t="rect"){e.save(),e.font=`bold ${r}px ${Ee}`;let n=t==="line"?Kt:16,i=10,l=12,s=Math.max(...o.map(b=>n+i+e.measureText(b).width));return e.restore(),s+l*2+30}function Oe(e,o,r,t,n,i={}){let l=i.iconGap??hn,s=i.padding??gn,b=i.spacing??Xt,g=S=>i.font?un(i.font,S):`bold ${S}px ${Ee}`,p=Math.max(1,n-s*2);e.save();let f=S=>(e.font=g(S),o.map((D,A)=>r[A]+l+e.measureText(D).width)),h=t,y=f(h);for(;h>mt&&Math.max(...y)>p;)h=Math.max(mt,h-.5),y=f(h);e.restore();let a=[],m=[],c=0;for(let S=0;S<o.length;S++){let D=m.length===0?y[S]:b+y[S];m.length>0&&c+D>p&&(a.push(m),m=[],c=0),m.push({index:S,width:y[S]}),c+=m.length===1?y[S]:b+y[S]}m.length>0&&a.push(m);let d=h+8;return{fontSize:h,lineHeight:d,rowGap:mn,rows:a,boxH:a.length*d+(a.length-1)*mn+s*2}}function te(e,o,r,t,n="rect",i=50){if(o.length===0)return 0;let l=g=>g==="line"?Kt:16,s=o.map((g,p)=>l(Array.isArray(n)?n[p]??"rect":n)),{boxH:b}=Oe(e,o,s,r,t);return i+b+2}function ee({ctx:e,items:o,position:r,plotX:t,plotY:n,plotW:i,plotH:l,canvasW:s,canvasH:b,fontSize:g,bottomOffset:p=50,rightGap:f=20}){if(o.length===0)return 0;e.save(),e.font=`bold ${g}px ${Ee}`;let h=hn,y=gn,a=g+8,m=d=>d.type==="line"?Kt:16,c=o.map(d=>m(d)+h+e.measureText(d.label).width);if(r==="bottom"){let d=i,S=Oe(e,o.map(k=>k.label),o.map(m),g,d),D=S.boxH,A=t,v=Math.max(0,Math.min(n+l+p,b-D-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(A,v,d,D,0),e.fill(),e.stroke();for(let k=0;k<S.rows.length;k++){let P=S.rows[k],F=P.reduce((z,C)=>z+C.width,0)+Xt*(P.length-1),w=A+(d-F)/2,T=v+y+k*(S.lineHeight+S.rowGap)+S.lineHeight/2;for(let{index:z,width:C}of P){let M=o[z],L=m(M);bn(e,M,w,T,L),e.font=`bold ${S.fontSize}px ${Ee}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(M.label,w+L+h,T),w+=C+Xt}}return e.restore(),v+D}else{let D=Math.max(...c)+y*2,A=a*o.length+10*(o.length-1)+y*2,v=Math.max(0,Math.min(t+i+f,s-D-1)),k=Math.max(0,Math.min(n+l-A,b-A-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(v,k,D,A,0),e.fill(),e.stroke();let P=k+y+a/2;for(let F of o){let w=v+y,T=m(F);bn(e,F,w,P,T),e.font=`bold ${g}px ${Ee}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(F.label,w+T+h,P),P+=a+10}return e.restore(),0}}function bn(e,o,r,t,n){o.type==="rect"?(e.fillStyle=o.fillStyle,e.fillRect(r,t-n/2,n,n),o.bordered?(e.strokeStyle="#000",e.lineWidth=1,e.strokeRect(r,t-n/2,n,n)):o.strokeStyle&&(e.strokeStyle=o.strokeStyle,e.lineWidth=1,e.strokeRect(r,t-n/2,n,n))):o.type==="circle"?(e.fillStyle=o.fillStyle,e.beginPath(),e.arc(r+n/2,t,n/2.5,0,Math.PI*2),e.fill()):o.type==="line"&&(e.save(),e.strokeStyle=o.fillStyle,e.lineWidth=o.lineWidth??2.5,o.dash&&o.dash.length>0&&e.setLineDash(o.dash),e.beginPath(),e.moveTo(r,t),e.lineTo(r+n,t),e.stroke(),e.restore(),e.fillStyle=o.fillStyle,e.beginPath(),e.arc(r+n/2,t,3.5,0,Math.PI*2),e.fill())}function mo(e,o){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=o,t.height=o,t}let r=e.canvas.constructor;return new r(o,o)}function Te(e,o){let r=mo(e,10),t=r.getContext("2d");return t.fillStyle="#fff",t.fillRect(0,0,10,10),o(t,10),r}function bo(e,o){switch(o){case"diagonal":return Te(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(0,t),r.lineTo(t,0),r.moveTo(-t*.5,t*.5),r.lineTo(t*.5,-t*.5),r.moveTo(t*.5,t*1.5),r.lineTo(t*1.5,t*.5),r.stroke()});case"grid":return Te(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.2,r.beginPath(),r.moveTo(t/2,0),r.lineTo(t/2,t),r.moveTo(0,t/2),r.lineTo(t,t/2),r.stroke()});case"diagonalGrid":return Te(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.2,r.beginPath(),r.moveTo(0,0),r.lineTo(t,t),r.moveTo(t,0),r.lineTo(0,t),r.stroke()});case"dot":return Te(e,(r,t)=>{r.fillStyle="#000",r.beginPath(),r.arc(t/2,t/2,1.8,0,Math.PI*2),r.fill()});case"dotReverse":return Te(e,(r,t)=>{r.fillStyle="#333",r.fillRect(0,0,t,t),r.fillStyle="#fff",r.beginPath(),r.arc(t/2,t/2,1.8,0,Math.PI*2),r.fill()});case"vertical":return Te(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(t/2,0),r.lineTo(t/2,t),r.stroke()});case"horizontal":return Te(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(0,t/2),r.lineTo(t,t/2),r.stroke()})}}var He=["#333","#999","#666","#fff"],Ne=["diagonal","grid","diagonalGrid","dot","dotReverse","vertical","horizontal"],dn=new WeakMap;function pn(e,o){let r=dn.get(e);r||(r=new Map,dn.set(e,r));let t=r.get(o);return t||(t=e.createPattern(bo(e,o),"repeat"),r.set(o,t)),t}function ht(e,o){if(o<He.length)return He[o];let r=(o-He.length)%Ne.length;return pn(e,Ne[r])}var ut="pattern:";function gt(e,o){if(!o.startsWith(ut))return o;let r=o.slice(ut.length);return Ne.includes(r)?pn(e,r):o}function dt(e){if(e.startsWith(ut))return e.slice(ut.length)!=="dotReverse";let o=e.replace("#","");if(o.length!==3&&o.length!==6)return!1;let r=o.length===3?o.split("").map(l=>l+l).join(""):o,t=parseInt(r.slice(0,2),16),n=parseInt(r.slice(2,4),16),i=parseInt(r.slice(4,6),16);return[t,n,i].some(Number.isNaN)?!1:(t*299+n*587+i*114)/1e3>180}function ce(e){return e>=3&&!uo(e)}function uo(e){if(e<He.length)return!1;let o=(e-He.length)%Ne.length;return Ne[o]==="dotReverse"}function _e(e,o,r,t,n){$(e,o,r);let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"&&!t.insideLegend?Q(e,t.seriesLabels,n.fontSize.dataLabel*.85+5):0,b=t.barDirection==="vertical",g=n.fontFamily,p=n.customFont,f=t.categories.length,h=t.seriesLabels.length,y=!b&&!!t.groups&&t.groups.length>0,a=0,m=0,c=0;(y||t.unitAdjacent||t.insideLegend)&&(e.save(),e.font=I(n.fontSize.tick,g,p,"bold"),y&&(a=oe(e,t.groups.map(L=>L.label)),m=oe(e,t.categories.map(L=>L.label))),e.font=I(n.fontSize.axisLabel,g,p,"bold"),c=e.measureText(t.unit).width,e.restore());let d=b?60+s:t.unitAdjacent?40+c:160+s,S=b?130:y?20+a+14+m+12:100,D=i&&l==="bottom"&&!t.insideLegend?te(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-S-d):0,A={top:n.title?100:50,right:d,bottom:(()=>{let L=b?70:60;return i&&l==="bottom"&&!t.insideLegend&&(L+=60),L=Math.max(L,D),n.source&&(L+=30),L+=n.footnotes.filter(B=>B.trim()).length*22,L})(),left:S},v=A.left,k=A.top,P=o-A.left-A.right,F=r-A.top-A.bottom,w=[0];for(let L of t.categories)t.stacked?w.push(L.values.reduce((B,R)=>B+R,0)):w.push(...L.values);w.length<=1&&w.push(100);let T=t.yRange.auto?J(w,6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};if(t.yRange.auto&&t.fitMax){let L=Math.max(...w);T={...T,max:L}}let z=L=>{let B=t.seriesFills?.[L];return B==null?ht(e,L):gt(e,B)},C=[],M=(L,B,R,W)=>{t.insideLegend&&C.push({x0:L,y0:B,x1:L+R,y1:B+W})};if(e.strokeStyle="#000",e.lineWidth=2,b){e.beginPath(),e.moveTo(v,k),e.lineTo(v,k+F),e.lineTo(v+P,k+F),e.lineTo(v+P,k),e.lineTo(v,k),e.stroke(),ge({ctx:e,padding:A,width:o,height:r,min:T.min,max:T.max,step:T.step,label:t.unit,side:"left",fontFamily:g,customFont:p,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0}),e.save(),e.beginPath(),e.rect(v,k,P,F),e.clip();let L=P/f,B=E=>k+F-(E-T.min)/(T.max-T.min)*F,R=t.zeroBaseline?0:T.min,W=B(R);if(t.stacked){let E=Math.min(L*.5,80);for(let _=0;_<f;_++){let O=v+L*_+L/2,H=0;for(let N=0;N<h;N++){let U=t.categories[_].values[N]||0,X=Math.min(B(H+U),B(H)),q=Math.abs(B(H)-B(H+U));e.fillStyle=z(N),e.fillRect(O-E/2,X,E,q),M(O-E/2,X,E,q),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(O-E/2,X,E,q),n.showDataLabels&&q>n.fontSize.dataLabel&&(e.fillStyle=ce(N)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,g,p,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(U),O,X+q/2)),H+=U}}}else{let E=Math.min(L*.7,h*60),_=E/h;for(let O=0;O<f;O++){let H=v+L*O+(L-E)/2;for(let N=0;N<h;N++){let U=t.categories[O].values[N]||0,X=Math.min(B(U),W),q=Math.abs(B(U)-W),V=H+_*N;e.fillStyle=z(N),e.fillRect(V,X,_,q),M(V,X,_,q),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(V,X,_,q),n.showDataLabels&&q>n.fontSize.dataLabel&&(e.fillStyle=ce(N)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,g,p,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(U),V+_/2,X-4))}}}e.restore(),t.zeroBaseline&&W>k&&W<k+F&&(e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(v,W),e.lineTo(v+P,W),e.stroke());let u=t.categoryLabelAtBaseline?W+6:k+F+12;e.fillStyle="#000",e.font=I(n.fontSize.tick,g,p,"bold"),e.textAlign="center",e.textBaseline="top";let G=ie(L,oe(e,t.categories.map(E=>E.label)));for(let E=0;E<f;E++){if(E%G!==0)continue;let _=v+L*E+L/2;e.fillText(t.categories[E].label,_,u)}}else{e.beginPath(),e.moveTo(v,k),e.lineTo(v,k+F),e.lineTo(v+P,k+F),e.lineTo(v+P,k),e.lineTo(v,k),e.stroke();let L=[];for(let O=T.min;O<T.max-T.step*1e-9;O+=T.step)L.push(Math.abs(O)<1e-9?0:O);(L.length===0||Math.abs(L[L.length-1]-T.max)>1e-9)&&L.push(T.max),e.font=I(n.fontSize.tick,g,p,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";let B=0;for(let O=0;O<L.length;O++){let H=L[O],N=v+(H-T.min)/(T.max-T.min)*P;e.lineWidth=1,e.strokeStyle="#000",e.beginPath(),e.moveTo(N,k+F),e.lineTo(N,k+F+5),e.stroke(),e.fillText(cn(H),N,k+F+10),O===L.length-1&&(B=e.measureText(cn(H)).width/2),O>0&&O<L.length-1&&(e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(N,k),e.lineTo(N,k+F),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,g,p,"bold"),e.fillStyle="#000",e.textAlign="left",e.textBaseline="top";let R=t.unitAdjacent?v+P+B+2:v+P+30;e.fillText(t.unit,R,k+F+10),e.save(),e.beginPath(),e.rect(v,k,P,F),e.clip();let W=F/f,u=y?W*.73:W,G=[];if(y){let O=0;for(let H of t.groups){let N=k+W*O+(W-u)*H.span/2;for(let U=0;U<H.span;U++)G.push(N+u*(U+.5));O+=H.span}}for(let O=G.length;O<f;O++)G.push(k+W*O+W/2);let E=O=>v+(O-T.min)/(T.max-T.min)*P;if(t.stacked){let O=Math.min(y?u*.74:W*.5,80);for(let H=0;H<f;H++){let N=G[H],U=0;for(let X=0;X<h;X++){let q=t.categories[H].values[X]||0,V=E(U),ne=E(U+q)-V;e.fillStyle=z(X),e.fillRect(V,N-O/2,ne,O),M(V,N-O/2,ne,O),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(V,N-O/2,ne,O),n.showDataLabels&&ne>n.fontSize.dataLabel*2&&(e.fillStyle=ce(X)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,g,p,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(q),V+ne/2,N)),U+=q}}}else{let O=Math.min(W*.7,h*60),H=O/h;for(let N=0;N<f;N++){let U=G[N]-O/2;for(let X=0;X<h;X++){let q=t.categories[N].values[X]||0,V=E(T.min),ne=E(q)-V,me=U+H*X;e.fillStyle=z(X),e.fillRect(V,me,ne,H),M(V,me,ne,H),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(V,me,ne,H),n.showDataLabels&&ne>n.fontSize.dataLabel*2&&(e.fillStyle=ce(X)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,g,p,"bold"),e.textAlign="left",e.textBaseline="middle",e.fillText(String(q),V+ne+4,me+H/2))}}}e.restore();let _=y?v-12:v-10;for(let O=0;O<f;O++)e.fillStyle="#000",e.font=I(n.fontSize.tick,g,p,"bold"),e.textAlign="right",e.textBaseline="middle",e.fillText(t.categories[O].label,_,G[O]);if(y){let O=0;for(let H of t.groups){let N=k+W*O+W*H.span/2;e.fillText(H.label,_-m-14,N),O+=H.span}}}if(j({ctx:e,plotX:v,plotW:P,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i&&t.insideLegend)bt({ctx:e,items:t.seriesLabels.map((L,B)=>({type:"rect",fillStyle:z(B),label:L})),corner:t.insideLegend,plotX:v,plotY:k,plotW:P,plotH:F,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.9,font:I(n.fontSize.dataLabel*.9,g,p,"bold"),avoid:C});else if(i){let L=t.seriesLabels.map((B,R)=>({type:"rect",fillStyle:z(R),bordered:t.seriesFills?.[R]?dt(t.seriesFills[R]):ce(R),label:B}));ee({ctx:e,items:L,position:l,plotX:v,plotY:k,plotW:P,plotH:F,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}K({ctx:e,plotX:v,plotW:P,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function cn(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}function pt(){return{title:"",source:"",footnotes:[""],fontFamily:"serif",customFont:"",fontSize:{title:36,axisLabel:28,tick:26,dataLabel:22},showDataLabels:!1,showLegend:!0,legendPosition:"bottom",legendLabel1:"",legendLabel2:""}}function ct(){return{baseMonths:Array.from({length:12},()=>({temp:0,precip:0})),months:Array.from({length:12},()=>({temp:0,precip:0})),monthInterval:12,tempLabel:"(\xB0C)",precipLabel:"(mm)",tempRange:{min:-10,max:10,auto:!0},precipRange:{min:-200,max:200,auto:!0}}}function yt(){return{baseTemp:0,basePrecip:0,regions:[{label:"A",precip:0,temp:0},{label:"B",precip:0,temp:0},{label:"C",precip:0,temp:0}],precipDiffLabel:"\uAC15\uC218\uB7C9 \uCC28\uC774",tempDiffLabel:"\uAE30\uC628 \uCC28\uC774",precipUnit:"(mm)",tempUnit:"(\xB0C)",precipRange:{min:-200,max:200,auto:!0},tempRange:{min:-10,max:10,auto:!0}}}function St(){return{months:Array.from({length:12},()=>({temp:0,precip:0})),monthInterval:12,tempLabel:"(\xB0C)",precipLabel:"(mm)",tempRange:{min:-10,max:40,auto:!0},precipRange:{min:0,max:400,auto:!0}}}var ve=["0-4","5-9","10-14","15-19","20-24","25-29","30-34","35-39","40-44","45-49","50-54","55-59","60-64","65-69","70-74","75-79","80+"];function Lt(){return{ages:Array.from({length:17},()=>({male:0,female:0})),unit:"percent",maleLabel:"\uB0A8",femaleLabel:"\uC5EC",axisLabel:"(%)",range:{max:10,auto:!0},ageLabelSide:"center"}}function Tt(){return{points:[{a:33,b:33,c:34,label:"(\uAC00)"}],axisLabels:["A","B","C"],gridInterval:20}}function vt(){return{displayMode:"bar",barDirection:"vertical",categories:[{label:"(\uAC00)",values:[40,30,30]},{label:"(\uB098)",values:[50,25,25]},{label:"(\uB2E4)",values:[20,40,40]}],seriesLabels:["\uD56D\uBAA91","\uD56D\uBAA92","\uD56D\uBAA93"],unit:"(%)"}}function Dt(){return{barDirection:"vertical",stacked:!1,categories:[{label:"(\uAC00)",values:[30,50]},{label:"(\uB098)",values:[45,35]},{label:"(\uB2E4)",values:[60,20]}],seriesLabels:["\uD56D\uBAA91","\uD56D\uBAA92"],unit:"",yRange:{min:0,max:100,auto:!0}}}function kt(){return{mode:"normal",bubbleLegendPosition:"bottom-right",points:[{x:10,y:25,size:50,label:"A"},{x:25,y:40,size:80,label:"B"},{x:40,y:15,size:30,label:"C"},{x:55,y:60,size:100,label:"D"}],xLabel:"X\uCD95",yLabel:"Y\uCD95",xUnit:"",yUnit:"",xRange:{min:0,max:100,auto:!0},yRange:{min:0,max:100,auto:!0},showBubble:!0,bubbleScale:30,quadrantLabels:["(\uAC00)","(\uB098)","(\uB2E4)","(\uB77C)"]}}var Mt=["1","2","3","4","5","6","7","8","9","10","11","12"],Rt=["J","F","M","A","M","J","J","A","S","O","N","D"];function Ct(){return{series:[{label:"(\uAC00)",months:Array.from({length:12},()=>({temp:0,precip:0}))}],mode:"both",monthLabelStyle:"number",xUnit:"(\xB0C)",yUnit:"(mm)",xRange:{min:-10,max:40,auto:!0},yRange:{min:0,max:400,auto:!0}}}function At(){return{points:[{x:0,y:1,z:1,label:"\u3131",labelDx:0,labelDy:0},{x:0,y:0,z:0,label:"\u3134",labelDx:0,labelDy:0},{x:1,y:0,z:1,label:"\u3137",labelDx:0,labelDy:0}],xAxis:{name:"X\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}},yAxis:{name:"Y\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}},zAxis:{name:"Z\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}}}}function Pt(){return{axisLabels:["\uCD951","\uCD952","\uCD953","\uCD954","\uCD955"],series:[{label:"(\uAC00)",values:[0,0,0,0,0]}],maxValue:100,autoMax:!0,gridSteps:5,showFill:!1}}var wt=["circle","square","triangle","diamond"];function zt(){return{categories:[{label:"A",values:[17]},{label:"B",values:[11]},{label:"C",values:[9]},{label:"D",values:[25]}],seriesLabels:["\uD56D\uBAA91"],unit:"",dotRadius:6,yRange:{min:0,max:100,auto:!0}}}var ye={solid:[],dashed:[10,6],dotted:[2,5],dashdot:[12,5,3,5]},De=["solid","dashed","dotted","dashdot"],Ue=["circle","square","triangle","diamond"];function Wt(){return{series:[{label:"(\uAC00)",values:Array.from({length:12},(e,o)=>o*2)}],xLabels:["1","2","3","4","5","6","7","8","9","10","11","12"],xUnit:"(\uC6D4)",yUnit:"",yRange:{min:0,max:100,auto:!0},labelPlacement:"lineEnd",showMarkers:!0}}function Gt(){return{names:["(\uAC00)","(\uB098)","(\uB2E4)"],values:[[0,0,0],[559,0,0],[2648,2210,0]],unit:"(\uB2E8\uC704 : km)"}}function Ft(){return{cornerLabel:"\uAD6C\uBD84",columns:["(\uAC00)","(\uB098)","(\uB2E4)","(\uB77C)"],rows:[{label:"\uAE30\uC628\uC758 \uC5F0\uAD50\uCC28",unit:"(\u2103)",values:[40.5,29.9,3.8,3.8]},{label:"\uCD5C\uD55C\uC6D4 \uD3C9\uADE0 \uAE30\uC628",unit:"(\u2103)",values:[-21.4,-24.4,24.6,19.5]},{label:"1\uC6D4 \uAC15\uC218\uB7C9",unit:"(mm)",values:[1.8,4.6,28.8,206.8]}]}}function Bt(){return{cells:[{label:"\uC911\uAD6D",value:50},{label:"\uBBF8\uAD6D",value:20},{label:"\uC778\uB3C4",value:12},{label:"\uAE30\uD0C0",value:18}]}}function ho(e,o,r,t,n){switch(e.beginPath(),o){case"circle":e.arc(r,t,n,0,Math.PI*2);break;case"square":e.rect(r-n,t-n,n*2,n*2);break;case"triangle":e.moveTo(r,t-n),e.lineTo(r+n,t+n),e.lineTo(r-n,t+n),e.closePath();break;case"diamond":e.moveTo(r,t-n),e.lineTo(r+n,t),e.lineTo(r,t+n),e.lineTo(r-n,t),e.closePath();break}e.fill()}function $e(e,o,r,t,n){$(e,o,r);let i=n.fontFamily,l=n.customFont,s=t.categories.length,b=t.seriesLabels.length,g=t.seriesMarkers??wt,p=n.showLegend&&b>1,f=n.legendPosition,h=p&&f==="right"?Q(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,"circle"):0,y=p&&f==="bottom"?te(e,t.seriesLabels,n.fontSize.dataLabel*.85,o-130-(60+h),"circle"):0,a={top:n.title?100:50,right:60+h,bottom:(()=>{let w=70;return p&&f==="bottom"&&(w+=60),w=Math.max(w,y),n.source&&(w+=30),w+=n.footnotes.filter(T=>T.trim()).length*22,w})(),left:130},m=a.left,c=a.top,d=o-a.left-a.right,S=r-a.top-a.bottom,D=[0];for(let w of t.categories)D.push(...w.values);D.length<=1&&D.push(100);let A=t.yRange.auto?J(D,6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(m,c),e.lineTo(m,c+S),e.lineTo(m+d,c+S),e.lineTo(m+d,c),e.lineTo(m,c),e.stroke(),ge({ctx:e,padding:a,width:o,height:r,min:A.min,max:A.max,step:A.step,label:t.unit,side:"left",fontFamily:i,customFont:l,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0});let v=t.dotRadius+1;e.save(),e.beginPath(),e.rect(m-v,c-v,d+v*2,S+v*2),e.clip();let k=d/s,P=w=>c+S-(w-A.min)/(A.max-A.min)*S,F=b>1?Math.min(k*.6,b*24)/b:0;for(let w=0;w<s;w++){let T=m+k*w+k/2;for(let z=0;z<b;z++){let C=t.categories[w].values[z];if(C===void 0||Number.isNaN(C))continue;let M=T+(z-(b-1)/2)*F,L=P(C);e.fillStyle="#000",ho(e,g[z%g.length],M,L,t.dotRadius),n.showDataLabels&&(e.font=I(n.fontSize.dataLabel*.8,i,l,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(C),M,L-t.dotRadius-4))}}if(e.restore(),t.zeroBaseline){let w=P(0);w>c&&w<c+S&&(e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(m,w),e.lineTo(m+d,w),e.stroke())}e.fillStyle="#000",e.font=I(n.fontSize.tick,i,l,"bold"),e.textAlign="center",e.textBaseline="top";for(let w=0;w<s;w++){let T=m+k*w+k/2;e.fillText(t.categories[w].label,T,c+S+12)}if(n.title&&j({ctx:e,plotX:m,plotW:d,title:n.title,fontSize:n.fontSize.title}),p){let w=t.seriesLabels.map(T=>({type:"circle",fillStyle:"#000",label:T}));ee({ctx:e,items:w,position:f,plotX:m,plotY:c,plotW:d,plotH:S,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85})}K({ctx:e,plotX:m,plotW:d,height:r,canvasWidth:o,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel*.85})}function go(e,o,r,t,n,i){switch(e.beginPath(),o){case"circle":e.arc(r,t,n,0,Math.PI*2);break;case"square":e.rect(r-n,t-n,n*2,n*2);break;case"triangle":e.moveTo(r,t-n),e.lineTo(r+n,t+n),e.lineTo(r-n,t+n),e.closePath();break;case"diamond":e.moveTo(r,t-n),e.lineTo(r+n,t),e.lineTo(r,t+n),e.lineTo(r-n,t),e.closePath();break}e.fillStyle=i?"#fff":"#000",e.fill(),e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.stroke()}function Ye(e,o,r,t,n){$(e,o,r);let i=n.fontFamily,l=n.customFont,s=t.xLabels.length,b=t.labelPlacement==="legend"&&n.showLegend,g=n.legendPosition,p=b&&g==="right"?Q(e,t.series.map(C=>C.label),n.fontSize.dataLabel*.85+5,"line"):0;e.font=I(n.fontSize.dataLabel,i,l,"bold");let f=t.labelPlacement==="lineEnd"?oe(e,t.series.map(C=>C.label))+16:0;e.font=I(n.fontSize.tick,i,l,"bold");let h=t.xUnit?e.measureText(t.xUnit).width+e.measureText(t.xLabels[s-1]??"").width/2+12:0,y=24+p+Math.max(f,h),a=b&&g==="bottom"&&!t.insideLegend?te(e,t.series.map(C=>C.label),n.fontSize.dataLabel*.85,o-130-y,"line"):0,m={top:n.title?100:50,right:y,bottom:(()=>{let C=70;return b&&g==="bottom"&&!t.insideLegend&&(C+=60),C=Math.max(C,a),n.source&&(C+=30),C+=n.footnotes.filter(M=>M.trim()).length*22,C})(),left:130},c=m.left,d=m.top,S=o-m.left-m.right,D=r-m.top-m.bottom,A=t.stacked?t.xLabels.map((C,M)=>t.series.reduce((L,B)=>{let R=B.values[M];return L+(R!==null&&Number.isFinite(R)?R:0)},0)):t.series.flatMap(C=>C.values).filter(C=>C!==null&&Number.isFinite(C)),v=t.yRange.auto?J(A.length>0?A:[0,100],6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};e.strokeStyle="#000",e.lineWidth=2,e.setLineDash([]),e.beginPath(),e.moveTo(c,d),e.lineTo(c,d+D),e.lineTo(c+S,d+D),e.lineTo(c+S,d),e.lineTo(c,d),e.stroke(),ge({ctx:e,padding:m,width:o,height:r,min:v.min,max:v.max,step:v.step,label:t.yUnit,side:"left",fontFamily:i,customFont:l,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0});let k=s>1?S/(s-1):0,P=C=>c+k*C,F=C=>d+D-(C-v.min)/(v.max-v.min)*D;t.zeroBaseline&&v.min<0&&v.max>0&&(e.save(),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(c,F(0)),e.lineTo(c+S,F(0)),e.stroke(),e.restore());let w=[],T=[];{let C=t.xLabels.map(()=>0);for(let M of t.series){let L=[...C],B=M.values.map((R,W)=>R===null||!Number.isFinite(R)?null:t.stacked?(C[W]+=R,C[W]):R);w.push(B),T.push(L)}}if(t.series.forEach((C,M)=>{if(!C.areaFill)return;let L=w[M],B=T[M];e.save(),e.fillStyle=C.areaFill;let R=0;for(;R<L.length;){if(L[R]===null){R++;continue}let W=R;for(;W+1<L.length&&L[W+1]!==null;)W++;e.beginPath();for(let u=R;u<=W;u++)e.lineTo(P(u),F(L[u]));for(let u=W;u>=R;u--)e.lineTo(P(u),F(t.stacked?B[u]:v.min));e.closePath(),e.fill(),R=W+1}e.restore()}),t.series.forEach((C,M)=>{let L=C.lineStyle??De[M%De.length];e.save(),e.strokeStyle="#000",e.lineWidth=2,e.setLineDash(ye[L]),e.beginPath();let B=!1;w[M].forEach((R,W)=>{if(R===null){B=!1;return}let u=P(W),G=F(R);B?e.lineTo(u,G):(e.moveTo(u,G),B=!0)}),e.stroke(),e.restore()}),t.showMarkers&&t.series.forEach((C,M)=>{let L=C.marker??Ue[M%Ue.length];w[M].forEach((B,R)=>{B!==null&&go(e,L,P(R),F(B),4.5,C.hollowMarker??!1)})}),t.labelPlacement==="lineEnd"){e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,i,l,"bold");let C=new we,M=n.fontSize.dataLabel*1.1,L=c+S+10,B={left:L,right:o-4,top:4,bottom:r-4};t.series.forEach((R,W)=>{let u=w[W],G=-1;for(let E=u.length-1;E>=0;E--)if(u[E]!==null){G=E;break}G<0||C.placeInColumn(e,R.label,L,F(u[G])-M/2,{lineHeight:M,bounds:B})})}e.fillStyle="#000",e.font=I(n.fontSize.tick,i,l,"bold"),e.textAlign="center",e.textBaseline="top";let z=ie(k,oe(e,t.xLabels));if(t.xLabels.forEach((C,M)=>{M%z===0&&e.fillText(C,P(M),d+D+10)}),t.xUnit){let C=e.measureText(t.xLabels[s-1]??"").width/2;e.textAlign="left",e.fillText(t.xUnit,c+S+C+6,d+D+10)}if(n.title&&j({ctx:e,plotX:c,plotW:S,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),b&&t.insideLegend){e.save(),e.font=I(n.fontSize.dataLabel*.8,i,l,"bold");let C=n.fontSize.dataLabel*1.15,M=C*.75,L=M+6+oe(e,t.series.map(R=>R.label))+10,B=d+6;for(let R of t.series)e.fillStyle="#fff",e.fillRect(c+6,B,L,C),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([]),e.strokeRect(c+6,B,L,C),e.fillStyle=R.areaFill??"#000",e.fillRect(c+10,B+(C-M)/2,M,M),e.strokeRect(c+10,B+(C-M)/2,M,M),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(R.label,c+10+M+5,B+C/2),B+=C;e.restore()}else if(b){let C=t.series.map((M,L)=>({type:"line",fillStyle:"#000",strokeStyle:"#000",label:M.label,dash:ye[M.lineStyle??De[L%De.length]]}));ee({ctx:e,items:C,position:g,plotX:c,plotY:d,plotW:S,plotH:D,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85})}K({ctx:e,plotX:c,plotW:S,height:r,canvasWidth:o,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel*.85})}var po="#d9d9d9",jt=.2,yn=1.7,Sn=.75;function Xe(e,o,r,t,n){$(e,o,r);let i=t.names.length;if(i===0)return;let l=n.fontFamily,s=n.customFont,b=n.fontSize.tick;e.font=I(b,l,s,"bold");let p=Math.max(...t.names.map(z=>e.measureText(z).width),...co(t).map(z=>e.measureText(Ln(z,t.groupThousands)).width))+b*Sn*2,f=t.unit?n.fontSize.dataLabel*1.6:0,h=n.footnotes.filter(z=>z.trim()).length,y=(h>0?h*22+n.fontSize.dataLabel+12:0)+(n.source?n.fontSize.dataLabel+4:0),a=n.title?100:30,m=(z,C)=>z*i+C*(i-1),c=Math.min(1,(o-20)/m(p,p*jt),(r-a-f-y-10)/m(b*yn,b*jt)),d=b*c,S=p*c,D=b*yn*c,A=b*jt*c,v=d*Sn,k=m(S,A),P=m(D,A),F=Math.max(10,(o-k)/2),w=a+f+Math.max(0,(r-a-f-y-P)/2),T=Math.max(a+f,Math.min(w,r-y-P));t.unit&&(e.font=I(n.fontSize.dataLabel,l,s,"bold"),e.fillStyle="#000",e.textAlign="right",e.textBaseline="bottom",e.fillText(t.unit,F+k,T-10)),e.textBaseline="middle";for(let z=0;z<i;z++){let C=T+(D+A)*z;for(let M=0;M<=z;M++){let L=F+(S+A)*M,B=M===z;if(e.fillStyle=B?t.nameFill??po:"#fff",e.fillRect(L,C,S,D),e.strokeStyle="#000",e.lineWidth=1.2,e.strokeRect(L,C,S,D),e.fillStyle="#000",B){let R=t.nameIsSymbol&&!t.nameIsSymbol[z]?"sans":l;e.font=I(d,R,s,"bold"),e.textAlign="center",e.fillText(t.names[z],L+S/2,C+D/2)}else e.font=I(d,l,s,"bold"),e.textAlign="right",e.fillText(Ln(t.values[z]?.[M]??0,t.groupThousands),L+S-v,C+D/2)}}j({ctx:e,plotX:F,plotW:k,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:F,plotW:k,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function co(e){let o=[];for(let r=0;r<e.names.length;r++)for(let t=0;t<r;t++)o.push(e.values[r]?.[t]??0);return o}function Ln(e,o=!0){let r=Number.isInteger(e)?e:Math.round(e);return o?String(r).replace(/\B(?=(\d{3})+(?!\d))/g,","):String(r)}var yo="#d9d9d9",So=1.7,Vt=.75,Jt=.8;function Ke(e,o,r,t,n){$(e,o,r);let i=t.columns.length,l=t.rows.length;if(i===0||l===0)return;let s=n.fontFamily,b=n.customFont,g=n.fontSize.tick;e.font=I(g,s,b,"bold");let p=Math.max(e.measureText(t.cornerLabel).width,...t.rows.map(L=>Lo(e,L,g,s,b))),f=Math.max(...t.columns.map(L=>e.measureText(L).width),...t.rows.flatMap(L=>L.values.map(B=>e.measureText(Tn(B,L.decimals,t.groupThousands)).width))),h=p+g*Vt*2,y=f+g*Vt*2,a=g*So,m=n.title?100:30,c=n.footnotes.filter(L=>L.trim()).length,d=(c>0?c*22+n.fontSize.dataLabel+12:0)+(n.source?n.fontSize.dataLabel+4:0),S=Math.min(1,(o-20)/(h+y*i),(r-m-d-10)/(a*(l+1))),D=g*S,A=h*S,v=y*S,k=a*S,P=D*Vt,F=A+v*i,w=k*(l+1),T=Math.max(10,(o-F)/2),z=m+Math.max(0,(r-m-d-w)/2),C=Math.max(m,Math.min(z,r-d-w)),M=L=>T+A+v*L;e.fillStyle=t.headerFill??yo,e.fillRect(T,C,F,k),e.fillStyle="#000",e.textBaseline="middle",e.textAlign="center",e.font=I(D,s,b,"bold"),e.fillText(t.cornerLabel,T+A/2,C+k/2,A-P*2),t.columns.forEach((L,B)=>{let R=t.columnIsSymbol&&!t.columnIsSymbol[B]?"sans":s;e.font=I(D,R,b,"bold"),e.fillText(L,M(B)+v/2,C+k/2,v-P*2)}),t.rows.forEach((L,B)=>{let R=C+k*(B+1);To(e,L,T+A/2,R+k/2,D,s,b),e.font=I(D,s,b,"bold"),e.textAlign="right";for(let W=0;W<i;W++){let u=L.values[W];u!==void 0&&e.fillText(Tn(u,L.decimals,t.groupThousands),M(W)+v-P,R+k/2,v-P*2)}e.textAlign="center"}),e.strokeStyle="#000",e.lineWidth=1;for(let L=1;L<=l;L++){let B=C+k*L;qt(e,T,B,T+F,B)}qt(e,T+A,C,T+A,C+w);for(let L=1;L<i;L++)qt(e,M(L),C,M(L),C+w);e.lineWidth=2,e.strokeRect(T,C,F,w),j({ctx:e,plotX:T,plotW:F,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:T,plotW:F,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function qt(e,o,r,t,n){e.beginPath(),e.moveTo(o,r),e.lineTo(t,n),e.stroke()}function Lo(e,o,r,t,n){e.font=I(r,t,n,"bold");let i=e.measureText(o.label).width;return o.unit?(e.font=I(r*Jt,t,n,"bold"),i+e.measureText(o.unit).width):i}function To(e,o,r,t,n,i,l){e.fillStyle="#000",e.textBaseline="middle",e.font=I(n,i,l,"bold");let s=e.measureText(o.label).width;if(!o.unit){e.textAlign="center",e.fillText(o.label,r,t);return}e.font=I(n*Jt,i,l,"bold");let b=e.measureText(o.unit).width,g=r-(s+b)/2;e.textAlign="left",e.font=I(n,i,l,"bold"),e.fillText(o.label,g,t),e.font=I(n*Jt,i,l,"bold"),e.fillText(o.unit,g+s,t),e.textAlign="center"}function Tn(e,o=1,r=!0){if(!Number.isFinite(e))return"-";let t=e.toFixed(o);if(!r)return t;let[n,i]=t.split("."),l=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return i?`${l}.${i}`:l}var vo=.4,Do=34,kn=.4,ko=4;function vn(e,o,r){if(e.length===0||o<=0||r<=0)return 1/0;let t=Math.max(...e),n=Math.min(...e);if(n<=0)return 1/0;let i=o*o,l=r*r;return Math.max(l*t/i,i/(l*n))}var Dn=e=>Number.isFinite(e)&&e>0?e:0;function Mo(e,o){let r=e.map(()=>({x:o.x,y:o.y,w:0,h:0})),t=e.reduce((s,b)=>s+Dn(b),0);if(e.length===0||t<=0||o.w<=0||o.h<=0)return r;let n=e.map(s=>Dn(s)/t*o.w*o.h),i={...o},l=0;for(;l<n.length;){let s=Math.min(i.w,i.h);if(s<=0)break;let b=0,g=0;for(;l+b<n.length;){let a=n[l+b],m=n.slice(l,l+b);if(b>0&&(g<=0||vn([...m,a],g+a,s)>vn(m,g,s)))break;g+=a,b++}let p=n.slice(l,l+b),f=g/s,h=i.w>=i.h,y=0;for(let a=0;a<p.length;a++){let m=f>0?p[a]/f:0;r[l+a]=h?{x:i.x,y:i.y+y,w:f,h:m}:{x:i.x+y,y:i.y,w:m,h:f},y+=m}i=h?{x:i.x+f,y:i.y,w:Math.max(0,i.w-f),h:i.h}:{x:i.x,y:i.y+f,w:i.w,h:Math.max(0,i.h-f)},l+=b}return r}function Ro(e,o){let r=Math.min(Math.max(o,1),e.length);if(r<=1)return[e];let t=Math.ceil(e.length/r),n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}function Co(e,o,r,t,n,i=ko){let l=Math.max(1,Math.min(i,o.length)),s=g=>{let p=Ro(o,g),f=Math.max(...p.map(a=>e.measureText(a).width)),h=f>0?r/f:1/0,y=t/(p.length*n*1.2);return{lines:p,scale:Math.min(1,h,y)}},b=s(1);for(let g=2;g<=l;g++){let p=s(g);p.scale>b.scale&&(b=p)}return b}function Ao(e,o,r){return e.w<o||e.h<r*kn*1.2}function Po(e,o=kn){return e.scale<o}function wo(e,o){return e*o.scale}function je(e,o,r,t,n){if($(e,o,r),t.cells.length===0)return;let i=n.title?100:30,l=n.footnotes.filter(a=>a.trim()).length,s=!!n.source||!!t.reserveSourceSpace,b=(l>0?l*22+n.fontSize.dataLabel+12:0)+(s?n.fontSize.dataLabel+4:0),g={x:20,y:i,w:Math.max(0,o-40),h:Math.max(0,r-i-b-10)},p=Mo(t.cells.map(a=>a.value),g),f=t.labelFontSize??n.fontSize.tick,h=t.minLabelWidth??Do,y=f*vo;e.strokeStyle="#000",e.lineWidth=1,p.forEach(a=>{a.w<=0||a.h<=0||e.strokeRect(a.x,a.y,a.w,a.h)}),e.fillStyle="#000",e.textAlign="center",e.textBaseline="middle",e.font=I(f,n.fontFamily,n.customFont),p.forEach((a,m)=>{if(Ao(a,h,f))return;let c=a.w-y*2;e.font=I(f,n.fontFamily,n.customFont);let d=Co(e,t.cells[m].label,c,a.h,f);if(Po(d))return;let S=wo(f,d);S!==f&&(e.font=I(S,n.fontFamily,n.customFont));let D=a.y+a.h/2-(d.lines.length-1)*S*1.2/2;d.lines.forEach((A,v)=>{e.fillText(A,a.x+a.w/2,D+v*S*1.2,c)}),S!==f&&(e.font=I(f,n.fontFamily,n.customFont))}),e.lineWidth=2,e.strokeRect(g.x,g.y,g.w,g.h),j({ctx:e,plotX:g.x,plotW:g.w,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:g.x,plotW:g.w,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var Mn=["1","2","3","4","5","6","7","8","9","10","11","12"],Rn={12:[0,1,2,3,4,5,6,7,8,9,10,11],4:[2,5,8,11],2:[0,6]};function Ve(e,o,r,t,n){$(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipLabel,n.legendLabel2||t.tempLabel],b=i&&l==="right"?Q(e,s,n.fontSize.dataLabel*.85+5):0,g=i&&l==="bottom"?te(e,s,n.fontSize.dataLabel*.85+5,o-130-(130+b),["rect",t.monthInterval===12?"line":"circle"]):0,p={top:n.title?100:50,right:130+b,bottom:(()=>{let T=60;return i&&l==="bottom"&&(T+=70),T=Math.max(T,g),n.source&&(T+=30),T+=n.footnotes.filter(z=>z.trim()).length*22,T})(),left:130},f=p.left,h=p.top,y=o-p.left-p.right,a=r-p.top-p.bottom,m=t.months.map(T=>T.temp),c=t.months.map(T=>T.precip),d=t.tempRange.auto?J(m,6):{min:t.tempRange.min,max:t.tempRange.max,step:t.tempRange.step||Math.max(1,Math.round((t.tempRange.max-t.tempRange.min)/6))},S=t.precipRange.auto?J(c.filter(T=>T>0).length>0?c:[0,100],6):{min:t.precipRange.min,max:t.precipRange.max,step:t.precipRange.step||Math.max(1,Math.round((t.precipRange.max-t.precipRange.min)/6))};S.min<0&&(S.min=0);let D=n.fontFamily,A=n.customFont,v=Rn[t.monthInterval]??Rn[12];if(ge({ctx:e,padding:p,width:o,height:r,min:d.min,max:d.max,step:d.step,label:t.tempLabel,side:"left",fontFamily:D,customFont:A,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0}),ge({ctx:e,padding:p,width:o,height:r,min:S.min,max:S.max,step:S.step,label:t.precipLabel,side:"right",fontFamily:D,customFont:A,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel}),t.monthInterval===12)Yt({ctx:e,padding:p,width:o,height:r,labels:Mn,indices:v,fontFamily:D,customFont:A,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel});else{let T=v.map(z=>Mn[z]);Yt({ctx:e,padding:p,width:o,height:r,labels:T,fontFamily:D,customFont:A,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel})}let k=t.monthInterval===12?12:v.length,P=y/k,F=P*.55,w=T=>f+P*T+P/2;e.fillStyle="#AAAAAA";for(let T=0;T<v.length;T++){let z=v[T],C=t.months[z].precip;if(C<=0)continue;let M=(C-S.min)/(S.max-S.min)*a,B=(t.monthInterval===12?w(z):w(T))-F/2,R=h+a-M;e.fillRect(B,R,F,M),e.strokeStyle="#444",e.lineWidth=1,e.strokeRect(B,R,F,M)}if(n.showDataLabels){e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,D,A,"bold"),e.textAlign="center",e.textBaseline="bottom";for(let T=0;T<v.length;T++){let z=v[T],C=t.months[z].precip;if(C<=0)continue;let M=(C-S.min)/(S.max-S.min)*a,L=t.monthInterval===12?w(z):w(T),B=h+a-M;e.fillText(String(C),L,B-4)}}if(t.monthInterval===12){e.strokeStyle="#000",e.lineWidth=2.5,e.beginPath();for(let T=0;T<12;T++){let z=w(T),C=h+a-(t.months[T].temp-d.min)/(d.max-d.min)*a;T===0?e.moveTo(z,C):e.lineTo(z,C)}e.stroke()}for(let T=0;T<v.length;T++){let z=v[T],C=t.monthInterval===12?w(z):w(T),M=h+a-(t.months[z].temp-d.min)/(d.max-d.min)*a;e.fillStyle="#000",e.beginPath(),e.arc(C,M,5,0,Math.PI*2),e.fill(),n.showDataLabels&&(e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,D,A,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(t.months[z].temp),C,M-8))}j({ctx:e,plotX:f,plotW:y,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),e.fillStyle="#000",e.font=I(n.fontSize.tick,D,A,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText("(\uC6D4)",f+y+30,h+a+12),i&&ee({ctx:e,items:[{type:"rect",fillStyle:"#AAA",strokeStyle:"#666",label:s[0]},{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:f,plotY:h,plotW:y,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),K({ctx:e,plotX:f,plotW:y,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel})}var Pn=35*Math.PI/180,wn=.5,zo=Math.cos(Pn)*wn,Wo=Math.sin(Pn)*wn;function x(e,o,r,t,n,i){let l=t+r*i-e*zo*i,s=n-o*i+e*Wo*i;return[l,s]}var Go=[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]],Cn=[[4,0,!1],[4,5,!1],[4,6,!1],[0,1,!1],[0,2,!1],[1,3,!1],[2,3,!1],[1,5,!1],[2,6,!1],[3,7,!1],[5,7,!1],[6,7,!1]];function qe(e,o,r,t,n){$(e,o,r);let i=n.fontFamily,l=n.customFont,s=n.fontSize,b=n.title?100:60,g=40;n.source&&(g+=30),g+=n.footnotes.filter(z=>z.trim()).length*22;let p=o-240,f=r-b-g,h=Bo(e,t,o,r,b,f,Math.min(p*.5,f*.55),s,i,l),y=h.scale,a=x(.5,.5,.5,0,0,y),m=o/2-a[0],c=b+f/2-a[1],d=Go.map(([z,C,M])=>x(z,C,M,m,c,y));e.save(),e.strokeStyle="#999",e.lineWidth=1.5,e.setLineDash([6,5]);for(let[z,C,M]of Cn)M&&(e.beginPath(),e.moveTo(d[z][0],d[z][1]),e.lineTo(d[C][0],d[C][1]),e.stroke());e.restore(),e.strokeStyle="#000",e.lineWidth=2;for(let[z,C,M]of Cn)M||(e.beginPath(),e.moveTo(d[z][0],d[z][1]),e.lineTo(d[C][0],d[C][1]),e.stroke());Io(e,t,m,c,y,o,r,i,l,s,h.names,h.nameSize);let S=x(.5,.5,.5,m,c,y);for(let z of t.points){let[C,M]=x(z.z,z.y,z.x,m,c,y);e.fillStyle="#000",e.beginPath(),e.arc(C,M,14,0,Math.PI*2),e.fill();let L=C-S[0],B=M-S[1],R=Math.sqrt(L*L+B*B)||1;L=L/R*40,B=B/R*40;let W=L+z.labelDx,u=B+z.labelDy;e.font=I(s.dataLabel+10,i,l,"bold"),e.textAlign=W>=0?"left":"right",e.textBaseline="middle";let G=fe(e,z.label,C+W+(W>=0?4:-4),M+u,o,r),E=G.x-(W>=0?4:-4),_=G.y;e.strokeStyle="#000",e.lineWidth=1.2,e.beginPath(),e.moveTo(C,M),e.lineTo(E,_),e.stroke(),e.fillStyle="#000",e.fillText(z.label,G.x,G.y)}let D=d.map(([z])=>z),A=Math.min(...D)-30,v=Math.max(...D)+30,k=A,P=v-A;if(n.title){let z=x(0,1.25,0,m,c,y);e.fillStyle="#000",e.font=`bold ${s.title}px 'Noto Sans KR', sans-serif`,e.textAlign="center",e.textBaseline="bottom",le(e,n.title,o/2,z[1]-50,o,r,s.title,C=>`bold ${C}px 'Noto Sans KR', sans-serif`)}let F=x(1.25,0,0,m,c,y),w=x(1,0,0,m,c,y),T=Math.max(F[1]+20+s.axisLabel,w[1]+10+s.axisLabel*.9)+47;K({ctx:e,plotX:k,plotW:P,height:T,source:n.source,footnotes:n.footnotes,fontSize:s.dataLabel})}function Zt(e,o,r,t,n){let l=Math.atan2(n-r,t-o);e.beginPath(),e.moveTo(o,r),e.lineTo(t,n),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(t-10*Math.cos(l-.4),n-10*Math.sin(l-.4)),e.lineTo(t-10*Math.cos(l+.4),n-10*Math.sin(l+.4)),e.closePath(),e.fill()}var zn=1.2,Fo=.8;function Qt(e,o,r,t,n){let l=x(1.25,0,0,o,r,t),s=x(0,1.25,0,o,r,t),b=x(0,0,1.25,o,r,t),g=x(1,0,0,o,r,t),p=x(0,1,0,o,r,t),f=x(0,0,1,o,r,t),h=x(0,0,0,o,r,t);return[{lines:n.z,x:l[0]-6,y:l[1]+20,align:"right",baseline:"middle",kind:"name"},{lines:[e.zAxis.highLabel],x:g[0]+3+e.zAxis.highOffset.x,y:g[1]+10+e.zAxis.highOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:n.y,x:s[0],y:s[1]-10,align:"center",baseline:"bottom",kind:"name"},{lines:[e.yAxis.highLabel],x:p[0]+6+e.yAxis.highOffset.x,y:p[1]-20+e.yAxis.highOffset.y,align:"left",baseline:"middle",kind:"dir"},{lines:n.x,x:b[0]+6,y:b[1],align:"left",baseline:"middle",kind:"name"},{lines:[e.xAxis.highLabel],x:f[0]+e.xAxis.highOffset.x,y:f[1]+14+e.xAxis.highOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:[e.xAxis.lowLabel],x:h[0]+e.xAxis.lowOffset.x,y:h[1]+12+e.xAxis.lowOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:[e.yAxis.lowLabel],x:h[0]-10+e.yAxis.lowOffset.x,y:h[1]-4+e.yAxis.lowOffset.y,align:"right",baseline:"bottom",kind:"dir"},{lines:[e.zAxis.lowLabel],x:h[0]+10+e.zAxis.lowOffset.x,y:h[1]+12+e.zAxis.lowOffset.y,align:"left",baseline:"top",kind:"dir"}]}function An(e,o,r,t){let n=x(.5,.5,.5,0,0,t);return[e/2-n[0],o+r/2-n[1]]}function Bo(e,o,r,t,n,i,l,s,b,g){e.save();let p=s.axisLabel,f=c=>I(c,b,g,"bold"),h=I(s.axisLabel*.9,b,g,"normal"),y={x:[o.xAxis.name],y:[o.yAxis.name],z:[o.zAxis.name]},a=c=>{let[d,S]=An(r,n,i,c);return Qt(o,d,S,c,y).every(D=>{e.font=D.kind==="name"?f(p):h,e.textAlign=D.align,e.textBaseline=D.baseline;let A=p*zn,v=D.lines.map(P=>be(e,P)),k=(D.lines.length-1)*A/2;return D.x-Math.max(...v.map(P=>P.left))>=1&&D.x+Math.max(...v.map(P=>P.right))<=r-1&&D.y-k-Math.max(...v.map(P=>P.up))>=1&&D.y+k+Math.max(...v.map(P=>P.down))<=t-1})},m=se(20,l,a);if(m<l*Fo){let[c,d]=An(r,n,i,l);e.font=f(p);let S=A=>A.align==="left"?r-1-A.x:A.align==="right"?A.x-1:2*Math.min(A.x-1,r-1-A.x),D=Qt(o,c,d,l,y);y={z:re(e,o.zAxis.name,Math.max(30,S(D[0]))),y:re(e,o.yAxis.name,Math.max(30,S(D[2]))),x:re(e,o.xAxis.name,Math.max(30,S(D[4])))},m=se(20,l,a)}return m<=20&&(p=s.axisLabel*.7,e.font=f(p),y={x:y.x.flatMap(c=>re(e,c,Math.max(30,r/3))),y:y.y.flatMap(c=>re(e,c,Math.max(30,r/3))),z:y.z.flatMap(c=>re(e,c,Math.max(30,r/3)))},m=se(20,l,a)),e.restore(),{scale:m,names:y,nameSize:p}}function Io(e,o,r,t,n,i,l,s,b,g,p,f){e.strokeStyle="#000",e.fillStyle="#000",e.lineWidth=1.5;let y=x(1,0,0,r,t,n),a=x(1.25,0,0,r,t,n);Zt(e,y[0],y[1],a[0],a[1]);let m=x(0,1,0,r,t,n),c=x(0,1.25,0,r,t,n);Zt(e,m[0],m[1],c[0],c[1]);let d=x(0,0,1,r,t,n),S=x(0,0,1.25,r,t,n);Zt(e,d[0],d[1],S[0],S[1]);let D=I(f,s,b,"bold"),A=I(g.axisLabel*.9,s,b,"normal");e.fillStyle="#000";for(let v of Qt(o,r,t,n,p)){if(v.lines.every(F=>!F))continue;e.font=v.kind==="name"?D:A,e.textAlign=v.align,e.textBaseline=v.baseline;let k=f*zn,P=an(e,v.lines,v.x,v.y,k,i,l);pe(e,v.lines,P.x,P.y,k)}}var Eo=["1","2","3","4","5","6","7","8","9","10","11","12"],Wn={12:[0,1,2,3,4,5,6,7,8,9,10,11],4:[2,5,8,11],2:[0,6]};function Je(e,o,r,t,n){$(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipLabel,n.legendLabel2||t.tempLabel],b=i&&l==="right"&&!t.insideLegend?Q(e,s,n.fontSize.dataLabel*.85+5):0,g=0;(t.tempAxisName||t.precipAxisName)&&(e.save(),e.font=I(n.fontSize.axisLabel,n.fontFamily,n.customFont,"bold"),g=e.measureText("\uAC00").width+12,e.restore());let p=130+b+(t.precipAxisName?g:0),f=130+(t.tempAxisName?g:0),h=i&&l==="bottom"&&!t.insideLegend?te(e,s,n.fontSize.dataLabel*.85+5,o-f-p,["rect",t.monthInterval===12?"line":"circle"]):0,y={top:n.title?100:50,right:p,bottom:(()=>{let u=60;return i&&l==="bottom"&&!t.insideLegend&&(u+=60),u=Math.max(u,h),n.source&&(u+=30),u+=n.footnotes.filter(G=>G.trim()).length*22,u})(),left:f},a=y.left,m=y.top,c=o-y.left-y.right,d=r-y.top-y.bottom,S=n.fontFamily,D=n.customFont,A=Wn[t.monthInterval]??Wn[12],v=t.months.map((u,G)=>u.temp-t.baseMonths[G].temp),k=t.months.map((u,G)=>u.precip-t.baseMonths[G].precip),P=A.map(u=>v[u]),F=A.map(u=>k[u]),w=t.precipRange.auto?J(F.length>0?F:[0],6):{min:t.precipRange.min,max:t.precipRange.max,step:t.precipRange.step??0};if(w.step===0&&(w.step=Math.max(1,Math.round((w.max-w.min)/6))),t.precipRange.auto){let u=Math.max(Math.abs(w.min),Math.abs(w.max));w.min=-u,w.max=u}let T=t.tempRange.auto?(()=>{let u=J(P.length>0?P:[0],6),G=Math.max(Math.abs(u.min),Math.abs(u.max));return{min:-G,max:G,step:u.step}})():{min:t.tempRange.min,max:t.tempRange.max,step:t.tempRange.step??0};T.step===0&&(T.step=Math.max(.5,Math.round((T.max-T.min)/6*10)/10));let z=Gn(e,y,o,r,T,"left",t.tempLabel,S,D,n.fontSize),C=Gn(e,y,o,r,w,"right",t.precipLabel,S,D,n.fontSize),M=A.length,L=c/M;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,m+d),e.lineTo(a+c,m+d),e.stroke(),t.showFrame&&(e.beginPath(),e.moveTo(a,m),e.lineTo(a+c,m),e.stroke()),e.fillStyle="#000",e.font=I(n.fontSize.tick,S,D,"bold"),e.textAlign="center",e.textBaseline="top";for(let u=0;u<M;u++){let G=a+L*u+L/2;e.fillText(Eo[A[u]],G,m+d+12)}let B=m+d-(0-w.min)/(w.max-w.min)*d;e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(a,B),e.lineTo(a+c,B),e.stroke();let R=Math.min(L*.55,80),W=[];for(let u=0;u<M;u++){let G=A[u],E=k[G],O=a+L*u+L/2-R/2,H=m+d-(E-w.min)/(w.max-w.min)*d;e.fillStyle=t.barFill??(E>=0?"#666":"#CCC");let N=Math.min(B,H),U=Math.abs(H-B);e.fillRect(O,N,R,U),e.strokeStyle=t.barStroke??"#444",e.lineWidth=1,e.strokeRect(O,N,R,U),W.push({x0:O,y0:N,x1:O+R,y1:N+U})}if(t.monthInterval===12){e.strokeStyle="#000",e.lineWidth=2.5,e.beginPath();let u=null;for(let G=0;G<M;G++){let E=A[G],_=a+L*G+L/2,O=m+d-(v[E]-T.min)/(T.max-T.min)*d;G===0?e.moveTo(_,O):e.lineTo(_,O),u&&W.push({x0:u.x,y0:Math.min(u.y,O),x1:_,y1:Math.max(u.y,O)}),u={x:_,y:O}}e.stroke()}for(let u=0;u<M;u++){let G=A[u],E=a+L*u+L/2,_=m+d-(v[G]-T.min)/(T.max-T.min)*d;e.fillStyle="#000",t.markerShape==="square"?e.fillRect(E-5,_-5,10,10):(e.beginPath(),e.arc(E,_,5,0,Math.PI*2),e.fill()),W.push({x0:E-6,y0:_-6,x1:E+6,y1:_+6})}e.fillStyle="#000",e.font=I(n.fontSize.tick,S,D,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText("(\uC6D4)",a+c+30,m+d+12),i&&t.insideLegend?bt({ctx:e,items:[{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",marker:t.markerShape??"circle",label:s[1]},{type:"rect",fillStyle:t.barFill??"#888",strokeStyle:t.barStroke??"#444",label:s[0]}],corner:t.insideLegend,plotX:a,plotY:m,plotW:c,plotH:d,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.9,font:I(n.fontSize.dataLabel*.9,S,D,"bold"),avoid:W}):i&&ee({ctx:e,items:[{type:"rect",fillStyle:"#888",strokeStyle:"#444",label:s[0]},{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:a,plotY:m,plotW:c,plotH:d,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),t.tempAxisName&&Fn(e,t.tempAxisName,a-22-z-g/2,m,d,r,n.fontSize.axisLabel,S,D),t.precipAxisName&&Fn(e,t.precipAxisName,a+c+22+C+g/2,m,d,r,n.fontSize.axisLabel,S,D),j({ctx:e,plotX:a,plotW:c,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:a,plotW:c,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Gn(e,o,r,t,n,i,l,s,b,g){let p=o.left,f=o.top,h=r-o.left-o.right,y=t-o.top-o.bottom,a=i==="left"?p:p+h;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,f),e.lineTo(a,f+y),e.stroke(),e.fillStyle="#000",e.font=I(g.tick,s,b,"bold"),e.textBaseline="middle",e.textAlign=i==="left"?"right":"left";let m=0,c=Math.round((n.max-n.min)/n.step);for(let d=0;d<=c;d++){let S=n.min+d*n.step,D=f+y-(S-n.min)/(n.max-n.min)*y;e.lineWidth=1.5,e.beginPath(),i==="left"?(e.moveTo(a-6,D),e.lineTo(a,D)):(e.moveTo(a,D),e.lineTo(a+6,D)),e.stroke();let A=i==="left"?a-12:a+12,v=Number.isInteger(S)?S.toString():S.toFixed(1);e.fillText(v,A,D),m=Math.max(m,e.measureText(v).width)}if(l){e.save();let d=A=>I(A,s,b,"bold");e.fillStyle="#000",e.textBaseline="bottom",e.textAlign=i==="left"?"right":"left",e.font=d(Le(e,[l],g.axisLabel,r-2,d));let S=i==="left"?a-12:a+12,D=fe(e,l,S,f-16,r,t);e.fillText(l,D.x,D.y),e.restore()}return m}function Fn(e,o,r,t,n,i,l,s,b){let g=[...o].filter(S=>S.trim()!=="");if(g.length===0)return;let p=S=>(g.length-1)*S*1.15+S,f=l;p(f)>n&&(f=Math.max(l*.7,n/p(1))),p(f)>i-2&&(f=(i-2)/p(1)),e.save(),e.font=I(f,s,b,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="middle";let h=f*1.15,y=(g.length-1)*h/2,a=t+n/2,m=a-y-f/2,c=a+y+f/2;m<1?a+=1-m:c>i-1&&(a-=c-(i-1));let d=a-y;for(let S of g)e.fillText(S,r,d),d+=h;e.restore()}function Ze(e,o,r,t,n){$(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipDiffLabel,n.legendLabel2||t.tempDiffLabel],b=i&&l==="right"?Q(e,s,n.fontSize.dataLabel*.85+5):0,g=i&&l==="bottom"?te(e,s,n.fontSize.dataLabel*.85+5,o-130-(130+b),["rect","circle"]):0,p={top:n.title?100:50,right:130+b,bottom:(()=>{let M=60;return i&&l==="bottom"&&(M+=60),M=Math.max(M,g),n.source&&(M+=30),M+=n.footnotes.filter(L=>L.trim()).length*22,M})(),left:130},f=p.left,h=p.top,y=o-p.left-p.right,a=r-p.top-p.bottom,m=n.fontFamily,c=n.customFont,d=t.regions,S=d.length,D=d.map(M=>M.precip-t.basePrecip),A=d.map(M=>M.temp-t.baseTemp),v=D,k=A,P=t.precipRange.auto?J(v,6):{min:t.precipRange.min,max:t.precipRange.max,step:0};if(P.step===0&&(P.step=Math.max(1,Math.round((P.max-P.min)/6))),t.precipRange.auto){let M=Math.max(Math.abs(P.min),Math.abs(P.max));P.min=-M,P.max=M}let F=t.tempRange.auto?J(k,6):{min:t.tempRange.min,max:t.tempRange.max,step:0};if(F.step===0&&(F.step=Math.max(1,Math.round((F.max-F.min)/6))),t.tempRange.auto){let M=Math.max(Math.abs(F.min),Math.abs(F.max));F.min=-M,F.max=M}Bn(e,p,o,r,F,"left",t.tempUnit,m,c,n.fontSize),Bn(e,p,o,r,P,"right",t.precipUnit,m,c,n.fontSize),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(f,h+a),e.lineTo(f+y,h+a),e.stroke();let w=h+a-(0-P.min)/(P.max-P.min)*a;e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.moveTo(f,w),e.lineTo(f+y,w),e.stroke();let T=y/S,z=Math.min(T*.5,80);e.fillStyle="#000",e.font=I(n.fontSize.tick*1.2,m,c,"bold"),e.textAlign="center",e.textBaseline="top";let C=M=>I(M,m,c,"bold");for(let M=0;M<S;M++){let L=f+T*M+T/2;le(e,d[M].label,L,h+a+12,o,r,n.fontSize.tick*1.2,C)}for(let M=0;M<S;M++){let L=D[M],R=f+T*M+T/2-z/2,W=h+a-(L-P.min)/(P.max-P.min)*a;e.fillStyle=L>=0?"#888":"#CCC";let u=Math.min(w,W),G=Math.abs(W-w);e.fillRect(R,u,z,G),e.strokeStyle="#444",e.lineWidth=1,e.strokeRect(R,u,z,G)}for(let M=0;M<S;M++){let L=f+T*M+T/2,B=h+a-(A[M]-F.min)/(F.max-F.min)*a;e.fillStyle="#000",e.beginPath(),e.arc(L,B,7,0,Math.PI*2),e.fill()}if(n.showDataLabels){e.font=I(n.fontSize.dataLabel,m,c,"bold"),e.textAlign="center";for(let M=0;M<S;M++){let L=f+T*M+T/2,B=D[M],R=h+a-(B-P.min)/(P.max-P.min)*a;e.fillStyle="#000",e.textBaseline=B>=0?"bottom":"top",e.fillText(String(B),L,B>=0?R-z/2-4:R+4);let W=A[M],u=h+a-(W-F.min)/(F.max-F.min)*a;e.textBaseline="bottom",e.fillText(String(W),L,u-10)}}i&&ee({ctx:e,items:[{type:"rect",fillStyle:"#888",strokeStyle:"#444",label:s[0]},{type:"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:f,plotY:h,plotW:y,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),j({ctx:e,plotX:f,plotW:y,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:f,plotW:y,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel})}function Bn(e,o,r,t,n,i,l,s,b,g){let p=o.left,f=o.top,h=r-o.left-o.right,y=t-o.top-o.bottom,a=i==="left"?p:p+h;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,f),e.lineTo(a,f+y),e.stroke(),e.fillStyle="#000",e.font=I(g.tick,s,b,"bold"),e.textBaseline="middle",e.textAlign=i==="left"?"right":"left";let m=Math.round((n.max-n.min)/n.step);for(let d=0;d<=m;d++){let S=n.min+d*n.step,D=f+y-(S-n.min)/(n.max-n.min)*y;e.lineWidth=1.5,e.beginPath(),i==="left"?(e.moveTo(a-6,D),e.lineTo(a,D)):(e.moveTo(a,D),e.lineTo(a+6,D)),e.stroke();let A=i==="left"?a-12:a+12,v=Number.isInteger(S)?S.toString():S.toFixed(1);e.fillText(v,A,D)}e.save(),e.font=I(g.axisLabel,s,b,"bold"),e.fillStyle="#000",e.textBaseline="bottom";let c=i==="left"?a-12:a+12;e.textAlign=i==="left"?"right":"left",e.fillText(l,c,f-16),e.restore()}var ze=[{dash:[],width:2},{dash:[8,4],width:2},{dash:[2,3],width:2},{dash:[8,3,2,3],width:2},{dash:[12,4,2,4,2,4],width:2}],We=["filledCircle","filledSquare","filledTriangle","openCircle","openSquare"];function On(e,o,r,t,n){let i=n;switch(e.lineWidth=1.5,e.strokeStyle="#000",o){case"filledCircle":e.fillStyle="#000",e.beginPath(),e.arc(r,t,i,0,Math.PI*2),e.fill();break;case"filledSquare":e.fillStyle="#000",e.fillRect(r-i,t-i,i*2,i*2);break;case"filledTriangle":e.fillStyle="#000",e.beginPath(),e.moveTo(r,t-i*1.1),e.lineTo(r-i,t+i*.7),e.lineTo(r+i,t+i*.7),e.closePath(),e.fill();break;case"openCircle":e.fillStyle="#fff",e.beginPath(),e.arc(r,t,i,0,Math.PI*2),e.fill(),e.stroke();break;case"openSquare":e.fillStyle="#fff",e.fillRect(r-i,t-i,i*2,i*2),e.strokeRect(r-i,t-i,i*2,i*2);break}}function In(e,o,r,t){On(e,o,r,t,5)}function Qe(e,o,r,t,n){$(e,o,r);let i=n.fontFamily,l=n.customFont,s=n.fontSize,b=n.showLegend&&t.series.length>0,g=n.legendPosition,p=t.series.map(u=>u.label),f=b&&g==="right"?Q(e,p,s.dataLabel*.85+5):0,h=b&&g==="bottom"?65+Oe(e,p,t.series.map(()=>36),s.dataLabel*.85+5,o-80-(80+f),{iconGap:8}).boxH+2:0,y={top:n.title?110:60,right:80+f,bottom:(()=>{let u=90;return b&&g==="bottom"&&(u+=80),u=Math.max(u,h),n.source&&(u+=30),u+=n.footnotes.filter(G=>G.trim()).length*22,u})(),left:80},a=y.left,m=y.top,c=o-y.left-y.right,d=r-y.top-y.bottom,S=t.series.flatMap(u=>u.months.map(G=>G.temp)),D=t.series.flatMap(u=>u.months.map(G=>G.precip)),A=J(S),v=J(D),k=t.xRange.auto?A.min:t.xRange.min,P=t.xRange.auto?A.max:t.xRange.max,F=t.yRange.auto?v.min:t.yRange.min,w=t.yRange.auto?v.max:t.yRange.max,T=t.xRange.auto?A.step:(P-k)/5,z=t.yRange.auto?v.step:(w-F)/5,C=u=>a+(u-k)/(P-k)*c,M=u=>m+d-(u-F)/(w-F)*d;e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]);for(let u=k+T;u<P;u+=T){let G=C(u);e.beginPath(),e.moveTo(G,m),e.lineTo(G,m+d),e.stroke()}for(let u=F+z;u<w;u+=z){let G=M(u);e.beginPath(),e.moveTo(a,G),e.lineTo(a+c,G),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,m),e.lineTo(a,m+d),e.lineTo(a+c,m+d),e.stroke(),e.fillStyle="#000",e.font=I(s.tick,i,l,"bold"),e.textAlign="center",e.textBaseline="top";for(let u=k;u<=P+T*.01;u+=T){let G=C(u);e.lineWidth=1,e.beginPath(),e.moveTo(G,m+d),e.lineTo(G,m+d+6),e.stroke(),u+T>P+T*.01&&t.xUnit||e.fillText(En(u),G,m+d+10)}e.textAlign="right",e.textBaseline="middle";for(let u=F;u<=w+z*.01;u+=z){let G=M(u);e.lineWidth=1,e.beginPath(),e.moveTo(a-6,G),e.lineTo(a,G),e.stroke(),u+z>w+z*.01&&t.yUnit||e.fillText(En(u),a-10,G)}e.font=I(s.axisLabel,i,l,"bold"),e.fillStyle="#000";let L=u=>I(u,i,l,"bold");t.xUnit&&(e.textAlign="right",e.textBaseline="top",le(e,t.xUnit,a+c+10,m+d+35,o,r,s.axisLabel,L)),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",le(e,t.yUnit,a,m-16,o,r,s.axisLabel,L));let B=t.monthLabelStyle==="english"?Rt:Mt,R=t.mode==="loop"||t.mode==="both",W=t.mode==="points"||t.mode==="both";for(let u=0;u<t.series.length;u++){let G=t.series[u],E=ze[u%ze.length],_=G.months.map(O=>({cx:C(O.temp),cy:M(O.precip)}));if(R&&_.length===12){e.strokeStyle="#000",e.lineWidth=E.width,e.setLineDash(E.dash),e.beginPath(),e.moveTo(_[0].cx,_[0].cy);for(let O=1;O<12;O++)e.lineTo(_[O].cx,_[O].cy);e.closePath(),e.stroke(),e.setLineDash([])}if(W){let O=We[u%We.length];for(let H=0;H<12;H++){let{cx:N,cy:U}=_[H];e.fillStyle="#fff",e.beginPath(),e.arc(N,U,7,0,Math.PI*2),e.fill(),On(e,O,N,U,5),e.fillStyle="#000",e.font=I(s.dataLabel,i,l,"bold"),e.textAlign="left",e.textBaseline="bottom",e.fillText(B[H],N+9,U-5)}}}if(b){let u=s.dataLabel*.85+5,G="'Noto Sans KR', sans-serif";e.save(),e.font=`bold ${u}px ${G}`;let E=36,_=8,O=12,H=u+8,N=t.series.length,U=t.series.map(X=>E+_+e.measureText(X.label).width);if(g==="bottom"){let q=c,V=Oe(e,t.series.map(ae=>ae.label),t.series.map(()=>E),u,q,{iconGap:_,padding:O,spacing:30}),ne=V.boxH,me=a,Be=Math.max(0,Math.min(m+d+65,r-ne-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(me,Be,q,ne,0),e.fill(),e.stroke();for(let ae=0;ae<V.rows.length;ae++){let he=V.rows[ae],Ce=he.reduce((Ie,_t)=>Ie+_t.width,0)+30*(he.length-1),de=me+(q-Ce)/2,st=Be+O+ae*(V.lineHeight+V.rowGap)+V.lineHeight/2;for(let{index:Ie,width:_t}of he){let on=ze[Ie%ze.length];e.strokeStyle="#000",e.lineWidth=on.width,e.setLineDash(on.dash),e.beginPath(),e.moveTo(de,st),e.lineTo(de+E,st),e.stroke(),e.setLineDash([]),In(e,We[Ie%We.length],de+E/2,st),e.font=`bold ${V.fontSize}px ${G}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(t.series[Ie].label,de+E+_,st),de+=_t+30}}}else{let V=Math.max(...U)+O*2,ne=H*N+10*(N-1)+O*2,me=Math.max(0,Math.min(a+c+20,o-V-1)),Be=Math.max(0,Math.min(m+d-ne,r-ne-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(me,Be,V,ne,0),e.fill(),e.stroke();let ae=Be+O+H/2;for(let he=0;he<N;he++){let Ce=me+O,de=ze[he%ze.length];e.strokeStyle="#000",e.lineWidth=de.width,e.setLineDash(de.dash),e.beginPath(),e.moveTo(Ce,ae),e.lineTo(Ce+E,ae),e.stroke(),e.setLineDash([]),In(e,We[he%We.length],Ce+E/2,ae),e.font=`bold ${u}px ${G}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(t.series[he].label,Ce+E+_,ae),ae+=H+10}}e.restore()}j({ctx:e,plotX:a,plotW:c,title:n.title,fontSize:s.title,canvasWidth:o}),K({ctx:e,plotX:a,plotW:c,height:r,source:n.source,footnotes:n.footnotes,fontSize:s.dataLabel,canvasWidth:o})}function En(e){return Math.abs(e)<1e-4?"0":Number(e.toFixed(2)).toString()}function xe(e){let o=Math.round(e*1e10)/1e10;return Number.isInteger(o)?o.toString():o.toFixed(1)}var Oo=6,Ho=12;function No(e,o,r){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.max(1,Math.floor(o/(r+Oo))),n=(i,l)=>Math.abs(i/l-Math.round(i/l))<1e-9;for(let i of[1,.5,.1])for(let l=Math.min(t,Ho);l>=2;l-=1){let s=e/l;if(s>0&&n(s,i))return s}return e}function et(e,o,r,t,n){$(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.maleLabel,n.legendLabel2||t.femaleLabel],b=i&&l==="right"?Q(e,s,n.fontSize.dataLabel*.85+5):0,g=i&&l==="bottom"?te(e,s,n.fontSize.dataLabel*.85+5,o-60-(80+b)):0,p={top:n.title?100:50,right:80+b,bottom:(()=>{let R=90;return i&&l==="bottom"&&(R+=60),R=Math.max(R,g),n.source&&(R+=30),R+=n.footnotes.filter(W=>W.trim()).length*22,R})(),left:60},f=p.left,h=p.top,y=o-p.left-p.right,a=r-p.top-p.bottom,m=n.fontFamily,c=n.customFont,d=t.ages,S=t.numericAgeAxis&&d.length>0?d.length:ve.length,D=t.unit==="percent",A=d.flatMap(R=>[R.male,R.female]),v=t.range.auto?Math.max(...A,1):t.range.max;if(t.range.auto){let R=Ae(v,5);v=Math.ceil(v/R)*R}let k=f+y/2,P=y/2,F=a/S,w=F*.1,T=F-w-2,z=t.ageLabelSide;e.strokeStyle="#000",e.lineWidth=2,z==="left"&&(e.beginPath(),e.moveTo(f,h),e.lineTo(f,h+a),e.stroke()),z==="right"&&(e.beginPath(),e.moveTo(f+y,h),e.lineTo(f+y,h+a),e.stroke()),z==="center"&&(e.beginPath(),e.moveTo(k,h),e.lineTo(k,h+a),e.stroke()),e.beginPath(),e.moveTo(f,h),e.lineTo(f+y,h),e.stroke(),e.beginPath(),e.moveTo(f,h+a),e.lineTo(f+y,h+a),e.stroke(),e.save(),e.font=I(n.fontSize.tick,m,c,"bold");let C=No(v,P,e.measureText(xe(v)).width);e.restore();for(let R=C;R<=v;R+=C){let W=R/v*P;e.save(),e.strokeStyle="#aaa",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(k-W,h),e.lineTo(k-W,h+a),e.stroke(),e.beginPath(),e.moveTo(k+W,h),e.lineTo(k+W,h+a),e.stroke(),e.restore()}for(let R=0;R<S;R++){let W=h+a-(R+1)*F+w/2,u=d[R].male/v*P,G=d[R].female/v*P;e.fillStyle=t.sexFills?.[0]??"#666",e.fillRect(k-u,W,u,T),e.strokeStyle=t.sexFills?"#000":"#444",e.lineWidth=.5,e.strokeRect(k-u,W,u,T),e.fillStyle=t.sexFills?.[1]??"#BBB",e.fillRect(k,W,G,T),e.strokeStyle=t.sexFills?"#000":"#888",e.lineWidth=.5,e.strokeRect(k,W,G,T)}if(e.fillStyle="#000",e.textBaseline="middle",t.numericAgeAxis){e.font=I(n.fontSize.tick,m,c,"bold"),e.textAlign="right";let R=20,W=S*5;for(let u=0;u<=W;u+=R){let G=h+a-u/W*a;e.lineWidth=1,e.strokeStyle="#000",e.beginPath(),e.moveTo(f-6,G),e.lineTo(f,G),e.stroke(),e.fillText(String(u),f-10,G)}t.ageUnit&&(e.textBaseline="bottom",le(e,t.ageUnit,f+4,h-8,o,r,n.fontSize.tick,u=>I(u,m,c,"bold")),e.font=I(n.fontSize.tick,m,c,"bold"),e.textBaseline="middle")}else{e.font=I(n.fontSize.tick*.75,m,c,"bold");for(let R=0;R<S;R++){let W=h+a-(R+1)*F+F/2;z==="center"?(e.textAlign="center",e.fillText(ve[R],k,W)):z==="left"?(e.textAlign="right",e.fillText(ve[R],f-8,W)):(e.textAlign="left",e.fillText(ve[R],f+y+8,W))}}e.font=I(n.fontSize.tick,m,c,"bold"),e.textBaseline="top",e.fillStyle="#000";let M=[];for(let R=0;R<=v+C*.001;R+=C){let W=Math.round(R*1e10)/1e10;if(W>v)break;M.push(W)}let L=Math.max(1,M.length-1),B=ie(P/L,oe(e,M.map(xe)));for(;B<L&&L%B!==0;)B+=1;for(let R=0;R<M.length;R++){let W=M[R],u=R%B===0,G=W/v*P,E=k-G;e.strokeStyle="#000",e.lineWidth=1,e.beginPath(),e.moveTo(E,h+a),e.lineTo(E,h+a+5),e.stroke(),u&&(e.textAlign="center",e.fillText(xe(W),E,h+a+10));let _=k+G;e.strokeStyle="#000",e.lineWidth=1,e.beginPath(),e.moveTo(_,h+a),e.lineTo(_,h+a+5),e.stroke(),W>0&&u&&(e.textAlign="center",e.fillText(xe(W),_,h+a+10))}if(e.font=I(n.fontSize.axisLabel,m,c,"bold"),e.textBaseline="bottom",e.fillStyle="#000",e.textAlign="center",e.fillText(t.maleLabel,f+P/2,h-16),e.fillText(t.femaleLabel,k+P/2,h-16),e.save(),t.axisLabelInline){e.font=I(n.fontSize.tick,m,c,"bold");let R=e.measureText(xe(v)).width/2;e.textAlign="left",e.textBaseline="top",le(e,t.axisLabel,f+y+R+8,h+a+10,o,r,n.fontSize.tick,W=>I(W,m,c,"bold"))}else{e.font=I(n.fontSize.axisLabel*.85,m,c,"bold");let R=h+a+10+n.fontSize.tick+22;e.textAlign="left",le(e,t.axisLabel,f+y+4,R,o,r,n.fontSize.axisLabel*.85,W=>I(W,m,c,"bold"))}if(e.restore(),n.showDataLabels){e.font=I(n.fontSize.dataLabel*.8,m,c,"bold"),e.fillStyle="#000";for(let R=0;R<S;R++){let W=h+a-(R+1)*F+F/2,u=d[R].male/v*P,G=d[R].female/v*P,E=D?d[R].male.toFixed(1):String(d[R].male),_=D?d[R].female.toFixed(1):String(d[R].female);d[R].male>0&&(e.textAlign="right",e.fillText(E,k-u-4,W)),d[R].female>0&&(e.textAlign="left",e.fillText(_,k+G+4,W))}}j({ctx:e,plotX:f,plotW:y,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i&&ee({ctx:e,items:[{type:"rect",fillStyle:"#666",strokeStyle:"#444",label:s[0]},{type:"rect",fillStyle:"#BBB",strokeStyle:"#888",label:s[1]}],position:l,plotX:f,plotY:h,plotW:y,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5}),K({ctx:e,plotX:f,plotW:y,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var It=[{dash:[],width:2},{dash:[8,4],width:2},{dash:[2,3],width:2},{dash:[8,3,2,3],width:2},{dash:[12,4,2,4,2,4],width:2}],Ge=["#000","#444","#777","#AAA","#CCC"];function tt(e,o,r,t,n){$(e,o,r);let i=n.fontFamily,l=n.customFont,s=n.fontSize,b=t.axisLabels.length;if(b<3)return;let g=n.showLegend&&t.series.length>1,p=n.legendPosition,f=t.series.map(u=>u.label),h=g&&p==="right"?Q(e,f,s.dataLabel*.85+5,"line"):0,y=n.title?60:10,a=60+h,m=60,c=10;g&&p==="bottom"&&(c+=70,c=Math.max(c,te(e,f,s.dataLabel*.85+5,o-m-a,"line",30))),n.source&&(c+=25),c+=n.footnotes.filter(u=>u.trim()).length*22;let d=o-m-a,S=r-y-c,D=m+d/2,A=y+S/2,v=Array.from({length:b},(u,G)=>-Math.PI/2+2*Math.PI*G/b),k=s.axisLabel*.85,P=u=>I(u,i,l,"bold"),{radius:F,labelLines:w,labelSize:T}=$o(e,t.axisLabels,v,D,A,o,r,Math.min(d,S)/2-40,k,P),z=t.series.flatMap(u=>u.values),C=z.length>0?Math.max(...z,1):100,M=t.autoMax?Math.ceil(C/t.gridSteps)*t.gridSteps:t.maxValue,L=(u,G)=>[D+Math.cos(u)*G,A+Math.sin(u)*G];e.save(),e.strokeStyle="#ccc",e.lineWidth=.8;for(let u=1;u<=t.gridSteps;u++){let G=u/t.gridSteps*F;e.beginPath();for(let E=0;E<=b;E++){let[_,O]=L(v[E%b],G);E===0?e.moveTo(_,O):e.lineTo(_,O)}e.stroke()}e.restore(),e.strokeStyle="#999",e.lineWidth=1;for(let u=0;u<b;u++){let[G,E]=L(v[u],F);e.beginPath(),e.moveTo(D,A),e.lineTo(G,E),e.stroke()}e.fillStyle="#888",e.font=I(s.tick*.8,i,l,"normal"),e.textAlign="left",e.textBaseline="middle";for(let u=1;u<=t.gridSteps;u++){let G=M/t.gridSteps*u,E=u/t.gridSteps*F;e.fillText(_o(G),D+4,A-E-2)}e.fillStyle="#000",e.font=P(T);for(let u=0;u<b;u++){let[G,E]=L(v[u],F+20);xt(e,v[u]),pe(e,w[u],G,E,T*Hn)}let B=t.series.map(u=>{let G=[];for(let E=0;E<b;E++){let O=(u.values[E]||0)/M*F;G.push(L(v[E],O))}return G});if(t.showFill)for(let u=0;u<t.series.length;u++){let G=Ge[u%Ge.length],E=B[u],_=parseInt(G.slice(1,2),16)*17,O=parseInt(G.slice(2,3),16)*17,H=parseInt(G.slice(3,4),16)*17;e.fillStyle=`rgba(${_},${O},${H},0.12)`,e.beginPath();for(let N=0;N<=b;N++){let[U,X]=E[N%b];N===0?e.moveTo(U,X):e.lineTo(U,X)}e.fill()}for(let u=0;u<t.series.length;u++){let G=It[u%It.length],E=Ge[u%Ge.length],_=B[u];e.strokeStyle=E,e.lineWidth=G.width,e.setLineDash(G.dash),e.beginPath();for(let O=0;O<=b;O++){let[H,N]=_[O%b];O===0?e.moveTo(H,N):e.lineTo(H,N)}e.stroke(),e.setLineDash([]);for(let O=0;O<b;O++){let[H,N]=_[O];e.fillStyle="#fff",e.beginPath(),e.arc(H,N,5,0,Math.PI*2),e.fill(),e.fillStyle=E,e.beginPath(),e.arc(H,N,3.5,0,Math.PI*2),e.fill()}}if(g){let u=m,G=y,E=d,_=S,O=t.series.map((H,N)=>{let U=It[N%It.length];return{type:"line",fillStyle:Ge[N%Ge.length],label:H.label,dash:U.dash,lineWidth:U.width}});ee({ctx:e,items:O,position:p,plotX:u,plotY:G,plotW:E,plotH:_,canvasW:o,canvasH:r,fontSize:s.dataLabel*.85+5,bottomOffset:30})}let R=m,W=d;j({ctx:e,plotX:R,plotW:W,title:n.title,fontSize:s.title,canvasWidth:o}),K({ctx:e,plotX:R,plotW:W,height:r,source:n.source,footnotes:n.footnotes,fontSize:s.dataLabel,canvasWidth:o})}function _o(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}var Hn=1.25,Uo=.8;function xt(e,o){Math.abs(Math.cos(o))<.1?e.textAlign="center":Math.cos(o)>0?e.textAlign="left":e.textAlign="right",Math.abs(Math.sin(o))<.1?e.textBaseline="middle":Math.sin(o)>0?e.textBaseline="top":e.textBaseline="bottom"}function $o(e,o,r,t,n,i,l,s,b,g){e.save();let p=b,f=o.map(m=>[m]),h=(m,c)=>{let d=t+Math.cos(r[c])*(m+20),S=n+Math.sin(r[c])*(m+20);xt(e,r[c]);let D=f[c].map(v=>be(e,v)),A=(f[c].length-1)*p*Hn/2;return{x0:d-Math.max(...D.map(v=>v.left)),x1:d+Math.max(...D.map(v=>v.right)),y0:S-A-Math.max(...D.map(v=>v.up)),y1:S+A+Math.max(...D.map(v=>v.down))}},y=m=>o.every((c,d)=>{let S=h(m,d);return S.x0>=1&&S.x1<=i-1&&S.y0>=1&&S.y1<=l-1});e.font=g(p);let a=se(10,s,y);return a<s*Uo&&(f=o.map((m,c)=>{let d=t+Math.cos(r[c])*(s+20);xt(e,r[c]);let S=e.textAlign==="left"?i-1-d:e.textAlign==="right"?d-1:2*Math.min(d-1,i-1-d);return re(e,m,Math.max(20,S))}),a=se(10,s,y)),a<=10&&(p=b*.7,e.font=g(p),f=f.map(m=>m.flatMap(c=>re(e,c,Math.max(20,i/3)))),a=se(10,s,y)),e.restore(),{radius:a,labelLines:f,labelSize:p}}function nt(e,o,r,t,n){$(e,o,r),t.mode==="deviation"?Xo(e,o,r,t,n):Yo(e,o,r,t,n)}function Yo(e,o,r,t,n){let i=n.fontFamily,l=n.customFont,s=n.fontSize,b=t.bubbleLegendPosition==="outside-right"&&t.showBubble&&t.points.length>0,g=b?Yn(e,t,s,i,l):null,p=b?en(e,t,s,i,l):{boxW:0,boxH:0},f=Math.max(g?.boxW??0,p.boxW),h=(()=>{if(t.examFrame!==!0||!t.xUnit)return 0;e.save(),e.font=I(s.tick,i,l,"bold");let H=e.measureText(t.xUnit).width;return e.restore(),H})(),y=t.points.map(H=>H.x),a=t.points.map(H=>H.y),m=J(y),c=J(a),d=t.xRange.auto?m.min:t.xRange.min,S=t.xRange.auto?m.max:t.xRange.max,D=t.yRange.auto?c.min:t.yRange.min,A=t.yRange.auto?c.max:t.yRange.max,v=t.xRange.step??(t.xRange.auto?m.step:(S-d)/5),k=t.yRange.step??(t.yRange.auto?c.step:(A-D)/5),P=Ko(e,t,o,D,A,k,s,i,l),F={top:n.title?100:50,right:f>0?f+40:Math.max(60,h+34),bottom:(()=>{let H=90,N=n.footnotes.filter(U=>U.trim()).length;return n.source&&!(n.sourceInline&&N>0)&&(H+=30),H+=N*22,H})(),left:Math.max(130,P.reserve)},w=F.left,T=F.top,z=o-F.left-F.right,C=r-F.top-F.bottom,M=H=>w+(H-d)/(S-d)*z,L=H=>T+C-(H-D)/(A-D)*C,B=t.examFrame===!0;e.save(),e.strokeStyle=B?"#333":"#ddd",e.lineWidth=B?1:.5,e.setLineDash(B?[5,4]:[3,3]);for(let H=d+v;H<S;H+=v){let N=M(H);e.beginPath(),e.moveTo(N,T),e.lineTo(N,T+C),e.stroke()}for(let H=D+k;H<A;H+=k){let N=L(H);e.beginPath(),e.moveTo(w,N),e.lineTo(w+z,N),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,B?e.strokeRect(w,T,z,C):(e.beginPath(),e.moveTo(w,T),e.lineTo(w,T+C),e.lineTo(w+z,T+C),e.stroke()),e.fillStyle="#000",e.font=I(s.tick,i,l,"bold"),e.textAlign="center",e.textBaseline="top";let R=[];for(let H=d;H<=S+v*.01;H+=v)R.push(H);let W=ie(z/Math.max(1,R.length-1),oe(e,R.map(Se))),u=w+z;R.forEach((H,N)=>{let U=M(H);if(e.lineWidth=1,e.beginPath(),e.moveTo(U,T+C),e.lineTo(U,T+C+6),e.stroke(),N%W===0){let X=Se(H);e.fillText(X,U,T+C+10),u=Math.max(u,U+e.measureText(X).width/2)}}),e.textAlign="right",e.textBaseline="middle";let G=[];for(let H=D;H<=A+k*.01;H+=k)G.push(H);let E=ie(C/Math.max(1,G.length-1),s.tick*1.1),_=P.tickW;G.forEach((H,N)=>{let U=L(H);e.lineWidth=1,e.beginPath(),e.moveTo(w-6,U),e.lineTo(w,U),e.stroke(),N%E===0&&e.fillText(Se(H),w-10,U)}),e.font=I(s.axisLabel,i,l,"bold"),e.textAlign="center",e.textBaseline="top",le(e,t.xLabel,w+z/2,T+C+40,o,r,s.axisLabel,H=>I(H,i,l,"bold")),e.font=I(s.axisLabel,i,l,"bold"),t.xUnit&&(B?(e.font=I(s.tick,i,l,"bold"),e.textAlign="left",e.textBaseline="top",e.fillText(t.xUnit,u+6,T+C+10),e.font=I(s.axisLabel,i,l,"bold")):(e.textAlign="right",e.textBaseline="top",e.fillText(t.xUnit,w+z+10,T+C+40))),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",le(e,t.yUnit,w-10,T-16,o,r,s.axisLabel,H=>I(H,i,l,"bold"))),e.font=I(P.size,i,l,"bold"),e.textAlign="right",e.textBaseline="middle";let O=P.size*1.3;if(pe(e,P.lines,w-18-_,sn(e,P.lines,T+C/2,O,r),O),e.font=I(s.axisLabel,i,l,"bold"),Un(e,t,M,L,s,i,l,n.showDataLabels,{left:w,right:w+z,top:T,bottom:T+C},o,r),b){let H=w+z+20,N=T;g&&(Xn(e,g,H,N,i,l),N+=g.boxH+8),p.boxH>0&&jn(e,t,H,N,p,s,i,l)}else if(t.showBubble&&t.points.length>0){let H=$n(t,M,L),N=en(e,t,s,i,l),U=Kn(e,t,w,T,z,C,s,i,l,H,N.boxH);Jo(e,t,w,T,z,C,U.bottom,s,i,l,U.corner)}j({ctx:e,plotX:w,plotW:z,title:n.title,fontSize:s.title,canvasWidth:o}),K({ctx:e,plotX:w,plotW:z,height:r,source:n.source,sourceInline:n.sourceInline,footnotes:n.footnotes,fontSize:s.dataLabel,canvasWidth:o})}function Xo(e,o,r,t,n){let i=n.fontFamily,l=n.customFont,s=n.fontSize,b={top:n.title?100:t.boxedAxisLabels?120:50,right:t.boxedAxisLabels?170:80,bottom:(()=>{let u=90,G=n.footnotes.filter(E=>E.trim()).length;return n.source&&!(n.sourceInline&&G>0)&&(u+=30),u+=G*22,u})(),left:130},g=b.left,p=b.top,f=o-b.left-b.right,h=r-b.top-b.bottom,y=t.points.map(u=>Math.abs(u.x)),a=t.points.map(u=>Math.abs(u.y)),m=y.length>0?Math.max(...y):10,c=a.length>0?Math.max(...a):10,d=Nn(m),S=Nn(c),D=t.xRange.auto?d.limit:Math.max(Math.abs(t.xRange.min),Math.abs(t.xRange.max)),A=t.yRange.auto?S.limit:Math.max(Math.abs(t.yRange.min),Math.abs(t.yRange.max)),v=t.xRange.step??(t.xRange.auto?d.step:D/4),k=t.yRange.step??(t.yRange.auto?S.step:A/4),P=u=>g+(u+D)/(2*D)*f,F=u=>p+h-(u+A)/(2*A)*h,w=P(0),T=F(0);e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]);for(let u=-D+v;u<D;u+=v){if(Math.abs(u)<v*.01)continue;let G=P(u);e.beginPath(),e.moveTo(G,p),e.lineTo(G,p+h),e.stroke()}for(let u=-A+k;u<A;u+=k){if(Math.abs(u)<k*.01)continue;let G=F(u);e.beginPath(),e.moveTo(g,G),e.lineTo(g+f,G),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,t.showFrame!==!1&&(e.beginPath(),e.moveTo(g,p),e.lineTo(g,p+h),e.lineTo(g+f,p+h),e.lineTo(g+f,p),e.closePath(),e.stroke()),e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.moveTo(w,p),e.lineTo(w,p+h),e.stroke(),e.beginPath(),e.moveTo(g,T),e.lineTo(g+f,T),e.stroke(),e.fillStyle="#000",e.font=I(s.tick,i,l,"bold"),e.textAlign="right",e.textBaseline="top",e.fillText("0",w-6,T+4);let z=t.ticksOnAxis?T:p+h,C=t.ticksOnAxis?w:g;e.textAlign="center",e.textBaseline="top";let M=[];for(let u=-D;u<=D+v*.01;u+=v)M.push(u);let L=ie(f/Math.max(1,M.length-1),oe(e,M.map(Se)));M.forEach((u,G)=>{if(Math.abs(u)<v*.01)return;let E=P(u);e.lineWidth=1,e.beginPath(),e.moveTo(E,z),e.lineTo(E,z+6),e.stroke(),G%L===0&&e.fillText(Se(u),E,z+10)}),e.textAlign="right",e.textBaseline="middle";let B=[];for(let u=-A;u<=A+k*.01;u+=k)B.push(u);let R=ie(h/Math.max(1,B.length-1),s.tick*1.1),W=oe(e,B.map(Se));if(B.forEach((u,G)=>{if(Math.abs(u)<k*.01)return;let E=F(u);e.lineWidth=1,e.beginPath(),e.moveTo(C-6,E),e.lineTo(C,E),e.stroke(),G%R===0&&e.fillText(Se(u),C-10,E)}),e.font=I(s.axisLabel,i,l,"bold"),t.boxedAxisLabels||(e.textAlign="center",e.textBaseline="top",e.fillText(t.xLabel,g+f/2,p+h+40)),t.xUnit&&(e.textAlign=t.ticksOnAxis?"left":"right",e.textBaseline="top",e.fillText(t.xUnit,g+f+(t.ticksOnAxis?20:10),t.ticksOnAxis?T+10:p+h+40)),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",e.fillText(t.yUnit,t.ticksOnAxis?w-10:g-10,t.ticksOnAxis?p-6:p-16)),t.boxedAxisLabels){_n(e,t.yLabel,w,10,s.axisLabel,"below");let u=t.xUnit&&t.ticksOnAxis?e.measureText(t.xUnit).width+14:0;_n(e,t.xLabel,g+f+16+u,p+h/2,s.axisLabel,"right")}else e.textAlign="right",e.textBaseline="middle",rn(e,t.yLabel,C-18-W,p+h/2,s.axisLabel*1.3);Un(e,t,P,F,s,i,l,n.showDataLabels,{left:g,right:g+f,top:p,bottom:p+h},o,r),t.showBubble&&t.points.length>0&&Kn(e,t,g,p,f,h,s,i,l,$n(t,P,F)),j({ctx:e,plotX:g,plotW:f,title:n.title,fontSize:s.title,canvasWidth:o}),K({ctx:e,plotX:g,plotW:f,height:r,source:n.source,sourceInline:n.sourceInline,footnotes:n.footnotes,fontSize:s.dataLabel,canvasWidth:o})}function Un(e,o,r,t,n,i,l,s,b,g,p){let f=o.points.length>0?Math.max(...o.points.map(a=>a.size),1):1,h=new we;if(b)for(let a of o.points){let m=o.showBubble&&a.size>0?a.size/f*o.bubbleScale:4;h.reserveCircle(r(a.x),t(a.y),m)}let y=[...o.points].sort((a,m)=>m.size-a.size);for(let a of y){let m=r(a.x),c=t(a.y);if(o.showBubble&&a.size>0){let d=a.size/f*o.bubbleScale;e.fillStyle="#fff",e.beginPath(),e.arc(m,c,d,0,Math.PI*2),e.fill(),e.fillStyle=a.fill??"rgba(80,80,80,0.3)",e.beginPath(),e.arc(m,c,d,0,Math.PI*2),e.fill(),e.strokeStyle="#333",e.lineWidth=1.5,e.stroke()}else e.fillStyle="#000",e.beginPath(),e.arc(m,c,4,0,Math.PI*2),e.fill();if(a.label){e.fillStyle="#000",e.font=I(n.dataLabel,i,l,"bold");let d=o.showBubble&&a.size>0?a.size/f*o.bubbleScale+4:8;b?h.place(e,a.label,m,c,{gap:d,lineHeight:n.dataLabel*1.1,bounds:b}):(e.textAlign="left",e.textBaseline="bottom",e.fillText(a.label,m+d,c-2))}if(s){e.fillStyle="#555",e.font=I(n.dataLabel*.8,i,l,"normal"),e.textAlign="left",e.textBaseline="top";let d=o.showBubble&&a.size>0?a.size/f*o.bubbleScale+4:8,S=`(${a.x}, ${a.y})`,D=fe(e,S,m+d,c+2,g,p);e.fillText(S,D.x,D.y)}}}function Nn(e){if(e===0)return{limit:10,step:2};let o=e*.2,r=e+o,t=Math.pow(10,Math.floor(Math.log10(r))),n=r/t,i;n<=1.5?i=1.5:n<=2?i=2:n<=3?i=3:n<=5?i=5:i=10;let l=i*t,s=l/4;return{limit:l,step:s}}function Se(e){return Math.abs(e)<1e-4?"0":Number(e.toFixed(2)).toString()}function Ko(e,o,r,t,n,i,l,s,b){e.save(),e.font=I(l.tick,s,b,"bold");let g=[];for(let d=t;d<=n+i*.01;d+=i)g.push(d);let p=oe(e,g.map(Se)),f=d=>I(d,s,b,"bold");e.font=f(l.axisLabel);let h=(o.yLabel||"").split("\\n"),y=Math.max(40,r*.3-18-p-12),a=h.flatMap(d=>re(e,d,y)),m=l.axisLabel;$t(e,a)>y&&(m=Le(e,a,l.axisLabel,y,f),e.font=f(m),a=h.flatMap(d=>re(e,d,y)));let c=$t(e,a);return e.restore(),{lines:a,size:m,tickW:p,reserve:18+p+c+12}}function $n(e,o,r){let t=e.points.length>0?Math.max(...e.points.map(n=>n.size),1):1;return e.points.map(n=>{let i=e.showBubble&&n.size>0?n.size/t*e.bubbleScale:4,l=o(n.x),s=r(n.y);return{x0:l-i,y0:s-i,x1:l+i,y1:s+i}})}var jo=["top-right","top-left","bottom-right","bottom-left"];function Vo(e){return e==="outside-right"||!e?"top-right":e}function qo(e,o,r,t,n,i,l,s,b=0){let g=r+(b>0?b+6:0),p=a=>({x:a.endsWith("right")?t+i-o-10:t+10,y:a.startsWith("top")?n+10:n+l-g-10}),f=(a,m)=>s.reduce((c,d)=>{let S=Math.min(d.x1,a+o)-Math.max(d.x0,a),D=Math.min(d.y1,m+g)-Math.max(d.y0,m);return c+(S>0&&D>0?S*D:0)},0),h=[e,...jo.filter(a=>a!==e)],y={corner:e,...p(e),score:1/0};for(let a of h){let{x:m,y:c}=p(a),d=f(m,c);if(d<y.score&&(y={corner:a,x:m,y:c,score:d}),d===0)break}return{corner:y.corner,x:y.x,y:y.y}}function en(e,o,r,t,n){let i=o.fillLegend;if(!i||i.items.length===0)return{boxW:0,boxH:0};let l=r.dataLabel*.8;e.save(),e.font=I(l,t,n,"bold");let s=l*1.5,b=l*.95,g=8,p=i.title?s:0,f=Math.max(i.title?e.measureText(i.title).width:0,...i.items.map(h=>b+6+e.measureText(h.label).width));return e.restore(),{boxW:f+g*2,boxH:p+i.items.length*s+g*2}}function Yn(e,o,r,t,n){let i=o.points.map(k=>k.size).filter(k=>k>0);if(i.length===0)return null;let l=Math.max(...i);if(l===0)return null;let s=o.bubbleLegendItems?.filter(k=>k.size>0&&k.size<=l)??[],b=s.length>0?s.map(k=>k.size):[l,Math.round(l*.5),Math.round(l*.2)].filter(k=>k>0),g=[...new Set(b)].sort((k,P)=>P-k),p=k=>s.find(P=>P.size===k)?.label??String(k),f=k=>k/l*o.bubbleScale,h=f(g[0]),y=r.dataLabel*.85;e.save(),e.font=I(y,t,n,"bold");let a=Math.max(50,...g.map(k=>e.measureText(p(k)).width));e.restore();let m=14,c=h*2+a+m*2+20,d=y*1.2,S=[],D=-1/0;for(let k of g){let P=f(k);D=Math.max(-2*P,D+d),S.push(D)}let A=Math.max(0,...S)+y/2,v=h*2+A+m*2+10;return{uniqueSteps:g,labelOf:p,radiusOf:f,maxR:h,boxW:c,boxH:v,labelOffsets:S,lowest:A,labelFontSize:y,pad:m}}function Xn(e,o,r,t,n,i){e.fillStyle="#fff",e.strokeStyle="#666",e.lineWidth=1.5,e.beginPath(),e.roundRect(r,t,o.boxW,o.boxH,4),e.fill(),e.stroke();let l=r+o.pad+o.maxR,s=t+o.boxH-o.pad-o.lowest;o.uniqueSteps.forEach((b,g)=>{let p=o.radiusOf(b),f=s-p;e.strokeStyle="#333",e.lineWidth=1.5,e.beginPath(),e.arc(l,f,p,0,Math.PI*2),e.stroke(),e.save(),e.strokeStyle="#666",e.lineWidth=1,e.setLineDash([3,2]);let h=f-p;e.beginPath(),e.moveTo(l,h),e.lineTo(l+o.maxR+12,h),e.stroke(),e.restore(),e.fillStyle="#000",e.font=I(o.labelFontSize,n,i,"bold"),e.textAlign="left",e.textBaseline="middle",e.fillText(o.labelOf(b),l+o.maxR+16,s+o.labelOffsets[g])})}function Kn(e,o,r,t,n,i,l,s,b,g=[],p=0){let f=Vo(o.bubbleLegendPosition),h=Yn(e,o,l,s,b);if(!h)return{height:0,corner:f,bottom:0};let y=qo(f,h.boxW,h.boxH,r,t,n,i,g,p);return Xn(e,h,y.x,y.y,s,b),{height:h.boxH,corner:y.corner,bottom:y.y+h.boxH}}function _n(e,o,r,t,n,i){if(!o)return;let l=o.split("\\n"),s=n*1.25,b=8,g=6;e.save();let f=Math.max(...l.map(m=>e.measureText(m).width))+b*2,h=l.length*s+g*2,y=i==="below"?r-f/2:r,a=i==="below"?t:t-h/2;e.fillStyle="#fff",e.fillRect(y,a,f,h),e.strokeStyle="#000",e.lineWidth=1.2,e.strokeRect(y,a,f,h),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";for(let m=0;m<l.length;m++)e.fillText(l[m],y+f/2,a+g+m*s);e.restore()}function jn(e,o,r,t,n,i,l,s){let b=o.fillLegend;if(!b||b.items.length===0)return;let g=i.dataLabel*.8;e.save(),e.font=I(g,l,s,"bold");let p=g*1.5,f=g*.95,h=8;e.fillStyle="#fff",e.fillRect(r,t,n.boxW,n.boxH),e.strokeStyle="#666",e.lineWidth=1.5,e.setLineDash([]),e.strokeRect(r,t,n.boxW,n.boxH);let y=t+h;b.title&&(e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(b.title,r+n.boxW/2,y),y+=p);for(let a of b.items)e.fillStyle=a.fill,e.fillRect(r+h,y+(p-f)/2,f,f),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(r+h,y+(p-f)/2,f,f),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(a.label,r+h+f+6,y+p/2),y+=p;e.restore()}function Jo(e,o,r,t,n,i,l,s,b,g,p="bottom-right"){let f=o.fillLegend;if(!f||f.items.length===0)return;let h=en(e,o,s,b,g),y=p.endsWith("right")?r+n-h.boxW-10:r+10,a=l>0?l+6:p.startsWith("top")?t+10:t+i-h.boxH-10;jn(e,o,y,a,h,s,b,g)}function rt(e,o,r,t,n){$(e,o,r),t.displayMode==="bar"?Zo(e,o,r,t,n):Qo(e,o,r,t,n)}function Zo(e,o,r,t,n){let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"?Q(e,t.seriesLabels,n.fontSize.dataLabel*.85+5):0,b=t.barDirection==="vertical",g=i&&l==="bottom"?te(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-(b?80:100)-(b?60+s:160+s)):0,p={top:n.title?100:50,right:b?60+s:160+s,bottom:(()=>{let D=b?70:60;return i&&l==="bottom"&&(D+=60),D=Math.max(D,g),n.source&&(D+=30),D+=n.footnotes.filter(A=>A.trim()).length*22,D})(),left:b?80:100},f=p.left,h=p.top,y=o-p.left-p.right,a=r-p.top-p.bottom,m=n.fontFamily,c=n.customFont,d=t.categories.length,S=t.seriesLabels.length;if(e.strokeStyle="#000",e.lineWidth=2,b){e.beginPath(),e.moveTo(f,h),e.lineTo(f,h+a),e.lineTo(f+y,h+a),e.lineTo(f+y,h),e.lineTo(f,h),e.stroke();let D=t.axisStep??20;e.font=I(n.fontSize.tick,m,c,"bold"),e.fillStyle="#000",e.textAlign="right",e.textBaseline="middle";for(let k=0;k<=100;k+=D){let P=h+a-k/100*a;e.lineWidth=1,e.beginPath(),e.moveTo(f-5,P),e.lineTo(f,P),e.stroke(),e.fillText(String(k),f-10,P),k>0&&k<100&&(e.save(),e.strokeStyle=t.gridColor??"#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(f,P),e.lineTo(f+y,P),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,m,c,"bold"),e.textAlign="right",e.textBaseline="bottom",e.fillText(t.unit,f-10,h-16);let A=y/d,v=Math.min(A*.3,84);for(let k=0;k<d;k++){let P=f+A*k+A/2,F=t.categories[k].values.reduce((T,z)=>T+z,0),w=0;for(let T of Vn(t.categories[k],S)){let z=t.categories[k].values[T]||0,M=(F>0?z/F:0)*a,L=h+a-w-M;e.fillStyle=ot(e,t,T),e.fillRect(P-v/2,L,v,M),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(P-v/2,L,v,M),t.labelInSegment?xo(e,t,n,T,P,L+M/2,v,M,Fe(t,T),m,c):n.showDataLabels&&M>n.fontSize.dataLabel&&(e.fillStyle=Fe(t,T)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,m,c,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(z),P,L+M/2)),w+=M}e.fillStyle="#000",e.font=I(n.fontSize.tick,m,c,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText(t.categories[k].label,P,h+a+12)}}else{e.beginPath(),e.moveTo(f,h),e.lineTo(f,h+a),e.lineTo(f+y,h+a),e.lineTo(f+y,h),e.lineTo(f,h),e.stroke();let D=t.axisStep??20;e.font=I(n.fontSize.tick,m,c,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";for(let k=0;k<=100;k+=D){let P=f+k/100*y;e.lineWidth=1,e.beginPath(),e.moveTo(P,h+a),e.lineTo(P,h+a+5),e.stroke(),e.fillText(String(k),P,h+a+10),k>0&&k<100&&(e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(P,h),e.lineTo(P,h+a),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,m,c,"bold"),e.textAlign="left",e.textBaseline="top",e.fillText(t.unit,f+y+30,h+a+10);let A=a/d,v=Math.min(A*.3,84);for(let k=0;k<d;k++){let P=h+A*k+A/2,F=t.categories[k].values.reduce((T,z)=>T+z,0),w=0;for(let T of Vn(t.categories[k],S)){let z=t.categories[k].values[T]||0,M=(F>0?z/F:0)*y,L=f+w;e.fillStyle=ot(e,t,T),e.fillRect(L,P-v/2,M,v),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(L,P-v/2,M,v),n.showDataLabels&&M>n.fontSize.dataLabel*2&&(e.fillStyle=Fe(t,T)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,m,c,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(z),L+M/2,P)),w+=M}e.fillStyle="#000",e.font=I(n.fontSize.tick,m,c,"bold"),e.textAlign="right",e.textBaseline="middle",e.fillText(t.categories[k].label,f-10,P)}}if(j({ctx:e,plotX:f,plotW:y,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i){let D=t.seriesLabels.map((A,v)=>({type:"rect",fillStyle:ot(e,t,v),bordered:Fe(t,v),label:A}));ee({ctx:e,items:D,position:l,plotX:f,plotY:h,plotW:y,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}K({ctx:e,plotX:f,plotW:y,height:r,source:n.source,sourceLeft:n.sourceLeft,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Qo(e,o,r,t,n){let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"?Q(e,t.seriesLabels,n.fontSize.dataLabel*.85+5):0,b=i&&l==="bottom"?te(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-60-(60+s),"rect",16):0,g={top:n.title?100:50,right:60+s,bottom:(()=>{let L=50;return i&&l==="bottom"&&(L+=60),L=Math.max(L,b),n.source&&(L+=30),L+=n.footnotes.filter(B=>B.trim()).length*22,L})(),left:60},p=g.left,f=g.top,h=o-g.left-g.right,y=r-g.top-g.bottom,a=n.fontFamily,m=n.customFont,c=t.categories.length,d=t.seriesLabels.length,S=(t.pieScale??100)/100,D=(t.pieRotation??0)*Math.PI/180,A=24,v=n.fontSize.tick+16,k=h/c,F=Math.min(k*.4,(y-v)*.4)*S,w=c<=5?c:Math.ceil(Math.sqrt(c)),T=Math.ceil(c/w),z=h/w,C=y/T,M=Math.min(F,(z-A)/2,(C-v-A)/2);for(let L=0;L<c;L++){let B=L%w,R=Math.floor(L/w),W=p+z*B+z/2,u=f+C*R+(C-v)/2,G=t.categories[L].values.reduce((_,O)=>_+O,0),E=-Math.PI/2+D;for(let _=0;_<d;_++){let O=t.categories[L].values[_]||0,H=G>0?O/G:0,N=E+H*Math.PI*2;if(e.fillStyle=ot(e,t,_),e.beginPath(),e.moveTo(W,u),e.arc(W,u,M,E,N),e.closePath(),e.fill(),e.strokeStyle="#000",e.lineWidth=1,e.stroke(),n.showDataLabels&&H>.05){let U=(E+N)/2,X=W+Math.cos(U)*M*.65,q=u+Math.sin(U)*M*.65;e.fillStyle=Fe(t,_)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,a,m,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(O),X,q)}E=N}e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.arc(W,u,M,0,Math.PI*2),e.stroke(),e.fillStyle="#000",e.font=I(n.fontSize.tick,a,m,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText(t.categories[L].label,W,u+M+12)}if(j({ctx:e,plotX:p,plotW:h,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i){let L=t.seriesLabels.map((B,R)=>({type:"rect",fillStyle:ot(e,t,R),bordered:Fe(t,R),label:B}));if(l==="right"){let B=Math.min(w-1,c-1),W=p+z*B+z/2+M-p,u=T-1,_=f+C*u+(C-v)/2+M+12+n.fontSize.tick-f;ee({ctx:e,items:L,position:l,plotX:p,plotY:f,plotW:W,plotH:_,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}else{let B=T-1,u=f+C*B+(C-v)/2+M+12+n.fontSize.tick-f;ee({ctx:e,items:L,position:l,plotX:p,plotY:f,plotW:h,plotH:u,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,bottomOffset:16})}}K({ctx:e,plotX:p,plotW:h,height:r,source:n.source,sourceLeft:n.sourceLeft,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Vn(e,o){let r=e.segmentOrder;if(!r||r.length===0)return Array.from({length:o},(n,i)=>i);let t=Array.from({length:o},(n,i)=>i).filter(n=>!r.includes(n));return[...r.filter(n=>n>=0&&n<o),...t]}function ot(e,o,r){let t=o.seriesFills?.[r];return t==null?ht(e,r):gt(e,t)}function Fe(e,o){let r=e.seriesFills?.[o];return r==null?ce(o):dt(r)}function xo(e,o,r,t,n,i,l,s,b,g,p){let f=o.seriesLabels[t]??"",h=r.fontSize.dataLabel*.9;if(!f||s<h*1.1)return;let y=o.seriesIsSymbol&&!o.seriesIsSymbol[t]?"sans":g;e.font=I(h,y,p,"bold"),e.textAlign="center",e.textBaseline="middle";let a=Math.max(1,l-6);b?(e.save(),e.lineWidth=3,e.strokeStyle="#fff",e.lineJoin="round",e.strokeText(f,n,i,a),e.restore(),e.fillStyle="#000"):e.fillStyle="#fff",e.fillText(f,n,i,a)}function ue(e,o,r,t,n,i){let l=e+o+r;if(l===0)return{x:t,y:n};let s=e/l,b=o/l,g=r/l,p=i*Math.sqrt(3)/2,f=t,h=n-p*2/3,y=t-i/2,a=n+p/3,m=t+i/2,c=n+p/3,d=g*f+s*y+b*m,S=g*h+s*a+b*c;return{x:d,y:S}}function it(e,o,r,t,n){$(e,o,r);let i=12+n.fontSize.tick+10,l=n.fontSize.axisLabel*1.3+30,s=i+l;n.source&&(s+=n.fontSize.dataLabel+10),s+=n.footnotes.filter(R=>R.trim()).length*22;let b={top:n.title?80:50,right:120,bottom:s,left:120},g=b.left,p=o-b.left-b.right,f=r-b.top-b.bottom,h=p*.9,y=f*2/Math.sqrt(3),a=tr(e,t.axisLabels,n,o,r,g+p/2,b.top,Math.min(h,y)),m=a.size,c=m*Math.sqrt(3)/2,d=g+p/2,S=b.top+11+c*2/3,D=n.fontFamily,A=n.customFont,v={x:d,y:S-c*2/3},k={x:d-m/2,y:S+c/3},P={x:d+m/2,y:S+c/3},F=t.gridInterval,w=100/F;e.save(),e.strokeStyle="#ccc",e.lineWidth=.5;for(let R=1;R<w;R++){let W=R*F,u=ue(100-W,0,W,d,S,m),G=ue(0,100-W,W,d,S,m);e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(G.x,G.y),e.stroke();let E=ue(W,100-W,0,d,S,m),_=ue(W,0,100-W,d,S,m);e.beginPath(),e.moveTo(E.x,E.y),e.lineTo(_.x,_.y),e.stroke();let O=ue(0,W,100-W,d,S,m),H=ue(100-W,W,0,d,S,m);e.beginPath(),e.moveTo(O.x,O.y),e.lineTo(H.x,H.y),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(v.x,v.y),e.lineTo(k.x,k.y),e.lineTo(P.x,P.y),e.closePath(),e.stroke();let T=12,z={x:-1,y:0},C={x:Math.cos(Math.PI/3),y:Math.sin(Math.PI/3)},M={x:Math.cos(Math.PI/3),y:-Math.sin(Math.PI/3)};e.fillStyle="#000",e.font=I(n.fontSize.tick,D,A,"bold"),e.strokeStyle="#000",e.lineWidth=1.5;for(let R=0;R<=w;R++){let W=R*F,u=ue(100-W,0,W,d,S,m);e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(u.x+z.x*T,u.y+z.y*T),e.stroke(),e.textAlign="right",e.textBaseline="middle",e.fillText(String(W),u.x+z.x*T-4,u.y+z.y*T);let G=ue(W,100-W,0,d,S,m);e.beginPath(),e.moveTo(G.x,G.y),e.lineTo(G.x+C.x*T,G.y+C.y*T),e.stroke(),e.textAlign="center",e.textBaseline="top",e.fillText(String(W),G.x+C.x*T,G.y+C.y*T+4);let E=ue(0,W,100-W,d,S,m);e.beginPath(),e.moveTo(E.x,E.y),e.lineTo(E.x+M.x*T,E.y+M.y*T),e.stroke(),e.textAlign="left",e.textBaseline="middle";let _=W===100?"100 (%)":String(W),O=fe(e,_,E.x+M.x*T+4,E.y+M.y*T,o,r);e.fillText(_,O.x,O.y)}e.font=I(a.fontSize,D,A,"bold"),e.fillStyle="#000";let L=a.fontSize*1.3,B=tn(o,g+p/2,b.top,m,a.lines,L);for(let R=0;R<3;R++)e.textAlign=B[R].align,e.textBaseline=B[R].baseline,pe(e,a.lines[R],B[R].x,B[R].y,L);for(let R=0;R<t.points.length;R++){let W=t.points[R],{x:u,y:G}=ue(W.b,W.c,W.a,d,S,m);e.fillStyle="#000",e.beginPath(),e.arc(u,G,6,0,Math.PI*2),e.fill(),W.label&&(e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,D,A,"bold"),e.textAlign="left",e.textBaseline="bottom",e.fillText(W.label,u+10,G-4)),n.showDataLabels&&(e.fillStyle="#555",e.font=I(n.fontSize.dataLabel*.8,D,A),e.textAlign="left",e.textBaseline="top",e.fillText(`(${W.a}, ${W.b}, ${W.c})`,u+10,G+4))}j({ctx:e,plotX:g,plotW:p,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),K({ctx:e,plotX:k.x,plotW:P.x-k.x,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var er=.8;function tn(e,o,r,t,n,i){let l=t*Math.sqrt(3)/2,s=r+11+l*2/3,b=s-l*2/3,g=s+l/3,p=o-t/4,f=(b+g)/2,h=o+t/4,y=g+52;return[{x:p-52,y:f,align:"right",baseline:"middle"},{x:o,y:y+(n[1].length-1)*i/2,align:"center",baseline:"top"},{x:h+52,y:f,align:"left",baseline:"middle"}]}function tr(e,o,r,t,n,i,l,s){e.save();let b=a=>I(a,r.fontFamily,r.customFont,"bold"),g=r.fontSize.axisLabel*1.3,p=o.map(a=>(a||"").split("\\n")),f=p.map(a=>a.slice()),h=a=>{e.font=b(g);let m=g*1.3;return tn(t,i,l,a,f,m).every((d,S)=>{e.textAlign=d.align,e.textBaseline=d.baseline;let D=f[S].map(v=>be(e,v)),A=(f[S].length-1)*m/2;return d.x-Math.max(...D.map(v=>v.left))>=1&&d.x+Math.max(...D.map(v=>v.right))<=t-1&&d.y-A-Math.max(...D.map(v=>v.up))>=1&&d.y+A+Math.max(...D.map(v=>v.down))<=n-1})},y=se(40,s,h);if(y<s*er){e.font=b(g);let a=g*1.3,m=tn(t,i,l,s,f,a);f=p.map((c,d)=>{let S=m[d],D=S.align==="left"?t-1-S.x:S.align==="right"?S.x-1:2*Math.min(S.x-1,t-1-S.x);return c.flatMap(A=>re(e,A,Math.max(30,D)))}),y=se(40,s,h)}return y<=40&&(g=r.fontSize.axisLabel*1.3*.7,e.font=b(g),f=f.map(a=>a.flatMap(m=>re(e,m,Math.max(30,t/3)))),y=se(40,s,h)),e.restore(),{size:y,lines:f,fontSize:g}}var Me={absbar:{render:_e,createDefaultData:Dt},"category-dot":{render:$e,createDefaultData:zt},climate:{render:Ve,createDefaultData:St},cube:{render:qe,createDefaultData:At},"data-table":{render:Ke,createDefaultData:Ft},"deviation-a":{render:Je,createDefaultData:ct},"deviation-b":{render:Ze,createDefaultData:yt},hythergraph:{render:Qe,createDefaultData:Ct},line:{render:Ye,createDefaultData:Wt},"matrix-table":{render:Xe,createDefaultData:Gt},pyramid:{render:et,createDefaultData:Lt},radar:{render:tt,createDefaultData:Pt},scatter:{render:nt,createDefaultData:kt},stacked:{render:rt,createDefaultData:vt},ternary:{render:it,createDefaultData:Tt},treemap:{render:je,createDefaultData:Bt}},lt=Object.freeze(Object.keys(Me).sort());function Et(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(Me,e)}var Z=class extends Error{constructor(o){super(`csat-chart: ${o}`),this.name="CsatChartError"}},nr={climate:{months:12},"deviation-a":{baseMonths:12,months:12},ternary:{axisLabels:3},scatter:{quadrantLabels:4}},or={object:"\uAC1D\uCCB4",number:"\uC22B\uC790",string:"\uBB38\uC790\uC5F4",boolean:"\uBD88\uB9AC\uC5B8",undefined:"undefined",function:"\uD568\uC218"};function Re(e){return Array.isArray(e)?"\uBC30\uC5F4":e===null?"null":or[typeof e]??typeof e}function at(e){let o=e.charCodeAt(e.length-1),t=o>=44032&&o<=55203?(o-44032)%28!==0:!0;return`${e}${t?"\uC774\uC5B4\uC57C":"\uC5EC\uC57C"} \uD569\uB2C8\uB2E4`}function rr(e,o){let r=Array.from({length:o.length+1},(t,n)=>n);for(let t=1;t<=e.length;t++){let n=[t];for(let i=1;i<=o.length;i++)n[i]=Math.min(r[i]+1,n[i-1]+1,r[i-1]+(e[t-1]===o[i-1]?0:1));r=n}return r[o.length]}function ir(e){let o=null,r=1/0;for(let t of lt){let n=rr(e.toLowerCase(),t);n<r&&(r=n,o=t)}return r<=3?o:null}function qn(e){if(Et(e))return;let o=typeof e=="string"?ir(e):null;throw new Z(`\uC54C \uC218 \uC5C6\uB294 type ${JSON.stringify(e)}`+(o?` \u2014 \uD639\uC2DC "${o}"?`:` \u2014 \uC4F8 \uC218 \uC788\uB294 \uAC12: ${lt.join(", ")}`))}function Jn(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Z(`config \uB294 ${at("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Re(e)})`);let o=e.options;if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))throw new Z(`config.options \uB294 ${at("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Re(o)})`)}function nn(e,o){if(typeof o!="object"||o===null||Array.isArray(o))throw new Z(`type "${e}" \uC758 data \uB294 ${at("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Re(o)})`);let r=o,t=Me[e].createDefaultData(),n=nr[e]??{};for(let i of Object.keys(t)){if(!(i in r))throw new Z(`type "${e}" \uC758 data \uC5D0 ${i} \uD56D\uBAA9\uC774 \uC5C6\uC2B5\uB2C8\uB2E4`);let l=Re(t[i]),s=Re(r[i]);if(l!==s)throw new Z(`type "${e}" \uC758 data.${i}: ${at(l)} (\uC9C0\uAE08 ${s})`);let b=n[i];if(b!==void 0){let p=r[i].length;if(p!==b)throw new Z(`type "${e}" \uC758 data.${i}: ${b}\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${p}\uAC1C)`)}let g=t[i];if(l==="\uBC30\uC5F4"&&Array.isArray(g)&&g.length>0){let p=Re(g[0]),f=r[i];for(let h=0;h<f.length;h++){let y=Re(f[h]);if(y!==p)throw new Z(`type "${e}" \uC758 data.${i}[${h}]: ${at(p)} (\uC9C0\uAE08 ${y})`)}}}}var lr="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&family=Noto+Serif+KR:wght@400;700&display=swap",ar=["Noto Serif KR","Noto Sans KR"],Zn="csat-chart-fonts",Qn=null;function Ot(e={}){return typeof document>"u"?Promise.resolve(!1):(Qn??(Qn=sr(e)),Qn)}async function sr(e){let o=e.href??lr,r=e.families??ar,t=e.timeoutMs??5e3;try{if(!document.getElementById(Zn)){let b=document.createElement("link");b.id=Zn,b.rel="stylesheet",b.href=o,document.head.appendChild(b)}}catch{return!1}let n=document.fonts;if(!n)return!1;let i=(async()=>{for(let b of r)await n.load(`400 16px "${b}"`),await n.load(`700 16px "${b}"`);return!0})(),l,s=new Promise(b=>{l=setTimeout(()=>b(!1),t)});try{return await Promise.race([i.catch(()=>!1),s])}finally{clearTimeout(l)}}function fr(e){if(e===void 0)return{tl:0,tr:0,br:0,bl:0};if(typeof e=="number"){if(!(e>=0))throw new RangeError("roundRect: \uBC18\uC9C0\uB984\uC740 0 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");return{tl:e,tr:e,br:e,bl:e}}if(e.some(o=>!(o>=0)))throw new RangeError("roundRect: \uBC18\uC9C0\uB984\uC740 0 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");switch(e.length){case 1:return{tl:e[0],tr:e[0],br:e[0],bl:e[0]};case 2:return{tl:e[0],br:e[0],tr:e[1],bl:e[1]};case 3:return{tl:e[0],tr:e[1],bl:e[1],br:e[2]};case 4:return{tl:e[0],tr:e[1],br:e[2],bl:e[3]};default:throw new RangeError(`roundRect: \uBC18\uC9C0\uB984 \uBC30\uC5F4\uC740 1~4\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${e.length}\uAC1C)`)}}function mr(e,o,r){let t=Math.min(1,o/(e.tl+e.tr)||1/0,r/(e.tr+e.br)||1/0,o/(e.bl+e.br)||1/0,r/(e.tl+e.bl)||1/0);return t>=1?e:{tl:e.tl*t,tr:e.tr*t,br:e.br*t,bl:e.bl*t}}function br(e,o,r,t,n,i){let l=mr(fr(i),Math.abs(t),Math.abs(n));e.moveTo(o+l.tl,r),e.lineTo(o+t-l.tr,r),l.tr>0&&e.arcTo(o+t,r,o+t,r+l.tr,l.tr),e.lineTo(o+t,r+n-l.br),l.br>0&&e.arcTo(o+t,r+n,o+t-l.br,r+n,l.br),e.lineTo(o+l.bl,r+n),l.bl>0&&e.arcTo(o,r+n,o,r+n-l.bl,l.bl),e.lineTo(o,r+l.tl),l.tl>0&&e.arcTo(o,r,o+l.tl,r,l.tl),e.closePath()}function Ht(){if(typeof CanvasRenderingContext2D>"u")return!1;let e=CanvasRenderingContext2D.prototype;return typeof e.roundRect=="function"?!1:(e.roundRect=function(o,r,t,n,i){br(this,o,r,t,n,i)},!0)}var ur=800,hr=600,gr=300,dr=150;function xn(e,o,r){let t=e[o];if(!t)return!0;if(t!==r)return!1;let n=e;return typeof n.getAttribute=="function"&&n.getAttribute(o)===null}function eo(e,o){return{...e,...o,fontSize:{...e.fontSize,...o?.fontSize},footnotes:[...o?.footnotes??e.footnotes]}}var Nt=class{constructor(o,r){this.destroyed=!1;this.canvas=pr(o);let t=this.canvas.getContext("2d");if(!t)throw new Z("\uCE94\uBC84\uC2A4\uC5D0\uC11C 2d \uCEE8\uD14D\uC2A4\uD2B8\uB97C \uC5BB\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4");this.ctx=t,Jn(r),qn(r.type),nn(r.type,r.data),this.type=r.type,this.data=r.data,this.options=eo(pt(),r.options),xn(this.canvas,"width",gr)&&(this.canvas.width=ur),xn(this.canvas,"height",dr)&&(this.canvas.height=hr),Ht(),this.draw(),this.redrawWhenFontsArrive()}static ensureFonts(o){return Ot(o)}update(o){return this.assertAlive(),o.data!==void 0&&(nn(this.type,o.data),this.data=o.data),o.options!==void 0&&(this.options=eo(this.options,o.options)),this.draw(),this}resize(o,r){if(this.assertAlive(),!(o>0)||!(r>0))throw new Z(`\uD06C\uAE30\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${o}\xD7${r})`);return this.canvas.width=o,this.canvas.height=r,this.draw(),this}toDataURL(o={}){if(this.assertAlive(),typeof this.canvas.toDataURL!="function")throw new Z("\uC774 \uCE94\uBC84\uC2A4\uB294 toDataURL \uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");let r=o.scale??1;if(!(Number.isFinite(r)&&r>0))throw new Z(`scale \uC740 0\uBCF4\uB2E4 \uD070 \uC720\uD55C\uD55C \uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${r})`);if(r===1)return this.canvas.toDataURL("image/png");let t=this.canvas.width,n=this.canvas.height;try{return this.canvas.width=Math.round(t*r),this.canvas.height=Math.round(n*r),this.drawScaled(r,t,n),this.canvas.toDataURL("image/png")}finally{this.canvas.width=t,this.canvas.height=n,this.draw()}}download(o="csat-chart.png",r={}){if(this.assertAlive(),typeof document>"u")throw new Z("download() \uB294 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C\uB9CC \uC501\uB2C8\uB2E4. Node \uC5D0\uC11C\uB294 toDataURL() \uC774\uB098 \uCE94\uBC84\uC2A4\uC758 \uBC84\uD37C\uB97C \uC4F0\uC138\uC694");let t=document.createElement("a");t.href=this.toDataURL(r),t.download=o,t.click()}destroy(){this.destroyed||($(this.ctx,this.canvas.width,this.canvas.height),this.destroyed=!0)}redrawWhenFontsArrive(){if(typeof document>"u")return;let o=document.fonts;o?.ready&&Promise.resolve(o.ready).then(()=>{this.destroyed||this.draw()}).catch(()=>{})}draw(){let{width:o,height:r}=this.canvas;$(this.ctx,o,r),Me[this.type].render(this.ctx,o,r,this.data,this.options)}drawScaled(o,r,t){this.ctx.setTransform(o,0,0,o,0,0);try{$(this.ctx,r,t),Me[this.type].render(this.ctx,r,t,this.data,this.options)}finally{this.ctx.setTransform(1,0,0,1,0,0)}}assertAlive(){if(this.destroyed)throw new Z("\uC774\uBBF8 destroy() \uB41C \uCC28\uD2B8\uC785\uB2C8\uB2E4")}};function pr(e){if(typeof e=="string"){if(typeof document>"u")throw new Z(`id \uBB38\uC790\uC5F4\uC740 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C\uB9CC \uC501\uB2C8\uB2E4 ("${e}")`);let o=document.getElementById(e);if(!o)throw new Z(`id "${e}" \uC778 \uC694\uC18C\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);if(o.tagName.toUpperCase()!=="CANVAS")throw new Z(`id "${e}" \uC778 \uC694\uC18C\uB294 <canvas> \uAC00 \uC544\uB2D9\uB2C8\uB2E4`);return o}if(e===null||typeof e!="object")throw new Z(`\uCCAB \uC778\uC790\uB294 <canvas> \uC694\uC18C\uC774\uAC70\uB098 id \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${e===null?"null":typeof e})`+(e===null?" \u2014 getElementById \uAC00 \uADF8 id \uB97C \uCC3E\uC9C0 \uBABB\uD55C \uAC83\uC740 \uC544\uB2CC\uC9C0 \uBCF4\uC138\uC694":""));if(typeof e.getContext!="function")throw new Z("\uCCAB \uC778\uC790\uC5D0 getContext \uAC00 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 <canvas> \uC694\uC18C\uAC00 \uB9DE\uB294\uC9C0 \uBCF4\uC138\uC694");return e}var cr=Object.freeze(ve),yr=Object.freeze(wt),Sr=Object.freeze(Ue),Lr=Object.freeze(De),Tr=Object.freeze(Rt),vr=Object.freeze(Mt),Dr=Object.freeze({solid:Object.freeze(ye.solid),dashed:Object.freeze(ye.dashed),dotted:Object.freeze(ye.dotted),dashdot:Object.freeze(ye.dashdot)});return lo(kr);})();
|
|
2
|
+
"use strict";var __csat=(()=>{var Jt=Object.defineProperty;var Fo=Object.getOwnPropertyDescriptor;var Go=Object.getOwnPropertyNames;var Io=Object.prototype.hasOwnProperty;var Bo=(e,o)=>{for(var r in o)Jt(e,r,{get:o[r],enumerable:!0})},Oo=(e,o,r,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Go(o))!Io.call(e,n)&&n!==r&&Jt(e,n,{get:()=>o[n],enumerable:!(t=Fo(o,n))||t.enumerable});return e};var Ho=e=>Oo(Jt({},"__esModule",{value:!0}),e);var ui={};Bo(ui,{AGE_GROUPS:()=>ii,CHART_TYPES:()=>ut,CsatChart:()=>jt,CsatChartError:()=>J,DOT_MARKER_ORDER:()=>li,LINE_DASH:()=>bi,LINE_MARKER_ORDER:()=>ai,LINE_STYLE_ORDER:()=>si,MONTH_LABELS_EN:()=>fi,MONTH_LABELS_NUM:()=>mi,autoRange:()=>V,createAdAsData:()=>In,createDefaultAbsBarData:()=>Mt,createDefaultCategoryDotData:()=>Gt,createDefaultClimateData:()=>vt,createDefaultCubeData:()=>Wt,createDefaultDataTableData:()=>Ot,createDefaultDeviationAData:()=>Lt,createDefaultDeviationBData:()=>Tt,createDefaultEconPlaneData:()=>zt,createDefaultGraphOptions:()=>St,createDefaultHythergraphData:()=>wt,createDefaultLineData:()=>It,createDefaultMatrixTableData:()=>Bt,createDefaultPyramidData:()=>Dt,createDefaultRadarData:()=>Et,createDefaultScatterData:()=>Rt,createDefaultStackedData:()=>At,createDefaultTernaryData:()=>kt,createDefaultTreemapData:()=>Ht,createPointShiftData:()=>Bn,createSupplyDemandData:()=>nn,ensureFonts:()=>qt,installRoundRectPolyfill:()=>Kt,isCsatChartType:()=>$t,niceStep:()=>Fe,renderAbsBarGraph:()=>$e,renderCategoryDotGraph:()=>Ke,renderClimateGraph:()=>et,renderCubeGraph:()=>tt,renderDataTable:()=>Je,renderDeviationAGraph:()=>nt,renderDeviationBGraph:()=>ot,renderEconPlane:()=>Qe,renderHythergraph:()=>rt,renderLineGraph:()=>je,renderMatrixTable:()=>Ve,renderPyramidGraph:()=>lt,renderRadarChart:()=>at,renderScatterGraph:()=>st,renderStackedGraph:()=>mt,renderTernaryGraph:()=>bt,renderTreemapGraph:()=>xe});var Tn="'Noto Serif KR', 'NanumMyeongjo', serif",vn="'Noto Sans KR', sans-serif",_o="'Noto Serif KR', serif";function Zt(e,o){return o==="custom"?e.customFont||_o:o==="sans"?e.fontStack?.sans||vn:e.fontStack?.serif||Tn}function be(e){return Zt(e,"sans")}function I(e,o,r="normal",t=o.fontFamily??"serif"){return`${r} ${e}px ${Zt(o,t)}`}function U(e,o,r){e.fillStyle="#fff",e.fillRect(0,0,o,r)}function Dn(e,o,r,t,n){let i=o.split("\\n");if(i.length<=1){e.fillText(o,r,t);return}let l=(i.length-1)*n,s=t-l/2;for(let m=0;m<i.length;m++)e.fillText(i[m],r,s+m*n)}function Fe(e,o=8){if(!Number.isFinite(e)||e<=0)return 1;let r=e/o,t=Math.pow(10,Math.floor(Math.log10(r))),n=r/t,i;return n<=1.5?i=1:n<=3?i=2:n<=7?i=5:i=10,i*t}function V(e,o=8){if(e.length===0)return{min:0,max:100,step:20};let r=Math.min(...e),t=Math.max(...e);t-r>Math.max(Math.abs(r),Math.abs(t))*1e-9||(r-=10,t+=10);let n=(t-r)*.1;r=r-n,t=t+n;let i=Fe(t-r,o);return r=Math.floor(r/i)*i,t=Math.ceil(t/i)*i,{min:r,max:t,step:i}}var No=.6;function Ge(e,o,r,t,n){if(t<=0)return r;e.font=n(r);let i=e.measureText(o).width;if(i<=t)return r;let l=Math.max(r*No,r*(t/i));return Math.floor(l)}function q({ctx:e,plotX:o,plotW:r,title:t,fontSize:n,fonts:i,canvasWidth:l}){if(!t)return;e.save(),e.fillStyle="#000";let s=be(i),m=h=>`bold ${h}px ${s}`,g=o+r/2,p=l!=null?Math.max(0,Math.min(g,l-g)*2-12):r,u=Ge(e,t,n,p,m);e.font=m(u),e.textAlign="center",e.textBaseline="top",e.fillText(t,g,10,p>0?p:void 0),e.restore()}var kn=10;function X({ctx:e,plotX:o,plotW:r,height:t,source:n,sourceLeft:i,sourceInline:l,footnotes:s,fontSize:m,fonts:g,canvasWidth:p}){e.save();let u=be(g),h=o,f=o+r;p!=null&&(h=kn,f=p-kn);let a=s.filter(v=>v.trim()),d=a.length*(m*.9+4),C=!!i,c=!!l&&!!n&&!C&&a.length>0,T=(n||i)&&!c?m+4:0,S=t-6-d-(C?T:0),D=p!=null?f:o+r,L=Math.max(0,D-h),z=v=>`bold ${v}px ${u}`;if(n&&!C&&!c){e.fillStyle="#555";let v=Ge(e,n,m,L,z);e.font=z(v),e.textAlign="right",e.textBaseline="bottom",e.fillText(n,f,S,L>0?L:void 0),S+=T}e.font=z(m);let P=c?e.measureText(n).width+16:0,k=Math.max(0,L-P),w=S;for(let v=0;v<a.length;v++){let y="* "+a[v];e.fillStyle="#555";let R=A=>`${A}px ${u}`,E=Ge(e,y,m*.9,k,R);e.font=R(E),e.textAlign="left",e.textBaseline="bottom",e.fillText(y,h,S,k>0?k:void 0),w=S,S+=m*.9+4}if(c){e.fillStyle="#555";let v=Ge(e,n,m,P,z);e.font=z(v),e.textAlign="right",e.textBaseline="bottom",e.fillText(n,f,w,P>0?P:void 0)}if(C){let v=R=>`bold ${R}px ${u}`,y=L>0?L/2:0;e.fillStyle="#555",e.textBaseline="bottom",e.font=v(Ge(e,i,m,y,v)),e.textAlign="left",e.fillText(i,h,t-6,y>0?y:void 0),n&&(e.font=v(Ge(e,n,m,y,v)),e.textAlign="right",e.fillText(n,f,t-6,y>0?y:void 0))}e.restore()}var Ie=class{constructor(){this.used=[]}reserve(o){this.used.push(o)}reserveCircle(o,r,t){this.used.push({left:o-t,right:o+t,top:r-t,bottom:r+t})}overlaps(o){return this.used.some(r=>!(o.right<r.left||o.left>r.right||o.bottom<r.top||o.top>r.bottom))}placeInColumn(o,r,t,n,i){let l=o.measureText(r).width,s=i.lineHeight,{bounds:m}=i,g=s+2;for(let p=0;p<40;p++){let u=Math.ceil(p/2)*g*(p%2===0?1:-1),h=n+u;if(h<m.top||h+s>m.bottom)continue;let f={left:t,right:t+l,top:h,bottom:h+s};if(!this.overlaps(f)){this.used.push(f),o.textAlign="left",o.textBaseline="top",o.fillText(r,t,h);return}}this.used.push({left:t,right:t+l,top:n,bottom:n+s}),o.textAlign="left",o.textBaseline="top",o.fillText(r,t,n)}place(o,r,t,n,i){let l=o.measureText(r).width,s=i.lineHeight,{gap:m,bounds:g}=i,p=[[1,-1],[1,0],[0,-1],[-1,-1],[-1,0],[0,1],[1,1],[-1,1]],u=null;for(let a of[m,m*2,m*3.5])for(let[d,C]of p){let c=t+d*a-(d<0?l:d===0?l/2:0),T=n+C*a-(C>0?0:C===0?s/2:s),S={left:c,right:c+l,top:T,bottom:T+s};if(!(S.left<g.left||S.right>g.right)&&!(S.top<g.top||S.bottom>g.bottom)){if(!this.overlaps(S)){this.used.push(S),o.textAlign="left",o.textBaseline="top",o.fillText(r,c,T);return}u||(u={x:c,y:T})}}let h=u??{x:t+m,y:n-s},f={left:h.x,right:h.x+l,top:h.y,bottom:h.y+s};this.used.push(f),o.save(),o.strokeStyle="#666",o.lineWidth=.8,o.beginPath(),o.moveTo(t,n),o.lineTo(h.x+l/2,h.y+s/2),o.stroke(),o.restore(),o.textAlign="left",o.textBaseline="top",o.fillText(r,h.x,h.y)}};function ie(e,o,r=6){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.ceil((o+r)/e))}function ne(e,o){return o.length===0?0:Math.max(...o.map(r=>e.measureText(r).width))}function se(e,o){let r=e.measureText(o),t=r.width,n=e.textAlign==="right"||e.textAlign==="end"?t:e.textAlign==="center"?t/2:0,i=Uo(e.font),l=e.textBaseline==="top"?0:e.textBaseline==="middle"?i*.5:i*.8,s=i-l;if(r.actualBoundingBoxAscent!=null){l=0,s=0;for(let m of o){if(!m.trim())continue;let g=e.measureText(m);l=Math.max(l,g.actualBoundingBoxAscent),s=Math.max(s,g.actualBoundingBoxDescent)}}return{left:n,right:t-n,up:l,down:s}}function Uo(e){let o=/(\d+(?:\.\d+)?)px/.exec(e);return o?parseFloat(o[1]):16}function fe(e,o,r,t,n,i,l=1){let s=se(e,o),m=r,g=t;return r-s.left<l?m=l+s.left:r+s.right>n-l&&(m=n-l-s.right),t-s.up<l?g=l+s.up:t+s.down>i-l&&(g=i-l-s.down),{x:m,y:g}}function Ae(e,o,r,t,n,i=.7){if(t<=0||o.length===0)return r;let l=e.font;e.font=n(r);let s=Math.max(...o.map(m=>e.measureText(m).width));return e.font=l,s<=t?r:Math.max(r*i,r*(t/s))}function oe(e,o,r){if(r<=0||!o)return[o];if(e.measureText(o).width<=r)return[o];let t=[],n="",i=()=>{n&&(t.push(n),n="")};for(let l of o.split(/(\s+)/)){if(/^\s+$/.test(l)){n&&(n+=l);continue}let s=n?n+l:l;if(e.measureText(s).width<=r){n=s;continue}if(i(),e.measureText(l).width<=r){n=l;continue}for(let m of l){let g=n+m;n&&e.measureText(g).width>r?(i(),n=m):n=g}}return i(),t.length>0?t:[o]}function Qt(e,o){return o.length===0?0:Math.max(...o.map(r=>e.measureText(r).width))}function Te(e,o,r,t,n){let i=t-(o.length-1)*n/2;for(let l=0;l<o.length;l++)e.fillText(o[l],r,i+l*n)}function re(e,o,r,t,n,i,l,s){if(!o)return;e.font=s(Ae(e,[o],l,n-2,s));let m=fe(e,o,r,t,n,i);e.fillText(o,m.x,m.y)}function An(e,o,r,t,n,i,l,s=1){if(o.length===0)return{x:r,y:t};let m=o.map(C=>se(e,C)),g=(o.length-1)*n/2,p=Math.max(...m.map(C=>C.left)),u=Math.max(...m.map(C=>C.right)),h=g+Math.max(...m.map(C=>C.up)),f=g+Math.max(...m.map(C=>C.down)),a=r,d=t;return r-p<s?a=s+p:r+u>i-s&&(a=i-s-u),t-h<s?d=s+h:t+f>l-s&&(d=l-s-f),{x:a,y:d}}function Mn(e,o,r,t,n,i=1){if(o.length===0)return r;let l=(o.length-1)*t/2,s=Math.max(...o.map(g=>se(e,g).up)),m=Math.max(...o.map(g=>se(e,g).down));return r-l-s<i?i+l+s:r+l+m>n-i?n-i-l-m:r}function ue(e,o,r,t=24){if(r(o))return o;let n=e,i=o;for(let l=0;l<t;l++){let s=(n+i)/2;r(s)?n=s:i=s}return n}var Rn=(e,o,r)=>({x:e.left,y:e.top,w:o-e.left-e.right,h:r-e.top-e.bottom});function ce({ctx:e,padding:o,width:r,height:t,min:n,max:i,step:l,label:s,side:m,fonts:g,tickFontSize:p,labelFontSize:u,drawGrid:h=!1}){let f=Rn(o,r,t),a=m==="left"?f.x:f.x+f.w;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,f.y),e.lineTo(a,f.y+f.h),e.stroke(),e.fillStyle="#000",e.font=I(p,g,"bold"),e.textBaseline="middle",e.textAlign=m==="left"?"right":"left";let d=[];for(let c=n;c<i-l*1e-9;c+=l)d.push(Math.abs(c)<1e-9?0:c);(d.length===0||Math.abs(d[d.length-1]-i)>1e-9)&&d.push(i);let C=ie(f.h/Math.max(1,d.length-1),p*1.1);for(let c=0;c<d.length;c++){let T=d[c],S=f.y+f.h-(T-n)/(i-n)*f.h;if(e.lineWidth=1.5,e.beginPath(),m==="left"?(e.moveTo(a-6,S),e.lineTo(a,S)):(e.moveTo(a,S),e.lineTo(a+6,S)),e.stroke(),h&&c>0&&c<d.length-1&&(e.save(),e.strokeStyle="#ccc",e.lineWidth=.5,e.setLineDash([4,4]),e.beginPath(),e.moveTo(f.x,S),e.lineTo(f.x+f.w,S),e.stroke(),e.restore()),c%C===0){let D=m==="left"?a-12:a+12;e.fillText(Yo(T),D,S)}}if(s){e.save();let c=D=>I(D,g,"bold");e.fillStyle="#000",e.textBaseline="bottom",e.textAlign=m==="left"?"right":"left",e.font=c(Ae(e,[s],u,r-2,c));let T=m==="left"?a-12:a+12,S=fe(e,s,T,f.y-p*.5-8,r,t);e.fillText(s,S.x,S.y),e.restore()}}function xt({ctx:e,padding:o,width:r,height:t,labels:n,indices:i,fonts:l,tickFontSize:s}){let m=Rn(o,r,t),g=m.y+m.h;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(m.x,g),e.lineTo(m.x+m.w,g),e.stroke(),e.fillStyle="#000",e.font=I(s,l,"bold"),e.textAlign="center",e.textBaseline="top";let p=i??n.map((a,d)=>d),u=m.w/n.length,h=ie(u,ne(e,n)),f=0;for(let a of p){if(a<0||a>=n.length)continue;let d=m.x+u*a+u/2;e.lineWidth=1.5,e.beginPath(),e.moveTo(d,g),e.lineTo(d,g+6),e.stroke(),f%h===0&&e.fillText(n[a],d,g+12),f++}}function Yo(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}var gt=11;function wn(e,o){return e.replace(/(\d*\.?\d+)px/,`${Math.round(o*100)/100}px`)}function Be({ctx:e,items:o,corner:r,plotX:t,plotY:n,plotW:i,plotH:l,canvasW:s,canvasH:m,fontSize:g,font:p,avoid:u=[]}){if(o.length===0)return;e.save(),e.font=p;let h=8,f=8,a=A=>{e.font=A===g?p:wn(p,A);let W=A*.95,b=Math.max(...o.map(O=>O.type==="line"?W*2:W)),G=Math.max(...o.map(O=>e.measureText(O.label).width));return{swatch:W,maxIconW:b,boxW:h*2+b+8+G,rowH:A*1.5}},d=g,C=a(d),c=i-f*2;for(;d>gt&&C.boxW>c;)d=Math.max(gt,d-.5),C=a(d);let{swatch:T,maxIconW:S,boxW:D,rowH:L}=C,z=L*o.length+8,P=A=>({x:A.endsWith("right")?t+i-D-f:t+f,y:A.startsWith("top")?n+f:n+l-z-f}),v=[r,...["top-right","top-left","bottom-right","bottom-left"].filter(A=>A!==r)].map(P),y=A=>!u.some(W=>W.x0<A.x+D&&W.x1>A.x&&W.y0<A.y+z&&W.y1>A.y),R=v.find(y)??v[0],E={x:Math.max(1,Math.min(R.x,s-D-1)),y:Math.max(1,Math.min(R.y,m-z-1))};e.fillStyle="#fff",e.fillRect(E.x,E.y,D,z),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([]),e.strokeRect(E.x,E.y,D,z);for(let A=0;A<o.length;A++){let W=o[A],b=E.y+4+L*(A+.5);Xo(e,W,E.x+h,b,T),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(W.label,E.x+h+S+8,b)}e.restore()}function Xo(e,o,r,t,n){if(o.type==="line"){let i=n*2;e.strokeStyle=typeof o.fillStyle=="string"?o.fillStyle:"#000",e.lineWidth=o.lineWidth??2,e.setLineDash(o.dash&&o.dash.length>0?o.dash:[]),e.beginPath(),e.moveTo(r,t),e.lineTo(r+i,t),e.stroke(),e.setLineDash([]),e.fillStyle=o.hollow?"#fff":o.fillStyle,o.hollow&&(e.lineWidth=1.5);let l=n*.3;o.marker==="square"?(e.fillRect(r+i/2-l,t-l,l*2,l*2),o.hollow&&e.strokeRect(r+i/2-l,t-l,l*2,l*2)):(e.beginPath(),e.arc(r+i/2,t,l,0,Math.PI*2),e.fill(),o.hollow&&e.stroke());return}e.fillStyle=o.fillStyle,e.fillRect(r,t-n/2,n,n),e.strokeStyle=o.strokeStyle??"#000",e.lineWidth=1,e.strokeRect(r,t-n/2,n,n)}var tn=36,Wn=10,zn=12,en=30,Cn=6;function Z(e,o,r,t,n="rect"){e.save(),e.font=`bold ${r}px ${be(t)}`;let i=n==="line"?tn:16,l=10,s=12,m=Math.max(...o.map(g=>i+l+e.measureText(g).width));return e.restore(),m+s*2+30}function Ue(e,o,r,t,n,i,l={}){let s=l.iconGap??Wn,m=l.padding??zn,g=l.spacing??en,p=be(i),u=D=>l.font?wn(l.font,D):`bold ${D}px ${p}`,h=Math.max(1,n-m*2);e.save();let f=D=>(e.font=u(D),o.map((L,z)=>r[z]+s+e.measureText(L).width)),a=t,d=f(a);for(;a>gt&&Math.max(...d)>h;)a=Math.max(gt,a-.5),d=f(a);e.restore();let C=[],c=[],T=0;for(let D=0;D<o.length;D++){let L=c.length===0?d[D]:g+d[D];c.length>0&&T+L>h&&(C.push(c),c=[],T=0),c.push({index:D,width:d[D]}),T+=c.length===1?d[D]:g+d[D]}c.length>0&&C.push(c);let S=a+8;return{fontSize:a,lineHeight:S,rowGap:Cn,rows:C,boxH:C.length*S+(C.length-1)*Cn+m*2}}function ee(e,o,r,t,n,i="rect",l=50){if(o.length===0)return 0;let s=p=>p==="line"?tn:16,m=o.map((p,u)=>s(Array.isArray(i)?i[u]??"rect":i)),{boxH:g}=Ue(e,o,m,r,t,n);return l+g+2}function x({ctx:e,items:o,position:r,plotX:t,plotY:n,plotW:i,plotH:l,canvasW:s,canvasH:m,fontSize:g,fonts:p,bottomOffset:u=50,rightGap:h=20}){if(o.length===0)return 0;let f=be(p);e.save(),e.font=`bold ${g}px ${f}`;let a=Wn,d=zn,C=g+8,c=S=>S.type==="line"?tn:16,T=o.map(S=>c(S)+a+e.measureText(S.label).width);if(r==="bottom"){let S=i,D=Ue(e,o.map(k=>k.label),o.map(c),g,S,p),L=D.boxH,z=t,P=Math.max(0,Math.min(n+l+u,m-L-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(z,P,S,L,0),e.fill(),e.stroke();for(let k=0;k<D.rows.length;k++){let w=D.rows[k],v=w.reduce((E,A)=>E+A.width,0)+en*(w.length-1),y=z+(S-v)/2,R=P+d+k*(D.lineHeight+D.rowGap)+D.lineHeight/2;for(let{index:E,width:A}of w){let W=o[E],b=c(W);Pn(e,W,y,R,b),e.font=`bold ${D.fontSize}px ${f}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(W.label,y+b+a,R),y+=A+en}}return e.restore(),P+L}else{let L=Math.max(...T)+d*2,z=C*o.length+10*(o.length-1)+d*2,P=Math.max(0,Math.min(t+i+h,s-L-1)),k=Math.max(0,Math.min(n+l-z,m-z-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(P,k,L,z,0),e.fill(),e.stroke();let w=k+d+C/2;for(let v of o){let y=P+d,R=c(v);Pn(e,v,y,w,R),e.font=`bold ${g}px ${f}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(v.label,y+R+a,w),w+=C+10}return e.restore(),0}}function Pn(e,o,r,t,n){o.type==="rect"?(e.fillStyle=o.fillStyle,e.fillRect(r,t-n/2,n,n),o.bordered?(e.strokeStyle="#000",e.lineWidth=1,e.strokeRect(r,t-n/2,n,n)):o.strokeStyle&&(e.strokeStyle=o.strokeStyle,e.lineWidth=1,e.strokeRect(r,t-n/2,n,n))):o.type==="circle"?(e.fillStyle=o.fillStyle,e.beginPath(),e.arc(r+n/2,t,n/2.5,0,Math.PI*2),e.fill()):o.type==="line"&&(e.save(),e.strokeStyle=o.fillStyle,e.lineWidth=o.lineWidth??2.5,o.dash&&o.dash.length>0&&e.setLineDash(o.dash),e.beginPath(),e.moveTo(r,t),e.lineTo(r+n,t),e.stroke(),e.restore(),e.fillStyle=o.fillStyle,e.beginPath(),e.arc(r+n/2,t,3.5,0,Math.PI*2),e.fill())}function $o(e,o){if(typeof document<"u"){let t=document.createElement("canvas");return t.width=o,t.height=o,t}let r=e.canvas.constructor;return new r(o,o)}function Me(e,o){let r=$o(e,10),t=r.getContext("2d");return t.fillStyle="#fff",t.fillRect(0,0,10,10),o(t,10),r}function qo(e,o){switch(o){case"diagonal":return Me(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(0,t),r.lineTo(t,0),r.moveTo(-t*.5,t*.5),r.lineTo(t*.5,-t*.5),r.moveTo(t*.5,t*1.5),r.lineTo(t*1.5,t*.5),r.stroke()});case"grid":return Me(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.2,r.beginPath(),r.moveTo(t/2,0),r.lineTo(t/2,t),r.moveTo(0,t/2),r.lineTo(t,t/2),r.stroke()});case"diagonalGrid":return Me(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.2,r.beginPath(),r.moveTo(0,0),r.lineTo(t,t),r.moveTo(t,0),r.lineTo(0,t),r.stroke()});case"dot":return Me(e,(r,t)=>{r.fillStyle="#000",r.beginPath(),r.arc(t/2,t/2,1.8,0,Math.PI*2),r.fill()});case"dotReverse":return Me(e,(r,t)=>{r.fillStyle="#333",r.fillRect(0,0,t,t),r.fillStyle="#fff",r.beginPath(),r.arc(t/2,t/2,1.8,0,Math.PI*2),r.fill()});case"vertical":return Me(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(t/2,0),r.lineTo(t/2,t),r.stroke()});case"horizontal":return Me(e,(r,t)=>{r.strokeStyle="#000",r.lineWidth=1.5,r.beginPath(),r.moveTo(0,t/2),r.lineTo(t,t/2),r.stroke()})}}var Ye=["#333","#999","#666","#fff"],Xe=["diagonal","grid","diagonalGrid","dot","dotReverse","vertical","horizontal"],En=new WeakMap;function Fn(e,o){let r=En.get(e);r||(r=new Map,En.set(e,r));let t=r.get(o);return t||(t=e.createPattern(qo(e,o),"repeat"),r.set(o,t)),t}function pt(e,o){if(o<Ye.length)return Ye[o];let r=(o-Ye.length)%Xe.length;return Fn(e,Xe[r])}var dt="pattern:";function ct(e,o){if(!o.startsWith(dt))return o;let r=o.slice(dt.length);return Xe.includes(r)?Fn(e,r):o}function yt(e){if(e.startsWith(dt))return e.slice(dt.length)!=="dotReverse";let o=e.replace("#","");if(o.length!==3&&o.length!==6)return!1;let r=o.length===3?o.split("").map(l=>l+l).join(""):o,t=parseInt(r.slice(0,2),16),n=parseInt(r.slice(2,4),16),i=parseInt(r.slice(4,6),16);return[t,n,i].some(Number.isNaN)?!1:(t*299+n*587+i*114)/1e3>180}function ve(e){return e>=3&&!Ko(e)}function Ko(e){if(e<Ye.length)return!1;let o=(e-Ye.length)%Xe.length;return Xe[o]==="dotReverse"}function $e(e,o,r,t,n){U(e,o,r);let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"&&!t.insideLegend?Z(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,n):0,m=t.barDirection==="vertical",g=t.categories.length,p=t.seriesLabels.length,u=!m&&!!t.groups&&t.groups.length>0,h=0,f=0,a=0;(u||t.unitAdjacent||t.insideLegend)&&(e.save(),e.font=I(n.fontSize.tick,n,"bold"),u&&(h=ne(e,t.groups.map(R=>R.label)),f=ne(e,t.categories.map(R=>R.label))),e.font=I(n.fontSize.axisLabel,n,"bold"),a=e.measureText(t.unit).width,e.restore());let d=m?60+s:t.unitAdjacent?40+a:160+s,C=m?130:u?20+h+14+f+12:100,c=i&&l==="bottom"&&!t.insideLegend?ee(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-C-d,n):0,T={top:n.title?100:50,right:d,bottom:(()=>{let R=m?70:60;return i&&l==="bottom"&&!t.insideLegend&&(R+=60),R=Math.max(R,c),n.source&&(R+=30),R+=n.footnotes.filter(E=>E.trim()).length*22,R})(),left:C},S=T.left,D=T.top,L=o-T.left-T.right,z=r-T.top-T.bottom,P=[0];for(let R of t.categories)t.stacked?P.push(R.values.reduce((E,A)=>E+A,0)):P.push(...R.values);P.length<=1&&P.push(100);let k=t.yRange.auto?V(P,6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};if(t.yRange.auto&&t.fitMax){let R=Math.max(...P);k={...k,max:R}}let w=R=>{let E=t.seriesFills?.[R];return E==null?pt(e,R):ct(e,E)},v=[],y=(R,E,A,W)=>{t.insideLegend&&v.push({x0:R,y0:E,x1:R+A,y1:E+W})};if(e.strokeStyle="#000",e.lineWidth=2,m){e.beginPath(),e.moveTo(S,D),e.lineTo(S,D+z),e.lineTo(S+L,D+z),e.lineTo(S+L,D),e.lineTo(S,D),e.stroke(),ce({ctx:e,padding:T,width:o,height:r,min:k.min,max:k.max,step:k.step,label:t.unit,side:"left",fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0}),e.save(),e.beginPath(),e.rect(S,D,L,z),e.clip();let R=L/g,E=O=>D+z-(O-k.min)/(k.max-k.min)*z,A=t.zeroBaseline?0:k.min,W=E(A);if(t.stacked){let O=Math.min(R*.5,80);for(let _=0;_<g;_++){let M=S+R*_+R/2,F=0;for(let B=0;B<p;B++){let H=t.categories[_].values[B]||0,N=Math.min(E(F+H),E(F)),K=Math.abs(E(F)-E(F+H));e.fillStyle=w(B),e.fillRect(M-O/2,N,O,K),y(M-O/2,N,O,K),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(M-O/2,N,O,K),n.showDataLabels&&K>n.fontSize.dataLabel&&(e.fillStyle=ve(B)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(H),M,N+K/2)),F+=H}}}else{let O=Math.min(R*.7,p*60),_=O/p;for(let M=0;M<g;M++){let F=S+R*M+(R-O)/2;for(let B=0;B<p;B++){let H=t.categories[M].values[B]||0,N=Math.min(E(H),W),K=Math.abs(E(H)-W),$=F+_*B;e.fillStyle=w(B),e.fillRect($,N,_,K),y($,N,_,K),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect($,N,_,K),n.showDataLabels&&K>n.fontSize.dataLabel&&(e.fillStyle=ve(B)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(H),$+_/2,N-4))}}}e.restore(),t.zeroBaseline&&W>D&&W<D+z&&(e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(S,W),e.lineTo(S+L,W),e.stroke());let b=t.categoryLabelAtBaseline?W+6:D+z+12;e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";let G=ie(R,ne(e,t.categories.map(O=>O.label)));for(let O=0;O<g;O++){if(O%G!==0)continue;let _=S+R*O+R/2;e.fillText(t.categories[O].label,_,b)}}else{e.beginPath(),e.moveTo(S,D),e.lineTo(S,D+z),e.lineTo(S+L,D+z),e.lineTo(S+L,D),e.lineTo(S,D),e.stroke();let R=[];for(let M=k.min;M<k.max-k.step*1e-9;M+=k.step)R.push(Math.abs(M)<1e-9?0:M);(R.length===0||Math.abs(R[R.length-1]-k.max)>1e-9)&&R.push(k.max),e.font=I(n.fontSize.tick,n,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";let E=0;for(let M=0;M<R.length;M++){let F=R[M],B=S+(F-k.min)/(k.max-k.min)*L;e.lineWidth=1,e.strokeStyle="#000",e.beginPath(),e.moveTo(B,D+z),e.lineTo(B,D+z+5),e.stroke(),e.fillText(Gn(F),B,D+z+10),M===R.length-1&&(E=e.measureText(Gn(F)).width/2),M>0&&M<R.length-1&&(e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(B,D),e.lineTo(B,D+z),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,n,"bold"),e.fillStyle="#000",e.textAlign="left",e.textBaseline="top";let A=t.unitAdjacent?S+L+E+2:S+L+30;e.fillText(t.unit,A,D+z+10),e.save(),e.beginPath(),e.rect(S,D,L,z),e.clip();let W=z/g,b=u?W*.73:W,G=[];if(u){let M=0;for(let F of t.groups){let B=D+W*M+(W-b)*F.span/2;for(let H=0;H<F.span;H++)G.push(B+b*(H+.5));M+=F.span}}for(let M=G.length;M<g;M++)G.push(D+W*M+W/2);let O=M=>S+(M-k.min)/(k.max-k.min)*L;if(t.stacked){let M=Math.min(u?b*.74:W*.5,80);for(let F=0;F<g;F++){let B=G[F],H=0;for(let N=0;N<p;N++){let K=t.categories[F].values[N]||0,$=O(H),j=O(H+K)-$;e.fillStyle=w(N),e.fillRect($,B-M/2,j,M),y($,B-M/2,j,M),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect($,B-M/2,j,M),n.showDataLabels&&j>n.fontSize.dataLabel*2&&(e.fillStyle=ve(N)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(K),$+j/2,B)),H+=K}}}else{let M=Math.min(W*.7,p*60),F=M/p;for(let B=0;B<g;B++){let H=G[B]-M/2;for(let N=0;N<p;N++){let K=t.categories[B].values[N]||0,$=O(k.min),j=O(K)-$,le=H+F*N;e.fillStyle=w(N),e.fillRect($,le,j,F),y($,le,j,F),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect($,le,j,F),n.showDataLabels&&j>n.fontSize.dataLabel*2&&(e.fillStyle=ve(N)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="left",e.textBaseline="middle",e.fillText(String(K),$+j+4,le+F/2))}}}e.restore();let _=u?S-12:S-10;for(let M=0;M<g;M++)e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="right",e.textBaseline="middle",e.fillText(t.categories[M].label,_,G[M]);if(u){let M=0;for(let F of t.groups){let B=D+W*M+W*F.span/2;e.fillText(F.label,_-f-14,B),M+=F.span}}}if(q({ctx:e,fonts:n,plotX:S,plotW:L,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i&&t.insideLegend)Be({ctx:e,items:t.seriesLabels.map((R,E)=>({type:"rect",fillStyle:w(E),label:R})),corner:t.insideLegend,plotX:S,plotY:D,plotW:L,plotH:z,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.9,font:I(n.fontSize.dataLabel*.9,n,"bold"),avoid:v});else if(i){let R=t.seriesLabels.map((E,A)=>({type:"rect",fillStyle:w(A),bordered:t.seriesFills?.[A]?yt(t.seriesFills[A]):ve(A),label:E}));x({ctx:e,fonts:n,items:R,position:l,plotX:S,plotY:D,plotW:L,plotH:z,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}X({ctx:e,fonts:n,plotX:S,plotW:L,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Gn(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}function St(){return{title:"",source:"",footnotes:[""],fontFamily:"serif",customFont:"",fontStack:{},fontSize:{title:36,axisLabel:28,tick:26,dataLabel:22},showDataLabels:!1,showLegend:!0,legendPosition:"bottom",legendLabel1:"",legendLabel2:""}}function Lt(){return{baseMonths:Array.from({length:12},()=>({temp:0,precip:0})),months:Array.from({length:12},()=>({temp:0,precip:0})),monthInterval:12,tempLabel:"(\xB0C)",precipLabel:"(mm)",tempRange:{min:-10,max:10,auto:!0},precipRange:{min:-200,max:200,auto:!0}}}function Tt(){return{baseTemp:0,basePrecip:0,regions:[{label:"A",precip:0,temp:0},{label:"B",precip:0,temp:0},{label:"C",precip:0,temp:0}],precipDiffLabel:"\uAC15\uC218\uB7C9 \uCC28\uC774",tempDiffLabel:"\uAE30\uC628 \uCC28\uC774",precipUnit:"(mm)",tempUnit:"(\xB0C)",precipRange:{min:-200,max:200,auto:!0},tempRange:{min:-10,max:10,auto:!0}}}function vt(){return{months:Array.from({length:12},()=>({temp:0,precip:0})),monthInterval:12,tempLabel:"(\xB0C)",precipLabel:"(mm)",tempRange:{min:-10,max:40,auto:!0},precipRange:{min:0,max:400,auto:!0}}}var Re=["0-4","5-9","10-14","15-19","20-24","25-29","30-34","35-39","40-44","45-49","50-54","55-59","60-64","65-69","70-74","75-79","80+"];function Dt(){return{ages:Array.from({length:17},()=>({male:0,female:0})),unit:"percent",maleLabel:"\uB0A8",femaleLabel:"\uC5EC",axisLabel:"(%)",range:{max:10,auto:!0},ageLabelSide:"center"}}function kt(){return{points:[{a:33,b:33,c:34,label:"(\uAC00)"}],axisLabels:["A","B","C"],gridInterval:20}}function At(){return{displayMode:"bar",barDirection:"vertical",categories:[{label:"(\uAC00)",values:[40,30,30]},{label:"(\uB098)",values:[50,25,25]},{label:"(\uB2E4)",values:[20,40,40]}],seriesLabels:["\uD56D\uBAA91","\uD56D\uBAA92","\uD56D\uBAA93"],unit:"(%)"}}function Mt(){return{barDirection:"vertical",stacked:!1,categories:[{label:"(\uAC00)",values:[30,50]},{label:"(\uB098)",values:[45,35]},{label:"(\uB2E4)",values:[60,20]}],seriesLabels:["\uD56D\uBAA91","\uD56D\uBAA92"],unit:"",yRange:{min:0,max:100,auto:!0}}}function Rt(){return{mode:"normal",bubbleLegendPosition:"bottom-right",points:[{x:10,y:25,size:50,label:"A"},{x:25,y:40,size:80,label:"B"},{x:40,y:15,size:30,label:"C"},{x:55,y:60,size:100,label:"D"}],xLabel:"X\uCD95",yLabel:"Y\uCD95",xUnit:"",yUnit:"",xRange:{min:0,max:100,auto:!0},yRange:{min:0,max:100,auto:!0},showBubble:!0,bubbleScale:30,quadrantLabels:["(\uAC00)","(\uB098)","(\uB2E4)","(\uB77C)"]}}var Ct=["1","2","3","4","5","6","7","8","9","10","11","12"],Pt=["J","F","M","A","M","J","J","A","S","O","N","D"];function wt(){return{series:[{label:"(\uAC00)",months:Array.from({length:12},()=>({temp:0,precip:0}))}],mode:"both",monthLabelStyle:"number",xUnit:"(\xB0C)",yUnit:"(mm)",xRange:{min:-10,max:40,auto:!0},yRange:{min:0,max:400,auto:!0}}}function Wt(){return{points:[{x:0,y:1,z:1,label:"\u3131",labelDx:0,labelDy:0},{x:0,y:0,z:0,label:"\u3134",labelDx:0,labelDy:0},{x:1,y:0,z:1,label:"\u3137",labelDx:0,labelDy:0}],xAxis:{name:"X\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}},yAxis:{name:"Y\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}},zAxis:{name:"Z\uCD95",lowLabel:"\uB0AE\uC74C",highLabel:"\uB192\uC74C",lowOffset:{x:0,y:0},highOffset:{x:0,y:0}}}}function nn(){return{quadrants:"first",xAxis:{label:"\uC218\uB7C9(kg)",min:0,max:9,ticks:[1,2,3,4,5,6,7,8],broken:!1},yAxis:{label:"\uAC00\uACA9(\uCC9C \uC6D0)",min:0,max:9,ticks:[1,2,3,4,5,6,7,8],broken:!1},grid:!0,dash:"dashed",lines:[{label:"\uC218\uC694",from:{x:0,y:8},to:{x:8,y:0},labelAt:"to"},{label:"\uACF5\uAE09",from:{x:0,y:0},to:{x:8,y:8},labelAt:"to"}],points:[{x:4,y:4,label:"E",labelPos:"top",guide:"none",dot:!0}],arrows:[]}}function In(){return{quadrants:"first",xAxis:{label:"\uC2E4\uC9C8 GDP",min:0,max:10,ticks:[],broken:!1},yAxis:{label:"\uBB3C\uAC00",min:0,max:10,ticks:[],broken:!1},grid:!1,dash:"dashed",lines:[{label:"\uCD1D\uC218\uC694",from:{x:1,y:8.5},to:{x:8.5,y:1},labelAt:"to"},{label:"\uCD1D\uACF5\uAE09",from:{x:1,y:1},to:{x:8.5,y:8.5},labelAt:"to"}],points:[{x:4.75,y:4.75,label:"E",labelPos:"right",guide:"none",dot:!0}],arrows:[]}}function Bn(){return{quadrants:"first",xAxis:{label:"\uC218\uB7C9(\uB9CC \uAC1C)",min:0,max:18,ticks:[5,10,15],broken:!1},yAxis:{label:"\uAC00\uACA9(\uB2EC\uB7EC)",min:0,max:18,ticks:[10,15],broken:!1},grid:!1,dash:"dashed",lines:[],points:[{x:5,y:10,label:"E",labelPos:"top",guide:"both",dot:!0},{x:10,y:10,label:"A",labelPos:"top",guide:"both",dot:!0},{x:15,y:15,label:"B",labelPos:"top",guide:"both",dot:!0}],arrows:[{from:{x:5,y:10},to:{x:10,y:10},offset:0,shorten:10,label:"",labelPos:"top"},{from:{x:10,y:10},to:{x:15,y:15},offset:0,shorten:10,label:"",labelPos:"top"}]}}function zt(){return nn()}function Et(){return{axisLabels:["\uCD951","\uCD952","\uCD953","\uCD954","\uCD955"],series:[{label:"(\uAC00)",values:[0,0,0,0,0]}],maxValue:100,autoMax:!0,gridSteps:5,showFill:!1}}var Ft=["circle","square","triangle","diamond"];function Gt(){return{categories:[{label:"A",values:[17]},{label:"B",values:[11]},{label:"C",values:[9]},{label:"D",values:[25]}],seriesLabels:["\uD56D\uBAA91"],unit:"",dotRadius:6,yRange:{min:0,max:100,auto:!0}}}var De={solid:[],dashed:[10,6],dotted:[2,5],dashdot:[12,5,3,5]},Ce=["solid","dashed","dotted","dashdot"],qe=["circle","square","triangle","diamond"];function It(){return{series:[{label:"(\uAC00)",values:Array.from({length:12},(e,o)=>o*2)}],xLabels:["1","2","3","4","5","6","7","8","9","10","11","12"],xUnit:"(\uC6D4)",yUnit:"",yRange:{min:0,max:100,auto:!0},labelPlacement:"lineEnd",showMarkers:!0}}function Bt(){return{names:["(\uAC00)","(\uB098)","(\uB2E4)"],values:[[0,0,0],[559,0,0],[2648,2210,0]],unit:"(\uB2E8\uC704 : km)"}}function Ot(){return{cornerLabel:"\uAD6C\uBD84",columns:["(\uAC00)","(\uB098)","(\uB2E4)","(\uB77C)"],rows:[{label:"\uAE30\uC628\uC758 \uC5F0\uAD50\uCC28",unit:"(\u2103)",values:[40.5,29.9,3.8,3.8]},{label:"\uCD5C\uD55C\uC6D4 \uD3C9\uADE0 \uAE30\uC628",unit:"(\u2103)",values:[-21.4,-24.4,24.6,19.5]},{label:"1\uC6D4 \uAC15\uC218\uB7C9",unit:"(mm)",values:[1.8,4.6,28.8,206.8]}]}}function Ht(){return{cells:[{label:"\uC911\uAD6D",value:50},{label:"\uBBF8\uAD6D",value:20},{label:"\uC778\uB3C4",value:12},{label:"\uAE30\uD0C0",value:18}]}}function jo(e,o,r,t,n){switch(e.beginPath(),o){case"circle":e.arc(r,t,n,0,Math.PI*2);break;case"square":e.rect(r-n,t-n,n*2,n*2);break;case"triangle":e.moveTo(r,t-n),e.lineTo(r+n,t+n),e.lineTo(r-n,t+n),e.closePath();break;case"diamond":e.moveTo(r,t-n),e.lineTo(r+n,t),e.lineTo(r,t+n),e.lineTo(r-n,t),e.closePath();break}e.fill()}function Ke(e,o,r,t,n){U(e,o,r);let i=t.categories.length,l=t.seriesLabels.length,s=t.seriesMarkers??Ft,m=n.showLegend&&l>1,g=n.legendPosition,p=m&&g==="right"?Z(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,n,"circle"):0,u=m&&g==="bottom"?ee(e,t.seriesLabels,n.fontSize.dataLabel*.85,o-130-(60+p),n,"circle"):0,h={top:n.title?100:50,right:60+p,bottom:(()=>{let P=70;return m&&g==="bottom"&&(P+=60),P=Math.max(P,u),n.source&&(P+=30),P+=n.footnotes.filter(k=>k.trim()).length*22,P})(),left:130},f=h.left,a=h.top,d=o-h.left-h.right,C=r-h.top-h.bottom,c=[0];for(let P of t.categories)c.push(...P.values);c.length<=1&&c.push(100);let T=t.yRange.auto?V(c,6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(f,a),e.lineTo(f,a+C),e.lineTo(f+d,a+C),e.lineTo(f+d,a),e.lineTo(f,a),e.stroke(),ce({ctx:e,padding:h,width:o,height:r,min:T.min,max:T.max,step:T.step,label:t.unit,side:"left",fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0});let S=t.dotRadius+1;e.save(),e.beginPath(),e.rect(f-S,a-S,d+S*2,C+S*2),e.clip();let D=d/i,L=P=>a+C-(P-T.min)/(T.max-T.min)*C,z=l>1?Math.min(D*.6,l*24)/l:0;for(let P=0;P<i;P++){let k=f+D*P+D/2;for(let w=0;w<l;w++){let v=t.categories[P].values[w];if(v===void 0||Number.isNaN(v))continue;let y=k+(w-(l-1)/2)*z,R=L(v);e.fillStyle="#000",jo(e,s[w%s.length],y,R,t.dotRadius),n.showDataLabels&&(e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(v),y,R-t.dotRadius-4))}}if(e.restore(),t.zeroBaseline){let P=L(0);P>a&&P<a+C&&(e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(f,P),e.lineTo(f+d,P),e.stroke())}e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";for(let P=0;P<i;P++){let k=f+D*P+D/2;e.fillText(t.categories[P].label,k,a+C+12)}if(n.title&&q({ctx:e,fonts:n,plotX:f,plotW:d,title:n.title,fontSize:n.fontSize.title}),m){let P=t.seriesLabels.map(k=>({type:"circle",fillStyle:"#000",label:k}));x({ctx:e,fonts:n,items:P,position:g,plotX:f,plotY:a,plotW:d,plotH:C,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85})}X({ctx:e,fonts:n,plotX:f,plotW:d,height:r,canvasWidth:o,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel*.85})}function Vo(e,o,r,t,n,i){switch(e.beginPath(),o){case"circle":e.arc(r,t,n,0,Math.PI*2);break;case"square":e.rect(r-n,t-n,n*2,n*2);break;case"triangle":e.moveTo(r,t-n),e.lineTo(r+n,t+n),e.lineTo(r-n,t+n),e.closePath();break;case"diamond":e.moveTo(r,t-n),e.lineTo(r+n,t),e.lineTo(r,t+n),e.lineTo(r-n,t),e.closePath();break}e.fillStyle=i?"#fff":"#000",e.fill(),e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.stroke()}function je(e,o,r,t,n){U(e,o,r);let i=t.xLabels.length,l=t.labelPlacement==="legend"&&n.showLegend,s=n.legendPosition,m=l&&s==="right"?Z(e,t.series.map(v=>v.label),n.fontSize.dataLabel*.85+5,n,"line"):0;e.font=I(n.fontSize.dataLabel,n,"bold");let g=t.labelPlacement==="lineEnd"?ne(e,t.series.map(v=>v.label))+16:0;e.font=I(n.fontSize.tick,n,"bold");let p=t.xUnit?e.measureText(t.xUnit).width+e.measureText(t.xLabels[i-1]??"").width/2+12:0,u=24+m+Math.max(g,p),h=l&&s==="bottom"&&!t.insideLegend?ee(e,t.series.map(v=>v.label),n.fontSize.dataLabel*.85,o-130-u,n,"line"):0,f={top:n.title?100:50,right:u,bottom:(()=>{let v=70;return l&&s==="bottom"&&!t.insideLegend&&(v+=60),v=Math.max(v,h),n.source&&(v+=30),v+=n.footnotes.filter(y=>y.trim()).length*22,v})(),left:130},a=f.left,d=f.top,C=o-f.left-f.right,c=r-f.top-f.bottom,T=t.stacked?t.xLabels.map((v,y)=>t.series.reduce((R,E)=>{let A=E.values[y];return R+(A!==null&&Number.isFinite(A)?A:0)},0)):t.series.flatMap(v=>v.values).filter(v=>v!==null&&Number.isFinite(v)),S=t.yRange.auto?V(T.length>0?T:[0,100],6):{min:t.yRange.min,max:t.yRange.max,step:t.yRange.step||Math.max(1,Math.round((t.yRange.max-t.yRange.min)/6))};e.strokeStyle="#000",e.lineWidth=2,e.setLineDash([]),e.beginPath(),e.moveTo(a,d),e.lineTo(a,d+c),e.lineTo(a+C,d+c),e.lineTo(a+C,d),e.lineTo(a,d),e.stroke(),ce({ctx:e,padding:f,width:o,height:r,min:S.min,max:S.max,step:S.step,label:t.yUnit,side:"left",fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0});let D=i>1?C/(i-1):0,L=v=>a+D*v,z=v=>d+c-(v-S.min)/(S.max-S.min)*c;t.zeroBaseline&&S.min<0&&S.max>0&&(e.save(),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(a,z(0)),e.lineTo(a+C,z(0)),e.stroke(),e.restore());let P=[],k=[];{let v=t.xLabels.map(()=>0);for(let y of t.series){let R=[...v],E=y.values.map((A,W)=>A===null||!Number.isFinite(A)?null:t.stacked?(v[W]+=A,v[W]):A);P.push(E),k.push(R)}}if(t.series.forEach((v,y)=>{if(!v.areaFill)return;let R=P[y],E=k[y];e.save(),e.fillStyle=v.areaFill;let A=0;for(;A<R.length;){if(R[A]===null){A++;continue}let W=A;for(;W+1<R.length&&R[W+1]!==null;)W++;e.beginPath();for(let b=A;b<=W;b++)e.lineTo(L(b),z(R[b]));for(let b=W;b>=A;b--)e.lineTo(L(b),z(t.stacked?E[b]:S.min));e.closePath(),e.fill(),A=W+1}e.restore()}),t.series.forEach((v,y)=>{let R=v.lineStyle??Ce[y%Ce.length];e.save(),e.strokeStyle="#000",e.lineWidth=2,e.setLineDash(De[R]),e.beginPath();let E=!1;P[y].forEach((A,W)=>{if(A===null){E=!1;return}let b=L(W),G=z(A);E?e.lineTo(b,G):(e.moveTo(b,G),E=!0)}),e.stroke(),e.restore()}),t.showMarkers&&t.series.forEach((v,y)=>{let R=v.marker??qe[y%qe.length];P[y].forEach((E,A)=>{E!==null&&Vo(e,R,L(A),z(E),4.5,v.hollowMarker??!1)})}),t.labelPlacement==="lineEnd"){e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,n,"bold");let v=new Ie,y=n.fontSize.dataLabel*1.1,R=a+C+10,E={left:R,right:o-4,top:4,bottom:r-4};t.series.forEach((A,W)=>{let b=P[W],G=-1;for(let O=b.length-1;O>=0;O--)if(b[O]!==null){G=O;break}G<0||v.placeInColumn(e,A.label,R,z(b[G])-y/2,{lineHeight:y,bounds:E})})}e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";let w=ie(D,ne(e,t.xLabels));if(t.xLabels.forEach((v,y)=>{y%w===0&&e.fillText(v,L(y),d+c+10)}),t.xUnit){let v=e.measureText(t.xLabels[i-1]??"").width/2;e.textAlign="left",e.fillText(t.xUnit,a+C+v+6,d+c+10)}if(n.title&&q({ctx:e,fonts:n,plotX:a,plotW:C,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),l&&t.insideLegend){e.save(),e.font=I(n.fontSize.dataLabel*.8,n,"bold");let v=n.fontSize.dataLabel*1.15,y=v*.75,R=y+6+ne(e,t.series.map(A=>A.label))+10,E=d+6;for(let A of t.series)e.fillStyle="#fff",e.fillRect(a+6,E,R,v),e.strokeStyle="#000",e.lineWidth=1,e.setLineDash([]),e.strokeRect(a+6,E,R,v),e.fillStyle=A.areaFill??"#000",e.fillRect(a+10,E+(v-y)/2,y,y),e.strokeRect(a+10,E+(v-y)/2,y,y),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(A.label,a+10+y+5,E+v/2),E+=v;e.restore()}else if(l){let v=t.series.map((y,R)=>({type:"line",fillStyle:"#000",strokeStyle:"#000",label:y.label,dash:De[y.lineStyle??Ce[R%Ce.length]]}));x({ctx:e,fonts:n,items:v,position:s,plotX:a,plotY:d,plotW:C,plotH:c,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85})}X({ctx:e,fonts:n,plotX:a,plotW:C,height:r,canvasWidth:o,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel*.85})}var Jo="#d9d9d9",on=.2,On=1.7,Hn=.75;function Ve(e,o,r,t,n){U(e,o,r);let i=t.names.length;if(i===0)return;let l=n.fontFamily,s=n.fontSize.tick;e.font=I(s,n,"bold");let g=Math.max(...t.names.map(v=>e.measureText(v).width),...Zo(t).map(v=>e.measureText(_n(v,t.groupThousands)).width))+s*Hn*2,p=t.unit?n.fontSize.dataLabel*1.6:0,u=n.footnotes.filter(v=>v.trim()).length,h=(u>0?u*22+n.fontSize.dataLabel+12:0)+(n.source?n.fontSize.dataLabel+4:0),f=n.title?100:30,a=(v,y)=>v*i+y*(i-1),d=Math.min(1,(o-20)/a(g,g*on),(r-f-p-h-10)/a(s*On,s*on)),C=s*d,c=g*d,T=s*On*d,S=s*on*d,D=C*Hn,L=a(c,S),z=a(T,S),P=Math.max(10,(o-L)/2),k=f+p+Math.max(0,(r-f-p-h-z)/2),w=Math.max(f+p,Math.min(k,r-h-z));t.unit&&(e.font=I(n.fontSize.dataLabel,n,"bold"),e.fillStyle="#000",e.textAlign="right",e.textBaseline="bottom",e.fillText(t.unit,P+L,w-10)),e.textBaseline="middle";for(let v=0;v<i;v++){let y=w+(T+S)*v;for(let R=0;R<=v;R++){let E=P+(c+S)*R,A=R===v;if(e.fillStyle=A?t.nameFill??Jo:"#fff",e.fillRect(E,y,c,T),e.strokeStyle="#000",e.lineWidth=1.2,e.strokeRect(E,y,c,T),e.fillStyle="#000",A){let W=t.nameIsSymbol&&!t.nameIsSymbol[v]?"sans":l;e.font=I(C,n,"bold",W),e.textAlign="center",e.fillText(t.names[v],E+c/2,y+T/2)}else e.font=I(C,n,"bold"),e.textAlign="right",e.fillText(_n(t.values[v]?.[R]??0,t.groupThousands),E+c-D,y+T/2)}}q({ctx:e,fonts:n,plotX:P,plotW:L,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:P,plotW:L,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Zo(e){let o=[];for(let r=0;r<e.names.length;r++)for(let t=0;t<r;t++)o.push(e.values[r]?.[t]??0);return o}function _n(e,o=!0){let r=Number.isInteger(e)?e:Math.round(e);return o?String(r).replace(/\B(?=(\d{3})+(?!\d))/g,","):String(r)}var Qo="#d9d9d9",xo=1.7,rn=.75,an=.8;function Je(e,o,r,t,n){U(e,o,r);let i=t.columns.length,l=t.rows.length;if(i===0||l===0)return;let s=n.fontFamily,m=n.fontSize.tick;e.font=I(m,n,"bold");let g=Math.max(e.measureText(t.cornerLabel).width,...t.rows.map(E=>er(e,E,m,n))),p=Math.max(...t.columns.map(E=>e.measureText(E).width),...t.rows.flatMap(E=>E.values.map(A=>e.measureText(Nn(A,E.decimals,t.groupThousands)).width))),u=g+m*rn*2,h=p+m*rn*2,f=m*xo,a=n.title?100:30,d=n.footnotes.filter(E=>E.trim()).length,C=(d>0?d*22+n.fontSize.dataLabel+12:0)+(n.source?n.fontSize.dataLabel+4:0),c=Math.min(1,(o-20)/(u+h*i),(r-a-C-10)/(f*(l+1))),T=m*c,S=u*c,D=h*c,L=f*c,z=T*rn,P=S+D*i,k=L*(l+1),w=Math.max(10,(o-P)/2),v=a+Math.max(0,(r-a-C-k)/2),y=Math.max(a,Math.min(v,r-C-k)),R=E=>w+S+D*E;e.fillStyle=t.headerFill??Qo,e.fillRect(w,y,P,L),e.fillStyle="#000",e.textBaseline="middle",e.textAlign="center",e.font=I(T,n,"bold"),e.fillText(t.cornerLabel,w+S/2,y+L/2,S-z*2),t.columns.forEach((E,A)=>{let W=t.columnIsSymbol&&!t.columnIsSymbol[A]?"sans":s;e.font=I(T,n,"bold",W),e.fillText(E,R(A)+D/2,y+L/2,D-z*2)}),t.rows.forEach((E,A)=>{let W=y+L*(A+1);tr(e,E,w+S/2,W+L/2,T,n),e.font=I(T,n,"bold"),e.textAlign="right";for(let b=0;b<i;b++){let G=E.values[b];G!==void 0&&e.fillText(Nn(G,E.decimals,t.groupThousands),R(b)+D-z,W+L/2,D-z*2)}e.textAlign="center"}),e.strokeStyle="#000",e.lineWidth=1;for(let E=1;E<=l;E++){let A=y+L*E;ln(e,w,A,w+P,A)}ln(e,w+S,y,w+S,y+k);for(let E=1;E<i;E++)ln(e,R(E),y,R(E),y+k);e.lineWidth=2,e.strokeRect(w,y,P,k),q({ctx:e,fonts:n,plotX:w,plotW:P,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:w,plotW:P,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function ln(e,o,r,t,n){e.beginPath(),e.moveTo(o,r),e.lineTo(t,n),e.stroke()}function er(e,o,r,t){e.font=I(r,t,"bold");let n=e.measureText(o.label).width;return o.unit?(e.font=I(r*an,t,"bold"),n+e.measureText(o.unit).width):n}function tr(e,o,r,t,n,i){e.fillStyle="#000",e.textBaseline="middle",e.font=I(n,i,"bold");let l=e.measureText(o.label).width;if(!o.unit){e.textAlign="center",e.fillText(o.label,r,t);return}e.font=I(n*an,i,"bold");let s=e.measureText(o.unit).width,m=r-(l+s)/2;e.textAlign="left",e.font=I(n,i,"bold"),e.fillText(o.label,m,t),e.font=I(n*an,i,"bold"),e.fillText(o.unit,m+l,t),e.textAlign="center"}function Nn(e,o=1,r=!0){if(!Number.isFinite(e))return"-";let t=e.toFixed(o);if(!r)return t;let[n,i]=t.split("."),l=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return i?`${l}.${i}`:l}var sn=.65,Yn=.16,Un=/[0-9A-Za-z]/,Xn=/_[0-9A-Za-z]/;function fn(e){if(!Xn.test(e))return[{text:e,sub:!1}];let o=[],r="";for(let t=0;t<e.length;t++){if(e[t]==="_"&&t+1<e.length&&Un.test(e[t+1])){let n=t+1;for(;n<e.length&&Un.test(e[n]);)n++;r&&(o.push({text:r,sub:!1}),r=""),o.push({text:e.slice(t+1,n),sub:!0}),t=n-1;continue}r+=e[t]}return r&&o.push({text:r,sub:!1}),o}function mn(e){return e.length===1&&!e[0].sub}function Pe(e,o,r,t){let n=fn(o),i=t(r);if(mn(n))return e.font=i,e.measureText(o).width;let l=t(r*sn),s=0;for(let m of n)e.font=m.sub?l:i,s+=e.measureText(m.text).width;return e.font=i,s}function nr(e,o,r,t){let n=fn(o),i=t(r);if(mn(n))return e.font=i,se(e,o);let l=t(r*sn),s=r*Yn,m=0,g=0,p=0;for(let h of n){e.font=h.sub?l:i;let f=se(e,h.text);m+=f.left+f.right,g=Math.max(g,h.sub?f.up-s:f.up),p=Math.max(p,h.sub?f.down+s:f.down)}e.font=i;let u=e.textAlign==="right"||e.textAlign==="end"?m:e.textAlign==="center"?m/2:0;return{left:u,right:m-u,up:g,down:p}}function bn(e,o,r,t,n,i){let l=fn(o),s=i(n);if(mn(l)){e.font=s,e.fillText(o,r,t);return}let m=i(n*sn),g=n*Yn,p=0;for(let f of l)e.font=f.sub?m:s,p+=e.measureText(f.text).width;let u=e.textAlign,h=u==="right"||u==="end"?r-p:u==="center"?r-p/2:r;e.textAlign="left";for(let f of l)e.font=f.sub?m:s,e.fillText(f.text,h,f.sub?t+g:t),h+=e.measureText(f.text).width;e.textAlign=u,e.font=s}function or(e,o,r,t,n,i=.7){if(t<=0||o.length===0)return r;let l=e.font,s=Math.max(...o.map(m=>Pe(e,m,r,n)));return e.font=l,s<=t?r:Math.max(r*i,r*(t/s))}function _t(e,o,r,t,n,i,l,s,m=1){let g=nr(e,o,l,s),p=r,u=t;return r-g.left<m?p=m+g.left:r+g.right>n-m&&(p=n-m-g.right),t-g.up<m?u=m+g.up:t+g.down>i-m&&(u=i-m-g.down),{x:p,y:u}}function we(e,o,r,t,n,i,l,s){if(!o)return;if(!Xn.test(o)){re(e,o,r,t,n,i,l,s);return}let m=or(e,[o],l,n-2,s),g=_t(e,o,r,t,n,i,m,s);bn(e,o,g.x,g.y,m,s)}var We=26,rr=2.5,$n=3,qn=1.5,ir=2.5,he=6,Nt=14,Ut=6,Kn=13,jn=1.15,Vn={dashed:[7,5],dotted:[1.5,4]},un=[12,8],Yt=(e,o,r)=>Math.min(r,Math.max(o,e));function lr(e){let o=Number.isInteger(e)?String(e):e.toFixed(1);return o.startsWith("-")?"\u2212"+o.slice(1):o}function hn(e,o){let r=Array.isArray(e.tickLabels)?e.tickLabels[o]:void 0;return typeof r=="string"&&r!==""?r:lr(e.ticks[o])}function ar(e){return e?e.split(/\\n|\n/):[""]}function Jn(e){let o=e.max-e.min;return Number.isFinite(o)&&Math.abs(o)>1e-9?o:1}function sr(e){return Array.isArray(e.series)?e.series.filter(o=>o&&Array.isArray(o.points)):[]}function Zn(e){return e.length>1?[...e].reverse():e}function fr(e,o,r,t){e.beginPath(),o.marker==="square"?e.rect(r-he,t-he,he*2,he*2):e.arc(r,t,he,0,Math.PI*2),e.fillStyle=o.hollow?"#fff":"#000",e.fill(),o.hollow&&(e.strokeStyle="#000",e.lineWidth=2,e.setLineDash([]),e.stroke())}function Qn(e,o){let r=o*.75;switch(e){case"left":return{dx:-o,dy:0,align:"right",baseline:"middle"};case"top":return{dx:0,dy:-o,align:"center",baseline:"bottom"};case"bottom":return{dx:0,dy:o,align:"center",baseline:"top"};case"top-left":return{dx:-r,dy:-r,align:"right",baseline:"bottom"};case"top-right":return{dx:r,dy:-r,align:"left",baseline:"bottom"};case"bottom-left":return{dx:-r,dy:r,align:"right",baseline:"top"};case"bottom-right":return{dx:r,dy:r,align:"left",baseline:"top"};default:return{dx:o,dy:0,align:"left",baseline:"middle"}}}function Ze(e,o,r,t,n){let i=t-o,l=n-r,s=Math.hypot(i,l);if(!(s>0))return;let m=i/s,g=l/s;e.beginPath(),e.moveTo(t,n),e.lineTo(t-m*Nt-g*Ut,n-g*Nt+m*Ut),e.lineTo(t-m*Nt+g*Ut,n-g*Nt-m*Ut),e.closePath(),e.fill()}function xn(e,o,r,t){e.save(),e.translate(o,r),t&&e.rotate(-Math.PI/2),e.fillStyle="#fff",e.fillRect(-10,-7,20,14),e.strokeStyle="#000",e.lineWidth=1.6;for(let l of[-7*.5,7*.5])e.beginPath(),e.moveTo(-8,l+2.5),e.quadraticCurveTo(-8/2,l-4.5,0,l),e.quadraticCurveTo(8/2,l+4.5,8,l-2.5),e.stroke();e.restore()}function Qe(e,o,r,t,n){U(e,o,r);let i=n.fontSize,l=t.quadrants==="all",s=M=>I(M,n),m=I(i.tick,n),g=sr(t);e.font=m;let p=t.yAxis.ticks.length>0?Math.max(...t.yAxis.ticks.map((M,F)=>Pe(e,hn(t.yAxis,F),i.tick,s))):0;e.font=s(i.axisLabel);let u=ar(t.yAxis.label),h=t.xAxis.label?Pe(e,t.xAxis.label,i.axisLabel,s):0,f=t.yAxis.label?Math.max(...u.map(M=>M?Pe(e,M,i.axisLabel,s):0)):0,a=t.lines.length>0?Math.max(...t.lines.map(M=>M.label?Pe(e,M.label,i.axisLabel,s):0)):0,d=n.footnotes.filter(M=>M.trim()).length,C=!!n.sourceInline&&!!n.source&&!n.sourceLeft&&d>0,T=((!!n.source||!!n.sourceLeft)&&!C?i.dataLabel+6:0)+d*(i.dataLabel*.9+6)+12,S=(u.length-1)*i.axisLabel*jn,D={top:(n.title?i.title+40:18)+i.axisLabel+S+10+We,left:l?Math.max(46,We+20):Math.max(46,p+14,Math.min(f+8,o*.34)),right:Math.min(o*.45,Math.max(56,a+16,We+12+h+6)),bottom:i.tick+24+T},L=D.left,z=D.top,P=Math.max(40,o-D.left-D.right),k=Math.max(40,r-D.top-D.bottom),w=M=>L+(M-t.xAxis.min)/Jn(t.xAxis)*P,v=M=>z+k-(M-t.yAxis.min)/Jn(t.yAxis)*k,y=l?Yt(w(0),L,L+P):L,R=l?Yt(v(0),z,z+k):z+k,E=Vn[t.dash]??Vn.dashed;if(t.grid){let M=t.xAxis.ticks.length>0?w(Math.max(...t.xAxis.ticks)):L+P,F=t.yAxis.ticks.length>0?v(Math.max(...t.yAxis.ticks)):z;e.save(),e.strokeStyle="#000",e.lineWidth=qn,e.setLineDash(E);for(let B of t.xAxis.ticks){if(B===0)continue;let H=w(B);e.beginPath(),e.moveTo(H,R),e.lineTo(H,F),e.stroke()}for(let B of t.yAxis.ticks){if(B===0)continue;let H=v(B);e.beginPath(),e.moveTo(y,H),e.lineTo(M,H),e.stroke()}e.restore()}e.save(),e.strokeStyle="#000",e.lineWidth=qn,e.setLineDash(E);for(let M of t.points){if(M.guide==="none")continue;let F=w(M.x),B=v(M.y),H=M.guide==="cross";(H||M.guide==="to-x"||M.guide==="both")&&(e.beginPath(),e.moveTo(F,H?z:B),e.lineTo(F,H?z+k:R),e.stroke()),(H||M.guide==="to-y"||M.guide==="both")&&(e.beginPath(),e.moveTo(H?L:F,B),e.lineTo(H?L+P:y,B),e.stroke())}if(t.seriesGuides&&g.length>0){let M=new Map;for(let F of g)for(let B of F.points){let H=M.get(B.x);(H==null||B.y>H)&&M.set(B.x,B.y)}for(let[F,B]of M)e.beginPath(),e.moveTo(w(F),v(B)),e.lineTo(w(F),R),e.stroke()}e.restore(),e.save(),e.strokeStyle="#000",e.fillStyle="#000",e.lineWidth=rr,e.lineCap="butt";let A=l?L-We:y,W=L+P+We;e.beginPath(),e.moveTo(A,R),e.lineTo(W,R),e.stroke(),Ze(e,A,R,W,R),l&&Ze(e,W,R,A,R);let b=l?z+k+We:R,G=z-We;if(e.beginPath(),e.moveTo(y,b),e.lineTo(y,G),e.stroke(),Ze(e,y,b,y,G),l&&Ze(e,y,G,y,b),t.xAxis.broken){let M=t.xAxis.ticks.find(F=>F!==0);xn(e,M==null?y+P*.12:(y+w(M))/2,R,!1)}if(t.yAxis.broken){let M=t.yAxis.ticks.find(F=>F!==0);xn(e,y,M==null?R-k*.12:(R+v(M))/2,!0)}e.restore(),e.save(),e.strokeStyle="#000",e.lineWidth=$n;for(let M of t.lines)e.lineCap=M.dashed?"butt":"round",e.setLineDash(M.dashed?un:[]),e.beginPath(),e.moveTo(w(M.from.x),v(M.from.y)),e.lineTo(w(M.to.x),v(M.to.y)),e.stroke();e.restore(),e.save(),e.strokeStyle="#000",e.lineWidth=$n;for(let M of Zn(g))M.points.length<2||(e.lineCap=M.dashed?"butt":"round",e.setLineDash(M.dashed?un:[]),e.beginPath(),M.points.forEach((F,B)=>{B===0?e.moveTo(w(F.x),v(F.y)):e.lineTo(w(F.x),v(F.y))}),e.stroke());e.restore(),e.save(),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle";for(let M of t.lines){if(!M.label)continue;let F=M.labelAt==="from"?M.from:M.to,B=w(F.x)+12+(M.labelDx??0),H=v(F.y)+(M.labelDy??0),N=Math.min(H,R-6-i.axisLabel*.5);we(e,M.label,B,N,o,r,i.axisLabel,s)}e.restore(),e.save(),e.strokeStyle="#000",e.fillStyle="#000",e.lineWidth=ir;for(let M of t.arrows){let F=w(M.from.x),B=v(M.from.y),H=w(M.to.x),N=v(M.to.y),K=Math.hypot(H-F,N-B);if(!(K>0))continue;let $=(H-F)/K,j=(N-B)/K,le=-j*M.offset,Se=$*M.offset,te=Math.min(M.shorten,K*.4),ae=F+$*te+le,ge=B+j*te+Se,me=H-$*te+le,Le=N-j*te+Se;if(e.beginPath(),e.moveTo(ae,ge),e.lineTo(me,Le),e.stroke(),Ze(e,ae,ge,me,Le),M.label){let de=Qn(M.labelPos,Kn+4);e.textAlign=de.align,e.textBaseline=de.baseline,we(e,M.label,(ae+me)/2+de.dx,(ge+Le)/2+de.dy,o,r,i.axisLabel,s)}}e.restore(),e.save(),e.fillStyle="#000";for(let M of t.points){let F=w(M.x),B=v(M.y);if(M.dot&&(e.beginPath(),e.arc(F,B,he,0,Math.PI*2),e.fill()),!M.label)continue;let H=Qn(M.labelPos,he+Kn);e.textAlign=H.align,e.textBaseline=H.baseline,we(e,M.label,F+H.dx,B+H.dy,o,r,i.axisLabel,s)}e.restore(),e.save();for(let M of Zn(g))for(let F of M.points)fr(e,M,w(F.x),v(F.y));e.restore();let O=(M,F,B)=>{if(l){let H=Pe(e,M,i.tick,s),N=e.textAlign==="right"?H:e.textAlign==="center"?H/2:0,K=e.textBaseline==="top"?0:i.tick*.5,$=Yt(F-N-3,0,o),j=Yt(B-K-2,0,r);e.fillStyle="#fff",e.fillRect($,j,Math.min(H+6,o-$),Math.min(i.tick+4,r-j)),e.fillStyle="#000"}bn(e,M,F,B,i.tick,s)};e.save(),e.fillStyle="#000",e.font=m,e.textAlign="center",e.textBaseline="top",t.xAxis.ticks.forEach((M,F)=>{if(M===0)return;let B=hn(t.xAxis,F),H=_t(e,B,w(M),R+10,o,r,i.tick,s);O(B,H.x,H.y)}),e.textAlign=l?"left":"right",e.textBaseline="middle",t.yAxis.ticks.forEach((M,F)=>{if(M===0)return;let B=hn(t.yAxis,F),H=_t(e,B,y+(l?10:-10),v(M),o,r,i.tick,s);O(B,H.x,H.y)}),e.textAlign=l?"left":"center",e.textBaseline="top";let _=fe(e,"0",y+(l?8:0),R+10,o,r);if(O("0",_.x,_.y),e.restore(),e.save(),e.fillStyle="#000",t.xAxis.label&&(e.textAlign="left",e.textBaseline="middle",we(e,t.xAxis.label,W+10,R+i.tick*.6,o,r,i.axisLabel,s)),t.yAxis.label){e.textAlign=l?"center":"right",e.textBaseline="bottom";let M=G-(l?8:-4);if(u.length===1)we(e,t.yAxis.label,y+(l?0:-8),M,o,r,i.axisLabel,s);else{let F=i.axisLabel*jn,B=l?y:y-8-f/2;e.textAlign="center",u.forEach((H,N)=>{let K=M-(u.length-1-N)*F;we(e,H,B,K,o,r,i.axisLabel,s)})}}if(e.restore(),t.legend&&g.length>0){let M=g.map(F=>({type:"line",fillStyle:"#000",strokeStyle:"#000",label:F.label,dash:F.dashed?un:[],lineWidth:2.5,marker:F.marker,hollow:F.hollow}));Be({ctx:e,items:M,corner:t.legend,plotX:L,plotY:z,plotW:P,plotH:k,canvasW:o,canvasH:r,fontSize:i.axisLabel*.8,font:s(i.axisLabel*.8),avoid:g.flatMap(F=>F.points.map(B=>({x0:w(B.x)-he,y0:v(B.y)-he,x1:w(B.x)+he,y1:v(B.y)+he})))})}q({ctx:e,plotX:L,plotW:P,title:n.title,fontSize:i.title,fonts:n,canvasWidth:o}),X({ctx:e,plotX:L,plotW:P,height:r,source:n.source,sourceLeft:n.sourceLeft,sourceInline:n.sourceInline,footnotes:n.footnotes,fontSize:i.dataLabel,fonts:n,canvasWidth:o})}var mr=.4,br=34,no=.4,ur=4;function eo(e,o,r){if(e.length===0||o<=0||r<=0)return 1/0;let t=Math.max(...e),n=Math.min(...e);if(n<=0)return 1/0;let i=o*o,l=r*r;return Math.max(l*t/i,i/(l*n))}var to=e=>Number.isFinite(e)&&e>0?e:0;function hr(e,o){let r=e.map(()=>({x:o.x,y:o.y,w:0,h:0})),t=e.reduce((s,m)=>s+to(m),0);if(e.length===0||t<=0||o.w<=0||o.h<=0)return r;let n=e.map(s=>to(s)/t*o.w*o.h),i={...o},l=0;for(;l<n.length;){let s=Math.min(i.w,i.h);if(s<=0)break;let m=0,g=0;for(;l+m<n.length;){let a=n[l+m],d=n.slice(l,l+m);if(m>0&&(g<=0||eo([...d,a],g+a,s)>eo(d,g,s)))break;g+=a,m++}let p=n.slice(l,l+m),u=g/s,h=i.w>=i.h,f=0;for(let a=0;a<p.length;a++){let d=u>0?p[a]/u:0;r[l+a]=h?{x:i.x,y:i.y+f,w:u,h:d}:{x:i.x+f,y:i.y,w:d,h:u},f+=d}i=h?{x:i.x+u,y:i.y,w:Math.max(0,i.w-u),h:i.h}:{x:i.x,y:i.y+u,w:i.w,h:Math.max(0,i.h-u)},l+=m}return r}function gr(e,o){let r=Math.min(Math.max(o,1),e.length);if(r<=1)return[e];let t=Math.ceil(e.length/r),n=[];for(let i=0;i<e.length;i+=t)n.push(e.slice(i,i+t));return n}function dr(e,o,r,t,n,i=ur){let l=Math.max(1,Math.min(i,o.length)),s=g=>{let p=gr(o,g),u=Math.max(...p.map(a=>e.measureText(a).width)),h=u>0?r/u:1/0,f=t/(p.length*n*1.2);return{lines:p,scale:Math.min(1,h,f)}},m=s(1);for(let g=2;g<=l;g++){let p=s(g);p.scale>m.scale&&(m=p)}return m}function pr(e,o,r){return e.w<o||e.h<r*no*1.2}function cr(e,o=no){return e.scale<o}function yr(e,o){return e*o.scale}function xe(e,o,r,t,n){if(U(e,o,r),t.cells.length===0)return;let i=n.title?100:30,l=n.footnotes.filter(a=>a.trim()).length,s=!!n.source||!!t.reserveSourceSpace,m=(l>0?l*22+n.fontSize.dataLabel+12:0)+(s?n.fontSize.dataLabel+4:0),g={x:20,y:i,w:Math.max(0,o-40),h:Math.max(0,r-i-m-10)},p=hr(t.cells.map(a=>a.value),g),u=t.labelFontSize??n.fontSize.tick,h=t.minLabelWidth??br,f=u*mr;e.strokeStyle="#000",e.lineWidth=1,p.forEach(a=>{a.w<=0||a.h<=0||e.strokeRect(a.x,a.y,a.w,a.h)}),e.fillStyle="#000",e.textAlign="center",e.textBaseline="middle",e.font=I(u,n),p.forEach((a,d)=>{if(pr(a,h,u))return;let C=a.w-f*2;e.font=I(u,n);let c=dr(e,t.cells[d].label,C,a.h,u);if(cr(c))return;let T=yr(u,c);T!==u&&(e.font=I(T,n));let S=a.y+a.h/2-(c.lines.length-1)*T*1.2/2;c.lines.forEach((D,L)=>{e.fillText(D,a.x+a.w/2,S+L*T*1.2,C)}),T!==u&&(e.font=I(u,n))}),e.lineWidth=2,e.strokeRect(g.x,g.y,g.w,g.h),q({ctx:e,fonts:n,plotX:g.x,plotW:g.w,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:g.x,plotW:g.w,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var oo=["1","2","3","4","5","6","7","8","9","10","11","12"],ro={12:[0,1,2,3,4,5,6,7,8,9,10,11],4:[2,5,8,11],2:[0,6]};function et(e,o,r,t,n){U(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipLabel,n.legendLabel2||t.tempLabel],m=i&&l==="right"?Z(e,s,n.fontSize.dataLabel*.85+5,n):0,g=i&&l==="bottom"?ee(e,s,n.fontSize.dataLabel*.85+5,o-130-(130+m),n,["rect",t.monthInterval===12?"line":"circle"]):0,p={top:n.title?100:50,right:130+m,bottom:(()=>{let k=60;return i&&l==="bottom"&&(k+=70),k=Math.max(k,g),n.source&&(k+=30),k+=n.footnotes.filter(w=>w.trim()).length*22,k})(),left:130},u=p.left,h=p.top,f=o-p.left-p.right,a=r-p.top-p.bottom,d=t.months.map(k=>k.temp),C=t.months.map(k=>k.precip),c=t.tempRange.auto?V(d,6):{min:t.tempRange.min,max:t.tempRange.max,step:t.tempRange.step||Math.max(1,Math.round((t.tempRange.max-t.tempRange.min)/6))},T=t.precipRange.auto?V(C.filter(k=>k>0).length>0?C:[0,100],6):{min:t.precipRange.min,max:t.precipRange.max,step:t.precipRange.step||Math.max(1,Math.round((t.precipRange.max-t.precipRange.min)/6))};T.min<0&&(T.min=0);let S=ro[t.monthInterval]??ro[12];if(ce({ctx:e,padding:p,width:o,height:r,min:c.min,max:c.max,step:c.step,label:t.tempLabel,side:"left",fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel,drawGrid:!0}),ce({ctx:e,padding:p,width:o,height:r,min:T.min,max:T.max,step:T.step,label:t.precipLabel,side:"right",fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel}),t.monthInterval===12)xt({ctx:e,padding:p,width:o,height:r,labels:oo,indices:S,fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel});else{let k=S.map(w=>oo[w]);xt({ctx:e,padding:p,width:o,height:r,labels:k,fonts:n,tickFontSize:n.fontSize.tick,labelFontSize:n.fontSize.axisLabel})}let D=t.monthInterval===12?12:S.length,L=f/D,z=L*.55,P=k=>u+L*k+L/2;e.fillStyle="#AAAAAA";for(let k=0;k<S.length;k++){let w=S[k],v=t.months[w].precip;if(v<=0)continue;let y=(v-T.min)/(T.max-T.min)*a,E=(t.monthInterval===12?P(w):P(k))-z/2,A=h+a-y;e.fillRect(E,A,z,y),e.strokeStyle="#444",e.lineWidth=1,e.strokeRect(E,A,z,y)}if(n.showDataLabels){e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,n,"bold"),e.textAlign="center",e.textBaseline="bottom";for(let k=0;k<S.length;k++){let w=S[k],v=t.months[w].precip;if(v<=0)continue;let y=(v-T.min)/(T.max-T.min)*a,R=t.monthInterval===12?P(w):P(k),E=h+a-y;e.fillText(String(v),R,E-4)}}if(t.monthInterval===12){e.strokeStyle="#000",e.lineWidth=2.5,e.beginPath();for(let k=0;k<12;k++){let w=P(k),v=h+a-(t.months[k].temp-c.min)/(c.max-c.min)*a;k===0?e.moveTo(w,v):e.lineTo(w,v)}e.stroke()}for(let k=0;k<S.length;k++){let w=S[k],v=t.monthInterval===12?P(w):P(k),y=h+a-(t.months[w].temp-c.min)/(c.max-c.min)*a;e.fillStyle="#000",e.beginPath(),e.arc(v,y,5,0,Math.PI*2),e.fill(),n.showDataLabels&&(e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,n,"bold"),e.textAlign="center",e.textBaseline="bottom",e.fillText(String(t.months[w].temp),v,y-8))}q({ctx:e,fonts:n,plotX:u,plotW:f,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText("(\uC6D4)",u+f+30,h+a+12),i&&x({ctx:e,fonts:n,items:[{type:"rect",fillStyle:"#AAA",strokeStyle:"#666",label:s[0]},{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:u,plotY:h,plotW:f,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),X({ctx:e,fonts:n,plotX:u,plotW:f,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel})}var ao=35*Math.PI/180,so=.5,Sr=Math.cos(ao)*so,Lr=Math.sin(ao)*so;function Q(e,o,r,t,n,i){let l=t+r*i-e*Sr*i,s=n-o*i+e*Lr*i;return[l,s]}var Tr=[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]],io=[[4,0,!1],[4,5,!1],[4,6,!1],[0,1,!1],[0,2,!1],[1,3,!1],[2,3,!1],[1,5,!1],[2,6,!1],[3,7,!1],[5,7,!1],[6,7,!1]];function tt(e,o,r,t,n){U(e,o,r);let i=n.fontSize,l=n.title?100:60,s=40;n.source&&(s+=30),s+=n.footnotes.filter(w=>w.trim()).length*22;let m=o-240,g=r-l-s,p=Dr(e,t,o,r,l,g,Math.min(m*.5,g*.55),i,n),u=p.scale,h=Q(.5,.5,.5,0,0,u),f=o/2-h[0],a=l+g/2-h[1],d=Tr.map(([w,v,y])=>Q(w,v,y,f,a,u));e.save(),e.strokeStyle="#999",e.lineWidth=1.5,e.setLineDash([6,5]);for(let[w,v,y]of io)y&&(e.beginPath(),e.moveTo(d[w][0],d[w][1]),e.lineTo(d[v][0],d[v][1]),e.stroke());e.restore(),e.strokeStyle="#000",e.lineWidth=2;for(let[w,v,y]of io)y||(e.beginPath(),e.moveTo(d[w][0],d[w][1]),e.lineTo(d[v][0],d[v][1]),e.stroke());kr(e,t,f,a,u,o,r,n,i,p.names,p.nameSize);let C=Q(.5,.5,.5,f,a,u);for(let w of t.points){let[v,y]=Q(w.z,w.y,w.x,f,a,u);e.fillStyle="#000",e.beginPath(),e.arc(v,y,14,0,Math.PI*2),e.fill();let R=v-C[0],E=y-C[1],A=Math.sqrt(R*R+E*E)||1;R=R/A*40,E=E/A*40;let W=R+w.labelDx,b=E+w.labelDy;e.font=I(i.dataLabel+10,n,"bold"),e.textAlign=W>=0?"left":"right",e.textBaseline="middle";let G=fe(e,w.label,v+W+(W>=0?4:-4),y+b,o,r),O=G.x-(W>=0?4:-4),_=G.y;e.strokeStyle="#000",e.lineWidth=1.2,e.beginPath(),e.moveTo(v,y),e.lineTo(O,_),e.stroke(),e.fillStyle="#000",e.fillText(w.label,G.x,G.y)}let c=d.map(([w])=>w),T=Math.min(...c)-30,S=Math.max(...c)+30,D=T,L=S-T;if(n.title){let w=be(n),v=Q(0,1.25,0,f,a,u);e.fillStyle="#000",e.font=`bold ${i.title}px ${w}`,e.textAlign="center",e.textBaseline="bottom",re(e,n.title,o/2,v[1]-50,o,r,i.title,y=>`bold ${y}px ${w}`)}let z=Q(1.25,0,0,f,a,u),P=Q(1,0,0,f,a,u),k=Math.max(z[1]+20+i.axisLabel,P[1]+10+i.axisLabel*.9)+47;X({ctx:e,fonts:n,plotX:D,plotW:L,height:k,source:n.source,footnotes:n.footnotes,fontSize:i.dataLabel})}function gn(e,o,r,t,n){let l=Math.atan2(n-r,t-o);e.beginPath(),e.moveTo(o,r),e.lineTo(t,n),e.stroke(),e.beginPath(),e.moveTo(t,n),e.lineTo(t-10*Math.cos(l-.4),n-10*Math.sin(l-.4)),e.lineTo(t-10*Math.cos(l+.4),n-10*Math.sin(l+.4)),e.closePath(),e.fill()}var fo=1.2,vr=.8;function dn(e,o,r,t,n){let l=Q(1.25,0,0,o,r,t),s=Q(0,1.25,0,o,r,t),m=Q(0,0,1.25,o,r,t),g=Q(1,0,0,o,r,t),p=Q(0,1,0,o,r,t),u=Q(0,0,1,o,r,t),h=Q(0,0,0,o,r,t);return[{lines:n.z,x:l[0]-6,y:l[1]+20,align:"right",baseline:"middle",kind:"name"},{lines:[e.zAxis.highLabel],x:g[0]+3+e.zAxis.highOffset.x,y:g[1]+10+e.zAxis.highOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:n.y,x:s[0],y:s[1]-10,align:"center",baseline:"bottom",kind:"name"},{lines:[e.yAxis.highLabel],x:p[0]+6+e.yAxis.highOffset.x,y:p[1]-20+e.yAxis.highOffset.y,align:"left",baseline:"middle",kind:"dir"},{lines:n.x,x:m[0]+6,y:m[1],align:"left",baseline:"middle",kind:"name"},{lines:[e.xAxis.highLabel],x:u[0]+e.xAxis.highOffset.x,y:u[1]+14+e.xAxis.highOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:[e.xAxis.lowLabel],x:h[0]+e.xAxis.lowOffset.x,y:h[1]+12+e.xAxis.lowOffset.y,align:"center",baseline:"top",kind:"dir"},{lines:[e.yAxis.lowLabel],x:h[0]-10+e.yAxis.lowOffset.x,y:h[1]-4+e.yAxis.lowOffset.y,align:"right",baseline:"bottom",kind:"dir"},{lines:[e.zAxis.lowLabel],x:h[0]+10+e.zAxis.lowOffset.x,y:h[1]+12+e.zAxis.lowOffset.y,align:"left",baseline:"top",kind:"dir"}]}function lo(e,o,r,t){let n=Q(.5,.5,.5,0,0,t);return[e/2-n[0],o+r/2-n[1]]}function Dr(e,o,r,t,n,i,l,s,m){e.save();let g=s.axisLabel,p=d=>I(d,m,"bold"),u=I(s.axisLabel*.9,m,"normal"),h={x:[o.xAxis.name],y:[o.yAxis.name],z:[o.zAxis.name]},f=d=>{let[C,c]=lo(r,n,i,d);return dn(o,C,c,d,h).every(T=>{e.font=T.kind==="name"?p(g):u,e.textAlign=T.align,e.textBaseline=T.baseline;let S=g*fo,D=T.lines.map(z=>se(e,z)),L=(T.lines.length-1)*S/2;return T.x-Math.max(...D.map(z=>z.left))>=1&&T.x+Math.max(...D.map(z=>z.right))<=r-1&&T.y-L-Math.max(...D.map(z=>z.up))>=1&&T.y+L+Math.max(...D.map(z=>z.down))<=t-1})},a=ue(20,l,f);if(a<l*vr){let[d,C]=lo(r,n,i,l);e.font=p(g);let c=S=>S.align==="left"?r-1-S.x:S.align==="right"?S.x-1:2*Math.min(S.x-1,r-1-S.x),T=dn(o,d,C,l,h);h={z:oe(e,o.zAxis.name,Math.max(30,c(T[0]))),y:oe(e,o.yAxis.name,Math.max(30,c(T[2]))),x:oe(e,o.xAxis.name,Math.max(30,c(T[4])))},a=ue(20,l,f)}return a<=20&&(g=s.axisLabel*.7,e.font=p(g),h={x:h.x.flatMap(d=>oe(e,d,Math.max(30,r/3))),y:h.y.flatMap(d=>oe(e,d,Math.max(30,r/3))),z:h.z.flatMap(d=>oe(e,d,Math.max(30,r/3)))},a=ue(20,l,f)),e.restore(),{scale:a,names:h,nameSize:g}}function kr(e,o,r,t,n,i,l,s,m,g,p){e.strokeStyle="#000",e.fillStyle="#000",e.lineWidth=1.5;let h=Q(1,0,0,r,t,n),f=Q(1.25,0,0,r,t,n);gn(e,h[0],h[1],f[0],f[1]);let a=Q(0,1,0,r,t,n),d=Q(0,1.25,0,r,t,n);gn(e,a[0],a[1],d[0],d[1]);let C=Q(0,0,1,r,t,n),c=Q(0,0,1.25,r,t,n);gn(e,C[0],C[1],c[0],c[1]);let T=I(p,s,"bold"),S=I(m.axisLabel*.9,s,"normal");e.fillStyle="#000";for(let D of dn(o,r,t,n,g)){if(D.lines.every(P=>!P))continue;e.font=D.kind==="name"?T:S,e.textAlign=D.align,e.textBaseline=D.baseline;let L=p*fo,z=An(e,D.lines,D.x,D.y,L,i,l);Te(e,D.lines,z.x,z.y,L)}}var Ar=["1","2","3","4","5","6","7","8","9","10","11","12"],mo={12:[0,1,2,3,4,5,6,7,8,9,10,11],4:[2,5,8,11],2:[0,6]};function nt(e,o,r,t,n){U(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipLabel,n.legendLabel2||t.tempLabel],m=i&&l==="right"&&!t.insideLegend?Z(e,s,n.fontSize.dataLabel*.85+5,n):0,g=0;(t.tempAxisName||t.precipAxisName)&&(e.save(),e.font=I(n.fontSize.axisLabel,n,"bold"),g=e.measureText("\uAC00").width+12,e.restore());let p=130+m+(t.precipAxisName?g:0),u=130+(t.tempAxisName?g:0),h=i&&l==="bottom"&&!t.insideLegend?ee(e,s,n.fontSize.dataLabel*.85+5,o-u-p,n,["rect",t.monthInterval===12?"line":"circle"]):0,f={top:n.title?100:50,right:p,bottom:(()=>{let b=60;return i&&l==="bottom"&&!t.insideLegend&&(b+=60),b=Math.max(b,h),n.source&&(b+=30),b+=n.footnotes.filter(G=>G.trim()).length*22,b})(),left:u},a=f.left,d=f.top,C=o-f.left-f.right,c=r-f.top-f.bottom,T=mo[t.monthInterval]??mo[12],S=t.months.map((b,G)=>b.temp-t.baseMonths[G].temp),D=t.months.map((b,G)=>b.precip-t.baseMonths[G].precip),L=T.map(b=>S[b]),z=T.map(b=>D[b]),P=t.precipRange.auto?V(z.length>0?z:[0],6):{min:t.precipRange.min,max:t.precipRange.max,step:t.precipRange.step??0};if(P.step===0&&(P.step=Math.max(1,Math.round((P.max-P.min)/6))),t.precipRange.auto){let b=Math.max(Math.abs(P.min),Math.abs(P.max));P.min=-b,P.max=b}let k=t.tempRange.auto?(()=>{let b=V(L.length>0?L:[0],6),G=Math.max(Math.abs(b.min),Math.abs(b.max));return{min:-G,max:G,step:b.step}})():{min:t.tempRange.min,max:t.tempRange.max,step:t.tempRange.step??0};k.step===0&&(k.step=Math.max(.5,Math.round((k.max-k.min)/6*10)/10));let w=bo(e,f,o,r,k,"left",t.tempLabel,n,n.fontSize),v=bo(e,f,o,r,P,"right",t.precipLabel,n,n.fontSize),y=T.length,R=C/y;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(a,d+c),e.lineTo(a+C,d+c),e.stroke(),t.showFrame&&(e.beginPath(),e.moveTo(a,d),e.lineTo(a+C,d),e.stroke()),e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";for(let b=0;b<y;b++){let G=a+R*b+R/2;e.fillText(Ar[T[b]],G,d+c+12)}let E=d+c-(0-P.min)/(P.max-P.min)*c;e.strokeStyle="#000",e.lineWidth=1.5,e.setLineDash([]),e.beginPath(),e.moveTo(a,E),e.lineTo(a+C,E),e.stroke();let A=Math.min(R*.55,80),W=[];for(let b=0;b<y;b++){let G=T[b],O=D[G],M=a+R*b+R/2-A/2,F=d+c-(O-P.min)/(P.max-P.min)*c;e.fillStyle=t.barFill??(O>=0?"#666":"#CCC");let B=Math.min(E,F),H=Math.abs(F-E);e.fillRect(M,B,A,H),e.strokeStyle=t.barStroke??"#444",e.lineWidth=1,e.strokeRect(M,B,A,H),W.push({x0:M,y0:B,x1:M+A,y1:B+H})}if(t.monthInterval===12){e.strokeStyle="#000",e.lineWidth=2.5,e.beginPath();let b=null;for(let G=0;G<y;G++){let O=T[G],_=a+R*G+R/2,M=d+c-(S[O]-k.min)/(k.max-k.min)*c;G===0?e.moveTo(_,M):e.lineTo(_,M),b&&W.push({x0:b.x,y0:Math.min(b.y,M),x1:_,y1:Math.max(b.y,M)}),b={x:_,y:M}}e.stroke()}for(let b=0;b<y;b++){let G=T[b],O=a+R*b+R/2,_=d+c-(S[G]-k.min)/(k.max-k.min)*c;e.fillStyle="#000",t.markerShape==="square"?e.fillRect(O-5,_-5,10,10):(e.beginPath(),e.arc(O,_,5,0,Math.PI*2),e.fill()),W.push({x0:O-6,y0:_-6,x1:O+6,y1:_+6})}e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText("(\uC6D4)",a+C+30,d+c+12),i&&t.insideLegend?Be({ctx:e,items:[{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",marker:t.markerShape??"circle",label:s[1]},{type:"rect",fillStyle:t.barFill??"#888",strokeStyle:t.barStroke??"#444",label:s[0]}],corner:t.insideLegend,plotX:a,plotY:d,plotW:C,plotH:c,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.9,font:I(n.fontSize.dataLabel*.9,n,"bold"),avoid:W}):i&&x({ctx:e,fonts:n,items:[{type:"rect",fillStyle:"#888",strokeStyle:"#444",label:s[0]},{type:t.monthInterval===12?"line":"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:a,plotY:d,plotW:C,plotH:c,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),t.tempAxisName&&uo(e,t.tempAxisName,a-22-w-g/2,d,c,r,n.fontSize.axisLabel,n),t.precipAxisName&&uo(e,t.precipAxisName,a+C+22+v+g/2,d,c,r,n.fontSize.axisLabel,n),q({ctx:e,fonts:n,plotX:a,plotW:C,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:a,plotW:C,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function bo(e,o,r,t,n,i,l,s,m){let g=o.left,p=o.top,u=r-o.left-o.right,h=t-o.top-o.bottom,f=i==="left"?g:g+u;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(f,p),e.lineTo(f,p+h),e.stroke(),e.fillStyle="#000",e.font=I(m.tick,s,"bold"),e.textBaseline="middle",e.textAlign=i==="left"?"right":"left";let a=0,d=Math.round((n.max-n.min)/n.step);for(let C=0;C<=d;C++){let c=n.min+C*n.step,T=p+h-(c-n.min)/(n.max-n.min)*h;e.lineWidth=1.5,e.beginPath(),i==="left"?(e.moveTo(f-6,T),e.lineTo(f,T)):(e.moveTo(f,T),e.lineTo(f+6,T)),e.stroke();let S=i==="left"?f-12:f+12,D=Number.isInteger(c)?c.toString():c.toFixed(1);e.fillText(D,S,T),a=Math.max(a,e.measureText(D).width)}if(l){e.save();let C=S=>I(S,s,"bold");e.fillStyle="#000",e.textBaseline="bottom",e.textAlign=i==="left"?"right":"left",e.font=C(Ae(e,[l],m.axisLabel,r-2,C));let c=i==="left"?f-12:f+12,T=fe(e,l,c,p-16,r,t);e.fillText(l,T.x,T.y),e.restore()}return a}function uo(e,o,r,t,n,i,l,s){let m=[...o].filter(c=>c.trim()!=="");if(m.length===0)return;let g=c=>(m.length-1)*c*1.15+c,p=l;g(p)>n&&(p=Math.max(l*.7,n/g(1))),g(p)>i-2&&(p=(i-2)/g(1)),e.save(),e.font=I(p,s,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="middle";let u=p*1.15,h=(m.length-1)*u/2,f=t+n/2,a=f-h-p/2,d=f+h+p/2;a<1?f+=1-a:d>i-1&&(f-=d-(i-1));let C=f-h;for(let c of m)e.fillText(c,r,C),C+=u;e.restore()}function ot(e,o,r,t,n){U(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.precipDiffLabel,n.legendLabel2||t.tempDiffLabel],m=i&&l==="right"?Z(e,s,n.fontSize.dataLabel*.85+5,n):0,g=i&&l==="bottom"?ee(e,s,n.fontSize.dataLabel*.85+5,o-130-(130+m),n,["rect","circle"]):0,p={top:n.title?100:50,right:130+m,bottom:(()=>{let y=60;return i&&l==="bottom"&&(y+=60),y=Math.max(y,g),n.source&&(y+=30),y+=n.footnotes.filter(R=>R.trim()).length*22,y})(),left:130},u=p.left,h=p.top,f=o-p.left-p.right,a=r-p.top-p.bottom,d=t.regions,C=d.length,c=d.map(y=>y.precip-t.basePrecip),T=d.map(y=>y.temp-t.baseTemp),S=c,D=T,L=t.precipRange.auto?V(S,6):{min:t.precipRange.min,max:t.precipRange.max,step:0};if(L.step===0&&(L.step=Math.max(1,Math.round((L.max-L.min)/6))),t.precipRange.auto){let y=Math.max(Math.abs(L.min),Math.abs(L.max));L.min=-y,L.max=y}let z=t.tempRange.auto?V(D,6):{min:t.tempRange.min,max:t.tempRange.max,step:0};if(z.step===0&&(z.step=Math.max(1,Math.round((z.max-z.min)/6))),t.tempRange.auto){let y=Math.max(Math.abs(z.min),Math.abs(z.max));z.min=-y,z.max=y}ho(e,p,o,r,z,"left",t.tempUnit,n,n.fontSize),ho(e,p,o,r,L,"right",t.precipUnit,n,n.fontSize),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(u,h+a),e.lineTo(u+f,h+a),e.stroke();let P=h+a-(0-L.min)/(L.max-L.min)*a;e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.moveTo(u,P),e.lineTo(u+f,P),e.stroke();let k=f/C,w=Math.min(k*.5,80);e.fillStyle="#000",e.font=I(n.fontSize.tick*1.2,n,"bold"),e.textAlign="center",e.textBaseline="top";let v=y=>I(y,n,"bold");for(let y=0;y<C;y++){let R=u+k*y+k/2;re(e,d[y].label,R,h+a+12,o,r,n.fontSize.tick*1.2,v)}for(let y=0;y<C;y++){let R=c[y],A=u+k*y+k/2-w/2,W=h+a-(R-L.min)/(L.max-L.min)*a;e.fillStyle=R>=0?"#888":"#CCC";let b=Math.min(P,W),G=Math.abs(W-P);e.fillRect(A,b,w,G),e.strokeStyle="#444",e.lineWidth=1,e.strokeRect(A,b,w,G)}for(let y=0;y<C;y++){let R=u+k*y+k/2,E=h+a-(T[y]-z.min)/(z.max-z.min)*a;e.fillStyle="#000",e.beginPath(),e.arc(R,E,7,0,Math.PI*2),e.fill()}if(n.showDataLabels){e.font=I(n.fontSize.dataLabel,n,"bold"),e.textAlign="center";for(let y=0;y<C;y++){let R=u+k*y+k/2,E=c[y],A=h+a-(E-L.min)/(L.max-L.min)*a;e.fillStyle="#000",e.textBaseline=E>=0?"bottom":"top",e.fillText(String(E),R,E>=0?A-w/2-4:A+4);let W=T[y],b=h+a-(W-z.min)/(z.max-z.min)*a;e.textBaseline="bottom",e.fillText(String(W),R,b-10)}}i&&x({ctx:e,fonts:n,items:[{type:"rect",fillStyle:"#888",strokeStyle:"#444",label:s[0]},{type:"circle",fillStyle:"#000",label:s[1]}],position:l,plotX:u,plotY:h,plotW:f,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,rightGap:80}),q({ctx:e,fonts:n,plotX:u,plotW:f,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:u,plotW:f,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel})}function ho(e,o,r,t,n,i,l,s,m){let g=o.left,p=o.top,u=r-o.left-o.right,h=t-o.top-o.bottom,f=i==="left"?g:g+u;e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(f,p),e.lineTo(f,p+h),e.stroke(),e.fillStyle="#000",e.font=I(m.tick,s,"bold"),e.textBaseline="middle",e.textAlign=i==="left"?"right":"left";let a=Math.round((n.max-n.min)/n.step);for(let C=0;C<=a;C++){let c=n.min+C*n.step,T=p+h-(c-n.min)/(n.max-n.min)*h;e.lineWidth=1.5,e.beginPath(),i==="left"?(e.moveTo(f-6,T),e.lineTo(f,T)):(e.moveTo(f,T),e.lineTo(f+6,T)),e.stroke();let S=i==="left"?f-12:f+12,D=Number.isInteger(c)?c.toString():c.toFixed(1);e.fillText(D,S,T)}e.save(),e.font=I(m.axisLabel,s,"bold"),e.fillStyle="#000",e.textBaseline="bottom";let d=i==="left"?f-12:f+12;e.textAlign=i==="left"?"right":"left",e.fillText(l,d,p-16),e.restore()}var Oe=[{dash:[],width:2},{dash:[8,4],width:2},{dash:[2,3],width:2},{dash:[8,3,2,3],width:2},{dash:[12,4,2,4,2,4],width:2}],He=["filledCircle","filledSquare","filledTriangle","openCircle","openSquare"];function co(e,o,r,t,n){let i=n;switch(e.lineWidth=1.5,e.strokeStyle="#000",o){case"filledCircle":e.fillStyle="#000",e.beginPath(),e.arc(r,t,i,0,Math.PI*2),e.fill();break;case"filledSquare":e.fillStyle="#000",e.fillRect(r-i,t-i,i*2,i*2);break;case"filledTriangle":e.fillStyle="#000",e.beginPath(),e.moveTo(r,t-i*1.1),e.lineTo(r-i,t+i*.7),e.lineTo(r+i,t+i*.7),e.closePath(),e.fill();break;case"openCircle":e.fillStyle="#fff",e.beginPath(),e.arc(r,t,i,0,Math.PI*2),e.fill(),e.stroke();break;case"openSquare":e.fillStyle="#fff",e.fillRect(r-i,t-i,i*2,i*2),e.strokeRect(r-i,t-i,i*2,i*2);break}}function go(e,o,r,t){co(e,o,r,t,5)}function rt(e,o,r,t,n){U(e,o,r);let i=n.fontSize,l=n.showLegend&&t.series.length>0,s=n.legendPosition,m=t.series.map(b=>b.label),g=l&&s==="right"?Z(e,m,i.dataLabel*.85+5,n):0,p=l&&s==="bottom"?65+Ue(e,m,t.series.map(()=>36),i.dataLabel*.85+5,o-80-(80+g),n,{iconGap:8}).boxH+2:0,u={top:n.title?110:60,right:80+g,bottom:(()=>{let b=90;return l&&s==="bottom"&&(b+=80),b=Math.max(b,p),n.source&&(b+=30),b+=n.footnotes.filter(G=>G.trim()).length*22,b})(),left:80},h=u.left,f=u.top,a=o-u.left-u.right,d=r-u.top-u.bottom,C=t.series.flatMap(b=>b.months.map(G=>G.temp)),c=t.series.flatMap(b=>b.months.map(G=>G.precip)),T=V(C),S=V(c),D=t.xRange.auto?T.min:t.xRange.min,L=t.xRange.auto?T.max:t.xRange.max,z=t.yRange.auto?S.min:t.yRange.min,P=t.yRange.auto?S.max:t.yRange.max,k=t.xRange.auto?T.step:(L-D)/5,w=t.yRange.auto?S.step:(P-z)/5,v=b=>h+(b-D)/(L-D)*a,y=b=>f+d-(b-z)/(P-z)*d;e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]);for(let b=D+k;b<L;b+=k){let G=v(b);e.beginPath(),e.moveTo(G,f),e.lineTo(G,f+d),e.stroke()}for(let b=z+w;b<P;b+=w){let G=y(b);e.beginPath(),e.moveTo(h,G),e.lineTo(h+a,G),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(h,f),e.lineTo(h,f+d),e.lineTo(h+a,f+d),e.stroke(),e.fillStyle="#000",e.font=I(i.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";for(let b=D;b<=L+k*.01;b+=k){let G=v(b);e.lineWidth=1,e.beginPath(),e.moveTo(G,f+d),e.lineTo(G,f+d+6),e.stroke(),b+k>L+k*.01&&t.xUnit||e.fillText(po(b),G,f+d+10)}e.textAlign="right",e.textBaseline="middle";for(let b=z;b<=P+w*.01;b+=w){let G=y(b);e.lineWidth=1,e.beginPath(),e.moveTo(h-6,G),e.lineTo(h,G),e.stroke(),b+w>P+w*.01&&t.yUnit||e.fillText(po(b),h-10,G)}e.font=I(i.axisLabel,n,"bold"),e.fillStyle="#000";let R=b=>I(b,n,"bold");t.xUnit&&(e.textAlign="right",e.textBaseline="top",re(e,t.xUnit,h+a+10,f+d+35,o,r,i.axisLabel,R)),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",re(e,t.yUnit,h,f-16,o,r,i.axisLabel,R));let E=t.monthLabelStyle==="english"?Pt:Ct,A=t.mode==="loop"||t.mode==="both",W=t.mode==="points"||t.mode==="both";for(let b=0;b<t.series.length;b++){let G=t.series[b],O=Oe[b%Oe.length],_=G.months.map(M=>({cx:v(M.temp),cy:y(M.precip)}));if(A&&_.length===12){e.strokeStyle="#000",e.lineWidth=O.width,e.setLineDash(O.dash),e.beginPath(),e.moveTo(_[0].cx,_[0].cy);for(let M=1;M<12;M++)e.lineTo(_[M].cx,_[M].cy);e.closePath(),e.stroke(),e.setLineDash([])}if(W){let M=He[b%He.length];for(let F=0;F<12;F++){let{cx:B,cy:H}=_[F];e.fillStyle="#fff",e.beginPath(),e.arc(B,H,7,0,Math.PI*2),e.fill(),co(e,M,B,H,5),e.fillStyle="#000",e.font=I(i.dataLabel,n,"bold"),e.textAlign="left",e.textBaseline="bottom",e.fillText(E[F],B+9,H-5)}}}if(l){let b=i.dataLabel*.85+5,G=be(n);e.save(),e.font=`bold ${b}px ${G}`;let O=36,_=8,M=12,F=b+8,B=t.series.length,H=t.series.map(N=>O+_+e.measureText(N.label).width);if(s==="bottom"){let K=a,$=Ue(e,t.series.map(te=>te.label),t.series.map(()=>O),b,K,n,{iconGap:_,padding:M,spacing:30}),j=$.boxH,le=h,Se=Math.max(0,Math.min(f+d+65,r-j-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(le,Se,K,j,0),e.fill(),e.stroke();for(let te=0;te<$.rows.length;te++){let ae=$.rows[te],ge=ae.reduce((de,Vt)=>de+Vt.width,0)+30*(ae.length-1),me=le+(K-ge)/2,Le=Se+M+te*($.lineHeight+$.rowGap)+$.lineHeight/2;for(let{index:de,width:Vt}of ae){let Ln=Oe[de%Oe.length];e.strokeStyle="#000",e.lineWidth=Ln.width,e.setLineDash(Ln.dash),e.beginPath(),e.moveTo(me,Le),e.lineTo(me+O,Le),e.stroke(),e.setLineDash([]),go(e,He[de%He.length],me+O/2,Le),e.font=`bold ${$.fontSize}px ${G}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(t.series[de].label,me+O+_,Le),me+=Vt+30}}}else{let $=Math.max(...H)+M*2,j=F*B+10*(B-1)+M*2,le=Math.max(0,Math.min(h+a+20,o-$-1)),Se=Math.max(0,Math.min(f+d-j,r-j-1));e.strokeStyle="#888",e.lineWidth=1.5,e.fillStyle="#fff",e.beginPath(),e.roundRect(le,Se,$,j,0),e.fill(),e.stroke();let te=Se+M+F/2;for(let ae=0;ae<B;ae++){let ge=le+M,me=Oe[ae%Oe.length];e.strokeStyle="#000",e.lineWidth=me.width,e.setLineDash(me.dash),e.beginPath(),e.moveTo(ge,te),e.lineTo(ge+O,te),e.stroke(),e.setLineDash([]),go(e,He[ae%He.length],ge+O/2,te),e.font=`bold ${b}px ${G}`,e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(t.series[ae].label,ge+O+_,te),te+=F+10}}e.restore()}q({ctx:e,fonts:n,plotX:h,plotW:a,title:n.title,fontSize:i.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:h,plotW:a,height:r,source:n.source,footnotes:n.footnotes,fontSize:i.dataLabel,canvasWidth:o})}function po(e){return Math.abs(e)<1e-4?"0":Number(e.toFixed(2)).toString()}function it(e){let o=Math.round(e*1e10)/1e10;return Number.isInteger(o)?o.toString():o.toFixed(1)}var Mr=6,Rr=12;function Cr(e,o,r){if(!Number.isFinite(e)||e<=0)return 1;let t=Math.max(1,Math.floor(o/(r+Mr))),n=(i,l)=>Math.abs(i/l-Math.round(i/l))<1e-9;for(let i of[1,.5,.1])for(let l=Math.min(t,Rr);l>=2;l-=1){let s=e/l;if(s>0&&n(s,i))return s}return e}function lt(e,o,r,t,n){U(e,o,r);let i=n.showLegend,l=n.legendPosition,s=[n.legendLabel1||t.maleLabel,n.legendLabel2||t.femaleLabel],m=i&&l==="right"?Z(e,s,n.fontSize.dataLabel*.85+5,n):0,g=i&&l==="bottom"?ee(e,s,n.fontSize.dataLabel*.85+5,o-60-(80+m),n):0,p={top:n.title?100:50,right:80+m,bottom:(()=>{let A=90;return i&&l==="bottom"&&(A+=60),A=Math.max(A,g),n.source&&(A+=30),A+=n.footnotes.filter(W=>W.trim()).length*22,A})(),left:60},u=p.left,h=p.top,f=o-p.left-p.right,a=r-p.top-p.bottom,d=t.ages,C=t.numericAgeAxis&&d.length>0?d.length:Re.length,c=t.unit==="percent",T=d.flatMap(A=>[A.male,A.female]),S=t.range.auto?Math.max(...T,1):t.range.max;if(t.range.auto){let A=Fe(S,5);S=Math.ceil(S/A)*A}let D=u+f/2,L=f/2,z=a/C,P=z*.1,k=z-P-2,w=t.ageLabelSide;e.strokeStyle="#000",e.lineWidth=2,w==="left"&&(e.beginPath(),e.moveTo(u,h),e.lineTo(u,h+a),e.stroke()),w==="right"&&(e.beginPath(),e.moveTo(u+f,h),e.lineTo(u+f,h+a),e.stroke()),w==="center"&&(e.beginPath(),e.moveTo(D,h),e.lineTo(D,h+a),e.stroke()),e.beginPath(),e.moveTo(u,h),e.lineTo(u+f,h),e.stroke(),e.beginPath(),e.moveTo(u,h+a),e.lineTo(u+f,h+a),e.stroke(),e.save(),e.font=I(n.fontSize.tick,n,"bold");let v=Cr(S,L,e.measureText(it(S)).width);e.restore();for(let A=v;A<=S;A+=v){let W=A/S*L;e.save(),e.strokeStyle="#aaa",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(D-W,h),e.lineTo(D-W,h+a),e.stroke(),e.beginPath(),e.moveTo(D+W,h),e.lineTo(D+W,h+a),e.stroke(),e.restore()}for(let A=0;A<C;A++){let W=h+a-(A+1)*z+P/2,b=d[A].male/S*L,G=d[A].female/S*L;e.fillStyle=t.sexFills?.[0]??"#666",e.fillRect(D-b,W,b,k),e.strokeStyle=t.sexFills?"#000":"#444",e.lineWidth=.5,e.strokeRect(D-b,W,b,k),e.fillStyle=t.sexFills?.[1]??"#BBB",e.fillRect(D,W,G,k),e.strokeStyle=t.sexFills?"#000":"#888",e.lineWidth=.5,e.strokeRect(D,W,G,k)}if(e.fillStyle="#000",e.textBaseline="middle",t.numericAgeAxis){e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="right";let A=20,W=C*5;for(let b=0;b<=W;b+=A){let G=h+a-b/W*a;e.lineWidth=1,e.strokeStyle="#000",e.beginPath(),e.moveTo(u-6,G),e.lineTo(u,G),e.stroke(),e.fillText(String(b),u-10,G)}t.ageUnit&&(e.textBaseline="bottom",re(e,t.ageUnit,u+4,h-8,o,r,n.fontSize.tick,b=>I(b,n,"bold")),e.font=I(n.fontSize.tick,n,"bold"),e.textBaseline="middle")}else{e.font=I(n.fontSize.tick*.75,n,"bold");for(let A=0;A<C;A++){let W=h+a-(A+1)*z+z/2;w==="center"?(e.textAlign="center",e.fillText(Re[A],D,W)):w==="left"?(e.textAlign="right",e.fillText(Re[A],u-8,W)):(e.textAlign="left",e.fillText(Re[A],u+f+8,W))}}e.font=I(n.fontSize.tick,n,"bold"),e.textBaseline="top",e.fillStyle="#000";let y=[];for(let A=0;A<=S+v*.001;A+=v){let W=Math.round(A*1e10)/1e10;if(W>S)break;y.push(W)}let R=Math.max(1,y.length-1),E=ie(L/R,ne(e,y.map(it)));for(;E<R&&R%E!==0;)E+=1;for(let A=0;A<y.length;A++){let W=y[A],b=A%E===0,G=W/S*L,O=D-G;e.strokeStyle="#000",e.lineWidth=1,e.beginPath(),e.moveTo(O,h+a),e.lineTo(O,h+a+5),e.stroke(),b&&(e.textAlign="center",e.fillText(it(W),O,h+a+10));let _=D+G;e.strokeStyle="#000",e.lineWidth=1,e.beginPath(),e.moveTo(_,h+a),e.lineTo(_,h+a+5),e.stroke(),W>0&&b&&(e.textAlign="center",e.fillText(it(W),_,h+a+10))}if(e.font=I(n.fontSize.axisLabel,n,"bold"),e.textBaseline="bottom",e.fillStyle="#000",e.textAlign="center",e.fillText(t.maleLabel,u+L/2,h-16),e.fillText(t.femaleLabel,D+L/2,h-16),e.save(),t.axisLabelInline){e.font=I(n.fontSize.tick,n,"bold");let A=e.measureText(it(S)).width/2;e.textAlign="left",e.textBaseline="top",re(e,t.axisLabel,u+f+A+8,h+a+10,o,r,n.fontSize.tick,W=>I(W,n,"bold"))}else{e.font=I(n.fontSize.axisLabel*.85,n,"bold");let A=h+a+10+n.fontSize.tick+22;e.textAlign="left",re(e,t.axisLabel,u+f+4,A,o,r,n.fontSize.axisLabel*.85,W=>I(W,n,"bold"))}if(e.restore(),n.showDataLabels){e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.fillStyle="#000";for(let A=0;A<C;A++){let W=h+a-(A+1)*z+z/2,b=d[A].male/S*L,G=d[A].female/S*L,O=c?d[A].male.toFixed(1):String(d[A].male),_=c?d[A].female.toFixed(1):String(d[A].female);d[A].male>0&&(e.textAlign="right",e.fillText(O,D-b-4,W)),d[A].female>0&&(e.textAlign="left",e.fillText(_,D+G+4,W))}}q({ctx:e,fonts:n,plotX:u,plotW:f,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i&&x({ctx:e,fonts:n,items:[{type:"rect",fillStyle:"#666",strokeStyle:"#444",label:s[0]},{type:"rect",fillStyle:"#BBB",strokeStyle:"#888",label:s[1]}],position:l,plotX:u,plotY:h,plotW:f,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5}),X({ctx:e,fonts:n,plotX:u,plotW:f,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var Xt=[{dash:[],width:2},{dash:[8,4],width:2},{dash:[2,3],width:2},{dash:[8,3,2,3],width:2},{dash:[12,4,2,4,2,4],width:2}],_e=["#000","#444","#777","#AAA","#CCC"];function at(e,o,r,t,n){U(e,o,r);let i=n.fontSize,l=t.axisLabels.length;if(l<3)return;let s=n.showLegend&&t.series.length>1,m=n.legendPosition,g=t.series.map(b=>b.label),p=s&&m==="right"?Z(e,g,i.dataLabel*.85+5,n,"line"):0,u=n.title?60:10,h=60+p,f=60,a=10;s&&m==="bottom"&&(a+=70,a=Math.max(a,ee(e,g,i.dataLabel*.85+5,o-f-h,n,"line",30))),n.source&&(a+=25),a+=n.footnotes.filter(b=>b.trim()).length*22;let d=o-f-h,C=r-u-a,c=f+d/2,T=u+C/2,S=Array.from({length:l},(b,G)=>-Math.PI/2+2*Math.PI*G/l),D=i.axisLabel*.85,L=b=>I(b,n,"bold"),{radius:z,labelLines:P,labelSize:k}=Wr(e,t.axisLabels,S,c,T,o,r,Math.min(d,C)/2-40,D,L),w=t.series.flatMap(b=>b.values),v=w.length>0?Math.max(...w,1):100,y=t.autoMax?Math.ceil(v/t.gridSteps)*t.gridSteps:t.maxValue,R=(b,G)=>[c+Math.cos(b)*G,T+Math.sin(b)*G];e.save(),e.strokeStyle="#ccc",e.lineWidth=.8;for(let b=1;b<=t.gridSteps;b++){let G=b/t.gridSteps*z;e.beginPath();for(let O=0;O<=l;O++){let[_,M]=R(S[O%l],G);O===0?e.moveTo(_,M):e.lineTo(_,M)}e.stroke()}e.restore(),e.strokeStyle="#999",e.lineWidth=1;for(let b=0;b<l;b++){let[G,O]=R(S[b],z);e.beginPath(),e.moveTo(c,T),e.lineTo(G,O),e.stroke()}e.fillStyle="#888",e.font=I(i.tick*.8,n,"normal"),e.textAlign="left",e.textBaseline="middle";for(let b=1;b<=t.gridSteps;b++){let G=y/t.gridSteps*b,O=b/t.gridSteps*z;e.fillText(Pr(G),c+4,T-O-2)}e.fillStyle="#000",e.font=L(k);for(let b=0;b<l;b++){let[G,O]=R(S[b],z+20);pn(e,S[b]),Te(e,P[b],G,O,k*yo)}let E=t.series.map(b=>{let G=[];for(let O=0;O<l;O++){let M=(b.values[O]||0)/y*z;G.push(R(S[O],M))}return G});if(t.showFill)for(let b=0;b<t.series.length;b++){let G=_e[b%_e.length],O=E[b],_=parseInt(G.slice(1,2),16)*17,M=parseInt(G.slice(2,3),16)*17,F=parseInt(G.slice(3,4),16)*17;e.fillStyle=`rgba(${_},${M},${F},0.12)`,e.beginPath();for(let B=0;B<=l;B++){let[H,N]=O[B%l];B===0?e.moveTo(H,N):e.lineTo(H,N)}e.fill()}for(let b=0;b<t.series.length;b++){let G=Xt[b%Xt.length],O=_e[b%_e.length],_=E[b];e.strokeStyle=O,e.lineWidth=G.width,e.setLineDash(G.dash),e.beginPath();for(let M=0;M<=l;M++){let[F,B]=_[M%l];M===0?e.moveTo(F,B):e.lineTo(F,B)}e.stroke(),e.setLineDash([]);for(let M=0;M<l;M++){let[F,B]=_[M];e.fillStyle="#fff",e.beginPath(),e.arc(F,B,5,0,Math.PI*2),e.fill(),e.fillStyle=O,e.beginPath(),e.arc(F,B,3.5,0,Math.PI*2),e.fill()}}if(s){let b=f,G=u,O=d,_=C,M=t.series.map((F,B)=>{let H=Xt[B%Xt.length];return{type:"line",fillStyle:_e[B%_e.length],label:F.label,dash:H.dash,lineWidth:H.width}});x({ctx:e,fonts:n,items:M,position:m,plotX:b,plotY:G,plotW:O,plotH:_,canvasW:o,canvasH:r,fontSize:i.dataLabel*.85+5,bottomOffset:30})}let A=f,W=d;q({ctx:e,fonts:n,plotX:A,plotW:W,title:n.title,fontSize:i.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:A,plotW:W,height:r,source:n.source,footnotes:n.footnotes,fontSize:i.dataLabel,canvasWidth:o})}function Pr(e){return Number.isInteger(e)?e.toString():e.toFixed(1)}var yo=1.25,wr=.8;function pn(e,o){Math.abs(Math.cos(o))<.1?e.textAlign="center":Math.cos(o)>0?e.textAlign="left":e.textAlign="right",Math.abs(Math.sin(o))<.1?e.textBaseline="middle":Math.sin(o)>0?e.textBaseline="top":e.textBaseline="bottom"}function Wr(e,o,r,t,n,i,l,s,m,g){e.save();let p=m,u=o.map(d=>[d]),h=(d,C)=>{let c=t+Math.cos(r[C])*(d+20),T=n+Math.sin(r[C])*(d+20);pn(e,r[C]);let S=u[C].map(L=>se(e,L)),D=(u[C].length-1)*p*yo/2;return{x0:c-Math.max(...S.map(L=>L.left)),x1:c+Math.max(...S.map(L=>L.right)),y0:T-D-Math.max(...S.map(L=>L.up)),y1:T+D+Math.max(...S.map(L=>L.down))}},f=d=>o.every((C,c)=>{let T=h(d,c);return T.x0>=1&&T.x1<=i-1&&T.y0>=1&&T.y1<=l-1});e.font=g(p);let a=ue(10,s,f);return a<s*wr&&(u=o.map((d,C)=>{let c=t+Math.cos(r[C])*(s+20);pn(e,r[C]);let T=e.textAlign==="left"?i-1-c:e.textAlign==="right"?c-1:2*Math.min(c-1,i-1-c);return oe(e,d,Math.max(20,T))}),a=ue(10,s,f)),a<=10&&(p=m*.7,e.font=g(p),u=u.map(d=>d.flatMap(C=>oe(e,C,Math.max(20,i/3)))),a=ue(10,s,f)),e.restore(),{radius:a,labelLines:u,labelSize:p}}function st(e,o,r,t,n){U(e,o,r),t.mode==="deviation"?Er(e,o,r,t,n):zr(e,o,r,t,n)}function zr(e,o,r,t,n){let i=n.fontSize,l=t.bubbleLegendPosition==="outside-right"&&t.showBubble&&t.points.length>0,s=l?Do(e,t,i,n):null,m=l?cn(e,t,i,n):{boxW:0,boxH:0},g=Math.max(s?.boxW??0,m.boxW),p=(()=>{if(t.examFrame!==!0||!t.xUnit)return 0;e.save(),e.font=I(i.tick,n,"bold");let F=e.measureText(t.xUnit).width;return e.restore(),F})(),u=t.points.map(F=>F.x),h=t.points.map(F=>F.y),f=V(u),a=V(h),d=t.xRange.auto?f.min:t.xRange.min,C=t.xRange.auto?f.max:t.xRange.max,c=t.yRange.auto?a.min:t.yRange.min,T=t.yRange.auto?a.max:t.yRange.max,S=t.xRange.step??(t.xRange.auto?f.step:(C-d)/5),D=t.yRange.step??(t.yRange.auto?a.step:(T-c)/5),L=Fr(e,t,o,c,T,D,i,n),z={top:n.title?100:50,right:g>0?g+40:Math.max(60,p+34),bottom:(()=>{let F=90,B=n.footnotes.filter(H=>H.trim()).length;return n.source&&!(n.sourceInline&&B>0)&&(F+=30),F+=B*22,F})(),left:Math.max(130,L.reserve)},P=z.left,k=z.top,w=o-z.left-z.right,v=r-z.top-z.bottom,y=F=>P+(F-d)/(C-d)*w,R=F=>k+v-(F-c)/(T-c)*v,E=t.examFrame===!0;e.save(),e.strokeStyle=E?"#333":"#ddd",e.lineWidth=E?1:.5,e.setLineDash(E?[5,4]:[3,3]);for(let F=d+S;F<C;F+=S){let B=y(F);e.beginPath(),e.moveTo(B,k),e.lineTo(B,k+v),e.stroke()}for(let F=c+D;F<T;F+=D){let B=R(F);e.beginPath(),e.moveTo(P,B),e.lineTo(P+w,B),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,E?e.strokeRect(P,k,w,v):(e.beginPath(),e.moveTo(P,k),e.lineTo(P,k+v),e.lineTo(P+w,k+v),e.stroke()),e.fillStyle="#000",e.font=I(i.tick,n,"bold"),e.textAlign="center",e.textBaseline="top";let A=[];for(let F=d;F<=C+S*.01;F+=S)A.push(F);let W=ie(w/Math.max(1,A.length-1),ne(e,A.map(ke))),b=P+w;A.forEach((F,B)=>{let H=y(F);if(e.lineWidth=1,e.beginPath(),e.moveTo(H,k+v),e.lineTo(H,k+v+6),e.stroke(),B%W===0){let N=ke(F);e.fillText(N,H,k+v+10),b=Math.max(b,H+e.measureText(N).width/2)}}),e.textAlign="right",e.textBaseline="middle";let G=[];for(let F=c;F<=T+D*.01;F+=D)G.push(F);let O=ie(v/Math.max(1,G.length-1),i.tick*1.1),_=L.tickW;G.forEach((F,B)=>{let H=R(F);e.lineWidth=1,e.beginPath(),e.moveTo(P-6,H),e.lineTo(P,H),e.stroke(),B%O===0&&e.fillText(ke(F),P-10,H)}),e.font=I(i.axisLabel,n,"bold"),e.textAlign="center",e.textBaseline="top",re(e,t.xLabel,P+w/2,k+v+40,o,r,i.axisLabel,F=>I(F,n,"bold")),e.font=I(i.axisLabel,n,"bold"),t.xUnit&&(E?(e.font=I(i.tick,n,"bold"),e.textAlign="left",e.textBaseline="top",e.fillText(t.xUnit,b+6,k+v+10),e.font=I(i.axisLabel,n,"bold")):(e.textAlign="right",e.textBaseline="top",e.fillText(t.xUnit,P+w+10,k+v+40))),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",re(e,t.yUnit,P-10,k-16,o,r,i.axisLabel,F=>I(F,n,"bold"))),e.font=I(L.size,n,"bold"),e.textAlign="right",e.textBaseline="middle";let M=L.size*1.3;if(Te(e,L.lines,P-18-_,Mn(e,L.lines,k+v/2,M,r),M),e.font=I(i.axisLabel,n,"bold"),To(e,t,y,R,i,n,n.showDataLabels,{left:P,right:P+w,top:k,bottom:k+v},o,r),l){let F=P+w+20,B=k;s&&(ko(e,s,F,B,n),B+=s.boxH+8),m.boxH>0&&Mo(e,t,F,B,m,i,n)}else if(t.showBubble&&t.points.length>0){let F=vo(t,y,R),B=cn(e,t,i,n),H=Ao(e,t,P,k,w,v,i,n,F,B.boxH);Or(e,t,P,k,w,v,H.bottom,i,n,H.corner)}q({ctx:e,fonts:n,plotX:P,plotW:w,title:n.title,fontSize:i.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:P,plotW:w,height:r,source:n.source,sourceInline:n.sourceInline,footnotes:n.footnotes,fontSize:i.dataLabel,canvasWidth:o})}function Er(e,o,r,t,n){let i=n.fontSize,l={top:n.title?100:t.boxedAxisLabels?120:50,right:t.boxedAxisLabels?170:80,bottom:(()=>{let b=90,G=n.footnotes.filter(O=>O.trim()).length;return n.source&&!(n.sourceInline&&G>0)&&(b+=30),b+=G*22,b})(),left:130},s=l.left,m=l.top,g=o-l.left-l.right,p=r-l.top-l.bottom,u=t.points.map(b=>Math.abs(b.x)),h=t.points.map(b=>Math.abs(b.y)),f=u.length>0?Math.max(...u):10,a=h.length>0?Math.max(...h):10,d=So(f),C=So(a),c=t.xRange.auto?d.limit:Math.max(Math.abs(t.xRange.min),Math.abs(t.xRange.max)),T=t.yRange.auto?C.limit:Math.max(Math.abs(t.yRange.min),Math.abs(t.yRange.max)),S=t.xRange.step??(t.xRange.auto?d.step:c/4),D=t.yRange.step??(t.yRange.auto?C.step:T/4),L=b=>s+(b+c)/(2*c)*g,z=b=>m+p-(b+T)/(2*T)*p,P=L(0),k=z(0);e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]);for(let b=-c+S;b<c;b+=S){if(Math.abs(b)<S*.01)continue;let G=L(b);e.beginPath(),e.moveTo(G,m),e.lineTo(G,m+p),e.stroke()}for(let b=-T+D;b<T;b+=D){if(Math.abs(b)<D*.01)continue;let G=z(b);e.beginPath(),e.moveTo(s,G),e.lineTo(s+g,G),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,t.showFrame!==!1&&(e.beginPath(),e.moveTo(s,m),e.lineTo(s,m+p),e.lineTo(s+g,m+p),e.lineTo(s+g,m),e.closePath(),e.stroke()),e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.moveTo(P,m),e.lineTo(P,m+p),e.stroke(),e.beginPath(),e.moveTo(s,k),e.lineTo(s+g,k),e.stroke(),e.fillStyle="#000",e.font=I(i.tick,n,"bold"),e.textAlign="right",e.textBaseline="top",e.fillText("0",P-6,k+4);let w=t.ticksOnAxis?k:m+p,v=t.ticksOnAxis?P:s;e.textAlign="center",e.textBaseline="top";let y=[];for(let b=-c;b<=c+S*.01;b+=S)y.push(b);let R=ie(g/Math.max(1,y.length-1),ne(e,y.map(ke)));y.forEach((b,G)=>{if(Math.abs(b)<S*.01)return;let O=L(b);e.lineWidth=1,e.beginPath(),e.moveTo(O,w),e.lineTo(O,w+6),e.stroke(),G%R===0&&e.fillText(ke(b),O,w+10)}),e.textAlign="right",e.textBaseline="middle";let E=[];for(let b=-T;b<=T+D*.01;b+=D)E.push(b);let A=ie(p/Math.max(1,E.length-1),i.tick*1.1),W=ne(e,E.map(ke));if(E.forEach((b,G)=>{if(Math.abs(b)<D*.01)return;let O=z(b);e.lineWidth=1,e.beginPath(),e.moveTo(v-6,O),e.lineTo(v,O),e.stroke(),G%A===0&&e.fillText(ke(b),v-10,O)}),e.font=I(i.axisLabel,n,"bold"),t.boxedAxisLabels||(e.textAlign="center",e.textBaseline="top",e.fillText(t.xLabel,s+g/2,m+p+40)),t.xUnit&&(e.textAlign=t.ticksOnAxis?"left":"right",e.textBaseline="top",e.fillText(t.xUnit,s+g+(t.ticksOnAxis?20:10),t.ticksOnAxis?k+10:m+p+40)),t.yUnit&&(e.textAlign="right",e.textBaseline="bottom",e.fillText(t.yUnit,t.ticksOnAxis?P-10:s-10,t.ticksOnAxis?m-6:m-16)),t.boxedAxisLabels){Lo(e,t.yLabel,P,10,i.axisLabel,"below");let b=t.xUnit&&t.ticksOnAxis?e.measureText(t.xUnit).width+14:0;Lo(e,t.xLabel,s+g+16+b,m+p/2,i.axisLabel,"right")}else e.textAlign="right",e.textBaseline="middle",Dn(e,t.yLabel,v-18-W,m+p/2,i.axisLabel*1.3);To(e,t,L,z,i,n,n.showDataLabels,{left:s,right:s+g,top:m,bottom:m+p},o,r),t.showBubble&&t.points.length>0&&Ao(e,t,s,m,g,p,i,n,vo(t,L,z)),q({ctx:e,fonts:n,plotX:s,plotW:g,title:n.title,fontSize:i.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:s,plotW:g,height:r,source:n.source,sourceInline:n.sourceInline,footnotes:n.footnotes,fontSize:i.dataLabel,canvasWidth:o})}function To(e,o,r,t,n,i,l,s,m,g){let p=o.points.length>0?Math.max(...o.points.map(f=>f.size),1):1,u=new Ie;if(s)for(let f of o.points){let a=o.showBubble&&f.size>0?f.size/p*o.bubbleScale:4;u.reserveCircle(r(f.x),t(f.y),a)}let h=[...o.points].sort((f,a)=>a.size-f.size);for(let f of h){let a=r(f.x),d=t(f.y);if(o.showBubble&&f.size>0){let C=f.size/p*o.bubbleScale;e.fillStyle="#fff",e.beginPath(),e.arc(a,d,C,0,Math.PI*2),e.fill(),e.fillStyle=f.fill??"rgba(80,80,80,0.3)",e.beginPath(),e.arc(a,d,C,0,Math.PI*2),e.fill(),e.strokeStyle="#333",e.lineWidth=1.5,e.stroke()}else e.fillStyle="#000",e.beginPath(),e.arc(a,d,4,0,Math.PI*2),e.fill();if(f.label){e.fillStyle="#000",e.font=I(n.dataLabel,i,"bold");let C=o.showBubble&&f.size>0?f.size/p*o.bubbleScale+4:8;s?u.place(e,f.label,a,d,{gap:C,lineHeight:n.dataLabel*1.1,bounds:s}):(e.textAlign="left",e.textBaseline="bottom",e.fillText(f.label,a+C,d-2))}if(l){e.fillStyle="#555",e.font=I(n.dataLabel*.8,i,"normal"),e.textAlign="left",e.textBaseline="top";let C=o.showBubble&&f.size>0?f.size/p*o.bubbleScale+4:8,c=`(${f.x}, ${f.y})`,T=fe(e,c,a+C,d+2,m,g);e.fillText(c,T.x,T.y)}}}function So(e){if(e===0)return{limit:10,step:2};let o=e*.2,r=e+o,t=Math.pow(10,Math.floor(Math.log10(r))),n=r/t,i;n<=1.5?i=1.5:n<=2?i=2:n<=3?i=3:n<=5?i=5:i=10;let l=i*t,s=l/4;return{limit:l,step:s}}function ke(e){return Math.abs(e)<1e-4?"0":Number(e.toFixed(2)).toString()}function Fr(e,o,r,t,n,i,l,s){e.save(),e.font=I(l.tick,s,"bold");let m=[];for(let C=t;C<=n+i*.01;C+=i)m.push(C);let g=ne(e,m.map(ke)),p=C=>I(C,s,"bold");e.font=p(l.axisLabel);let u=(o.yLabel||"").split("\\n"),h=Math.max(40,r*.3-18-g-12),f=u.flatMap(C=>oe(e,C,h)),a=l.axisLabel;Qt(e,f)>h&&(a=Ae(e,f,l.axisLabel,h,p),e.font=p(a),f=u.flatMap(C=>oe(e,C,h)));let d=Qt(e,f);return e.restore(),{lines:f,size:a,tickW:g,reserve:18+g+d+12}}function vo(e,o,r){let t=e.points.length>0?Math.max(...e.points.map(n=>n.size),1):1;return e.points.map(n=>{let i=e.showBubble&&n.size>0?n.size/t*e.bubbleScale:4,l=o(n.x),s=r(n.y);return{x0:l-i,y0:s-i,x1:l+i,y1:s+i}})}var Gr=["top-right","top-left","bottom-right","bottom-left"];function Ir(e){return e==="outside-right"||!e?"top-right":e}function Br(e,o,r,t,n,i,l,s,m=0){let g=r+(m>0?m+6:0),p=a=>({x:a.endsWith("right")?t+i-o-10:t+10,y:a.startsWith("top")?n+10:n+l-g-10}),u=(a,d)=>s.reduce((C,c)=>{let T=Math.min(c.x1,a+o)-Math.max(c.x0,a),S=Math.min(c.y1,d+g)-Math.max(c.y0,d);return C+(T>0&&S>0?T*S:0)},0),h=[e,...Gr.filter(a=>a!==e)],f={corner:e,...p(e),score:1/0};for(let a of h){let{x:d,y:C}=p(a),c=u(d,C);if(c<f.score&&(f={corner:a,x:d,y:C,score:c}),c===0)break}return{corner:f.corner,x:f.x,y:f.y}}function cn(e,o,r,t){let n=o.fillLegend;if(!n||n.items.length===0)return{boxW:0,boxH:0};let i=r.dataLabel*.8;e.save(),e.font=I(i,t,"bold");let l=i*1.5,s=i*.95,m=8,g=n.title?l:0,p=Math.max(n.title?e.measureText(n.title).width:0,...n.items.map(u=>s+6+e.measureText(u.label).width));return e.restore(),{boxW:p+m*2,boxH:g+n.items.length*l+m*2}}function Do(e,o,r,t){let n=o.points.map(L=>L.size).filter(L=>L>0);if(n.length===0)return null;let i=Math.max(...n);if(i===0)return null;let l=o.bubbleLegendItems?.filter(L=>L.size>0&&L.size<=i)??[],s=l.length>0?l.map(L=>L.size):[i,Math.round(i*.5),Math.round(i*.2)].filter(L=>L>0),m=[...new Set(s)].sort((L,z)=>z-L),g=L=>l.find(z=>z.size===L)?.label??String(L),p=L=>L/i*o.bubbleScale,u=p(m[0]),h=r.dataLabel*.85;e.save(),e.font=I(h,t,"bold");let f=Math.max(50,...m.map(L=>e.measureText(g(L)).width));e.restore();let a=14,d=u*2+f+a*2+20,C=h*1.2,c=[],T=-1/0;for(let L of m){let z=p(L);T=Math.max(-2*z,T+C),c.push(T)}let S=Math.max(0,...c)+h/2,D=u*2+S+a*2+10;return{uniqueSteps:m,labelOf:g,radiusOf:p,maxR:u,boxW:d,boxH:D,labelOffsets:c,lowest:S,labelFontSize:h,pad:a}}function ko(e,o,r,t,n){e.fillStyle="#fff",e.strokeStyle="#666",e.lineWidth=1.5,e.beginPath(),e.roundRect(r,t,o.boxW,o.boxH,4),e.fill(),e.stroke();let i=r+o.pad+o.maxR,l=t+o.boxH-o.pad-o.lowest;o.uniqueSteps.forEach((s,m)=>{let g=o.radiusOf(s),p=l-g;e.strokeStyle="#333",e.lineWidth=1.5,e.beginPath(),e.arc(i,p,g,0,Math.PI*2),e.stroke(),e.save(),e.strokeStyle="#666",e.lineWidth=1,e.setLineDash([3,2]);let u=p-g;e.beginPath(),e.moveTo(i,u),e.lineTo(i+o.maxR+12,u),e.stroke(),e.restore(),e.fillStyle="#000",e.font=I(o.labelFontSize,n,"bold"),e.textAlign="left",e.textBaseline="middle",e.fillText(o.labelOf(s),i+o.maxR+16,l+o.labelOffsets[m])})}function Ao(e,o,r,t,n,i,l,s,m=[],g=0){let p=Ir(o.bubbleLegendPosition),u=Do(e,o,l,s);if(!u)return{height:0,corner:p,bottom:0};let h=Br(p,u.boxW,u.boxH,r,t,n,i,m,g);return ko(e,u,h.x,h.y,s),{height:u.boxH,corner:h.corner,bottom:h.y+u.boxH}}function Lo(e,o,r,t,n,i){if(!o)return;let l=o.split("\\n"),s=n*1.25,m=8,g=6;e.save();let u=Math.max(...l.map(d=>e.measureText(d).width))+m*2,h=l.length*s+g*2,f=i==="below"?r-u/2:r,a=i==="below"?t:t-h/2;e.fillStyle="#fff",e.fillRect(f,a,u,h),e.strokeStyle="#000",e.lineWidth=1.2,e.strokeRect(f,a,u,h),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";for(let d=0;d<l.length;d++)e.fillText(l[d],f+u/2,a+g+d*s);e.restore()}function Mo(e,o,r,t,n,i,l){let s=o.fillLegend;if(!s||s.items.length===0)return;let m=i.dataLabel*.8;e.save(),e.font=I(m,l,"bold");let g=m*1.5,p=m*.95,u=8;e.fillStyle="#fff",e.fillRect(r,t,n.boxW,n.boxH),e.strokeStyle="#666",e.lineWidth=1.5,e.setLineDash([]),e.strokeRect(r,t,n.boxW,n.boxH);let h=t+u;s.title&&(e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(s.title,r+n.boxW/2,h),h+=g);for(let f of s.items)e.fillStyle=f.fill,e.fillRect(r+u,h+(g-p)/2,p,p),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(r+u,h+(g-p)/2,p,p),e.fillStyle="#000",e.textAlign="left",e.textBaseline="middle",e.fillText(f.label,r+u+p+6,h+g/2),h+=g;e.restore()}function Or(e,o,r,t,n,i,l,s,m,g="bottom-right"){let p=o.fillLegend;if(!p||p.items.length===0)return;let u=cn(e,o,s,m),h=g.endsWith("right")?r+n-u.boxW-10:r+10,f=l>0?l+6:g.startsWith("top")?t+10:t+i-u.boxH-10;Mo(e,o,h,f,u,s,m)}function mt(e,o,r,t,n){U(e,o,r),t.displayMode==="bar"?Hr(e,o,r,t,n):_r(e,o,r,t,n)}function Hr(e,o,r,t,n){let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"?Z(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,n):0,m=t.barDirection==="vertical",g=i&&l==="bottom"?ee(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-(m?80:100)-(m?60+s:160+s),n):0,p={top:n.title?100:50,right:m?60+s:160+s,bottom:(()=>{let c=m?70:60;return i&&l==="bottom"&&(c+=60),c=Math.max(c,g),n.source&&(c+=30),c+=n.footnotes.filter(T=>T.trim()).length*22,c})(),left:m?80:100},u=p.left,h=p.top,f=o-p.left-p.right,a=r-p.top-p.bottom,d=t.categories.length,C=t.seriesLabels.length;if(e.strokeStyle="#000",e.lineWidth=2,m){e.beginPath(),e.moveTo(u,h),e.lineTo(u,h+a),e.lineTo(u+f,h+a),e.lineTo(u+f,h),e.lineTo(u,h),e.stroke();let c=t.axisStep??20;e.font=I(n.fontSize.tick,n,"bold"),e.fillStyle="#000",e.textAlign="right",e.textBaseline="middle";for(let D=0;D<=100;D+=c){let L=h+a-D/100*a;e.lineWidth=1,e.beginPath(),e.moveTo(u-5,L),e.lineTo(u,L),e.stroke(),e.fillText(String(D),u-10,L),D>0&&D<100&&(e.save(),e.strokeStyle=t.gridColor??"#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(u,L),e.lineTo(u+f,L),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,n,"bold"),e.textAlign="right",e.textBaseline="bottom",e.fillText(t.unit,u-10,h-16);let T=f/d,S=Math.min(T*.3,84);for(let D=0;D<d;D++){let L=u+T*D+T/2,z=t.categories[D].values.reduce((k,w)=>k+w,0),P=0;for(let k of Ro(t.categories[D],C)){let w=t.categories[D].values[k]||0,y=(z>0?w/z:0)*a,R=h+a-P-y;e.fillStyle=ft(e,t,k),e.fillRect(L-S/2,R,S,y),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(L-S/2,R,S,y),t.labelInSegment?Nr(e,t,n,k,L,R+y/2,S,y,Ne(t,k)):n.showDataLabels&&y>n.fontSize.dataLabel&&(e.fillStyle=Ne(t,k)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(w),L,R+y/2)),P+=y}e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText(t.categories[D].label,L,h+a+12)}}else{e.beginPath(),e.moveTo(u,h),e.lineTo(u,h+a),e.lineTo(u+f,h+a),e.lineTo(u+f,h),e.lineTo(u,h),e.stroke();let c=t.axisStep??20;e.font=I(n.fontSize.tick,n,"bold"),e.fillStyle="#000",e.textAlign="center",e.textBaseline="top";for(let D=0;D<=100;D+=c){let L=u+D/100*f;e.lineWidth=1,e.beginPath(),e.moveTo(L,h+a),e.lineTo(L,h+a+5),e.stroke(),e.fillText(String(D),L,h+a+10),D>0&&D<100&&(e.save(),e.strokeStyle="#ddd",e.lineWidth=.5,e.setLineDash([3,3]),e.beginPath(),e.moveTo(L,h),e.lineTo(L,h+a),e.stroke(),e.restore())}e.font=I(n.fontSize.axisLabel,n,"bold"),e.textAlign="left",e.textBaseline="top",e.fillText(t.unit,u+f+30,h+a+10);let T=a/d,S=Math.min(T*.3,84);for(let D=0;D<d;D++){let L=h+T*D+T/2,z=t.categories[D].values.reduce((k,w)=>k+w,0),P=0;for(let k of Ro(t.categories[D],C)){let w=t.categories[D].values[k]||0,y=(z>0?w/z:0)*f,R=u+P;e.fillStyle=ft(e,t,k),e.fillRect(R,L-S/2,y,S),e.strokeStyle="#000",e.lineWidth=.8,e.strokeRect(R,L-S/2,y,S),n.showDataLabels&&y>n.fontSize.dataLabel*2&&(e.fillStyle=Ne(t,k)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(w),R+y/2,L)),P+=y}e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="right",e.textBaseline="middle",e.fillText(t.categories[D].label,u-10,L)}}if(q({ctx:e,fonts:n,plotX:u,plotW:f,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i){let c=t.seriesLabels.map((T,S)=>({type:"rect",fillStyle:ft(e,t,S),bordered:Ne(t,S),label:T}));x({ctx:e,fonts:n,items:c,position:l,plotX:u,plotY:h,plotW:f,plotH:a,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}X({ctx:e,fonts:n,plotX:u,plotW:f,height:r,source:n.source,sourceLeft:n.sourceLeft,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function _r(e,o,r,t,n){let i=n.showLegend,l=n.legendPosition,s=i&&l==="right"?Z(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,n):0,m=i&&l==="bottom"?ee(e,t.seriesLabels,n.fontSize.dataLabel*.85+5,o-60-(60+s),n,"rect",16):0,g={top:n.title?100:50,right:60+s,bottom:(()=>{let R=50;return i&&l==="bottom"&&(R+=60),R=Math.max(R,m),n.source&&(R+=30),R+=n.footnotes.filter(E=>E.trim()).length*22,R})(),left:60},p=g.left,u=g.top,h=o-g.left-g.right,f=r-g.top-g.bottom,a=t.categories.length,d=t.seriesLabels.length,C=(t.pieScale??100)/100,c=(t.pieRotation??0)*Math.PI/180,T=24,S=n.fontSize.tick+16,D=h/a,z=Math.min(D*.4,(f-S)*.4)*C,P=a<=5?a:Math.ceil(Math.sqrt(a)),k=Math.ceil(a/P),w=h/P,v=f/k,y=Math.min(z,(w-T)/2,(v-S-T)/2);for(let R=0;R<a;R++){let E=R%P,A=Math.floor(R/P),W=p+w*E+w/2,b=u+v*A+(v-S)/2,G=t.categories[R].values.reduce((_,M)=>_+M,0),O=-Math.PI/2+c;for(let _=0;_<d;_++){let M=t.categories[R].values[_]||0,F=G>0?M/G:0,B=O+F*Math.PI*2;if(e.fillStyle=ft(e,t,_),e.beginPath(),e.moveTo(W,b),e.arc(W,b,y,O,B),e.closePath(),e.fill(),e.strokeStyle="#000",e.lineWidth=1,e.stroke(),n.showDataLabels&&F>.05){let H=(O+B)/2,N=W+Math.cos(H)*y*.65,K=b+Math.sin(H)*y*.65;e.fillStyle=Ne(t,_)?"#000":"#fff",e.font=I(n.fontSize.dataLabel*.8,n,"bold"),e.textAlign="center",e.textBaseline="middle",e.fillText(String(M),N,K)}O=B}e.strokeStyle="#000",e.lineWidth=1.5,e.beginPath(),e.arc(W,b,y,0,Math.PI*2),e.stroke(),e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.textAlign="center",e.textBaseline="top",e.fillText(t.categories[R].label,W,b+y+12)}if(q({ctx:e,fonts:n,plotX:p,plotW:h,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),i){let R=t.seriesLabels.map((E,A)=>({type:"rect",fillStyle:ft(e,t,A),bordered:Ne(t,A),label:E}));if(l==="right"){let E=Math.min(P-1,a-1),W=p+w*E+w/2+y-p,b=k-1,_=u+v*b+(v-S)/2+y+12+n.fontSize.tick-u;x({ctx:e,fonts:n,items:R,position:l,plotX:p,plotY:u,plotW:W,plotH:_,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5})}else{let E=k-1,b=u+v*E+(v-S)/2+y+12+n.fontSize.tick-u;x({ctx:e,fonts:n,items:R,position:l,plotX:p,plotY:u,plotW:h,plotH:b,canvasW:o,canvasH:r,fontSize:n.fontSize.dataLabel*.85+5,bottomOffset:16})}}X({ctx:e,fonts:n,plotX:p,plotW:h,height:r,source:n.source,sourceLeft:n.sourceLeft,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}function Ro(e,o){let r=e.segmentOrder;if(!r||r.length===0)return Array.from({length:o},(n,i)=>i);let t=Array.from({length:o},(n,i)=>i).filter(n=>!r.includes(n));return[...r.filter(n=>n>=0&&n<o),...t]}function ft(e,o,r){let t=o.seriesFills?.[r];return t==null?pt(e,r):ct(e,t)}function Ne(e,o){let r=e.seriesFills?.[o];return r==null?ve(o):yt(r)}function Nr(e,o,r,t,n,i,l,s,m){let g=o.seriesLabels[t]??"",p=r.fontSize.dataLabel*.9;if(!g||s<p*1.1)return;let u=o.seriesIsSymbol&&!o.seriesIsSymbol[t]?"sans":r.fontFamily;e.font=I(p,r,"bold",u),e.textAlign="center",e.textBaseline="middle";let h=Math.max(1,l-6);m?(e.save(),e.lineWidth=3,e.strokeStyle="#fff",e.lineJoin="round",e.strokeText(g,n,i,h),e.restore(),e.fillStyle="#000"):e.fillStyle="#fff",e.fillText(g,n,i,h)}function pe(e,o,r,t,n,i){let l=e+o+r;if(l===0)return{x:t,y:n};let s=e/l,m=o/l,g=r/l,p=i*Math.sqrt(3)/2,u=t,h=n-p*2/3,f=t-i/2,a=n+p/3,d=t+i/2,C=n+p/3,c=g*u+s*f+m*d,T=g*h+s*a+m*C;return{x:c,y:T}}function bt(e,o,r,t,n){U(e,o,r);let i=12+n.fontSize.tick+10,l=n.fontSize.axisLabel*1.3+30,s=i+l;n.source&&(s+=n.fontSize.dataLabel+10),s+=n.footnotes.filter(A=>A.trim()).length*22;let m={top:n.title?80:50,right:120,bottom:s,left:120},g=m.left,p=o-m.left-m.right,u=r-m.top-m.bottom,h=p*.9,f=u*2/Math.sqrt(3),a=Yr(e,t.axisLabels,n,o,r,g+p/2,m.top,Math.min(h,f)),d=a.size,C=d*Math.sqrt(3)/2,c=g+p/2,T=m.top+11+C*2/3,S={x:c,y:T-C*2/3},D={x:c-d/2,y:T+C/3},L={x:c+d/2,y:T+C/3},z=t.gridInterval,P=100/z;e.save(),e.strokeStyle="#ccc",e.lineWidth=.5;for(let A=1;A<P;A++){let W=A*z,b=pe(100-W,0,W,c,T,d),G=pe(0,100-W,W,c,T,d);e.beginPath(),e.moveTo(b.x,b.y),e.lineTo(G.x,G.y),e.stroke();let O=pe(W,100-W,0,c,T,d),_=pe(W,0,100-W,c,T,d);e.beginPath(),e.moveTo(O.x,O.y),e.lineTo(_.x,_.y),e.stroke();let M=pe(0,W,100-W,c,T,d),F=pe(100-W,W,0,c,T,d);e.beginPath(),e.moveTo(M.x,M.y),e.lineTo(F.x,F.y),e.stroke()}e.restore(),e.strokeStyle="#000",e.lineWidth=2,e.beginPath(),e.moveTo(S.x,S.y),e.lineTo(D.x,D.y),e.lineTo(L.x,L.y),e.closePath(),e.stroke();let k=12,w={x:-1,y:0},v={x:Math.cos(Math.PI/3),y:Math.sin(Math.PI/3)},y={x:Math.cos(Math.PI/3),y:-Math.sin(Math.PI/3)};e.fillStyle="#000",e.font=I(n.fontSize.tick,n,"bold"),e.strokeStyle="#000",e.lineWidth=1.5;for(let A=0;A<=P;A++){let W=A*z,b=pe(100-W,0,W,c,T,d);e.beginPath(),e.moveTo(b.x,b.y),e.lineTo(b.x+w.x*k,b.y+w.y*k),e.stroke(),e.textAlign="right",e.textBaseline="middle",e.fillText(String(W),b.x+w.x*k-4,b.y+w.y*k);let G=pe(W,100-W,0,c,T,d);e.beginPath(),e.moveTo(G.x,G.y),e.lineTo(G.x+v.x*k,G.y+v.y*k),e.stroke(),e.textAlign="center",e.textBaseline="top",e.fillText(String(W),G.x+v.x*k,G.y+v.y*k+4);let O=pe(0,W,100-W,c,T,d);e.beginPath(),e.moveTo(O.x,O.y),e.lineTo(O.x+y.x*k,O.y+y.y*k),e.stroke(),e.textAlign="left",e.textBaseline="middle";let _=W===100?"100 (%)":String(W),M=fe(e,_,O.x+y.x*k+4,O.y+y.y*k,o,r);e.fillText(_,M.x,M.y)}e.font=I(a.fontSize,n,"bold"),e.fillStyle="#000";let R=a.fontSize*1.3,E=yn(o,g+p/2,m.top,d,a.lines,R);for(let A=0;A<3;A++)e.textAlign=E[A].align,e.textBaseline=E[A].baseline,Te(e,a.lines[A],E[A].x,E[A].y,R);for(let A=0;A<t.points.length;A++){let W=t.points[A],{x:b,y:G}=pe(W.b,W.c,W.a,c,T,d);e.fillStyle="#000",e.beginPath(),e.arc(b,G,6,0,Math.PI*2),e.fill(),W.label&&(e.fillStyle="#000",e.font=I(n.fontSize.dataLabel,n,"bold"),e.textAlign="left",e.textBaseline="bottom",e.fillText(W.label,b+10,G-4)),n.showDataLabels&&(e.fillStyle="#555",e.font=I(n.fontSize.dataLabel*.8,n),e.textAlign="left",e.textBaseline="top",e.fillText(`(${W.a}, ${W.b}, ${W.c})`,b+10,G+4))}q({ctx:e,fonts:n,plotX:g,plotW:p,title:n.title,fontSize:n.fontSize.title,canvasWidth:o}),X({ctx:e,fonts:n,plotX:D.x,plotW:L.x-D.x,height:r,source:n.source,footnotes:n.footnotes,fontSize:n.fontSize.dataLabel,canvasWidth:o})}var Ur=.8;function yn(e,o,r,t,n,i){let l=t*Math.sqrt(3)/2,s=r+11+l*2/3,m=s-l*2/3,g=s+l/3,p=o-t/4,u=(m+g)/2,h=o+t/4,f=g+52;return[{x:p-52,y:u,align:"right",baseline:"middle"},{x:o,y:f+(n[1].length-1)*i/2,align:"center",baseline:"top"},{x:h+52,y:u,align:"left",baseline:"middle"}]}function Yr(e,o,r,t,n,i,l,s){e.save();let m=a=>I(a,r,"bold"),g=r.fontSize.axisLabel*1.3,p=o.map(a=>(a||"").split("\\n")),u=p.map(a=>a.slice()),h=a=>{e.font=m(g);let d=g*1.3;return yn(t,i,l,a,u,d).every((c,T)=>{e.textAlign=c.align,e.textBaseline=c.baseline;let S=u[T].map(L=>se(e,L)),D=(u[T].length-1)*d/2;return c.x-Math.max(...S.map(L=>L.left))>=1&&c.x+Math.max(...S.map(L=>L.right))<=t-1&&c.y-D-Math.max(...S.map(L=>L.up))>=1&&c.y+D+Math.max(...S.map(L=>L.down))<=n-1})},f=ue(40,s,h);if(f<s*Ur){e.font=m(g);let a=g*1.3,d=yn(t,i,l,s,u,a);u=p.map((C,c)=>{let T=d[c],S=T.align==="left"?t-1-T.x:T.align==="right"?T.x-1:2*Math.min(T.x-1,t-1-T.x);return C.flatMap(D=>oe(e,D,Math.max(30,S)))}),f=ue(40,s,h)}return f<=40&&(g=r.fontSize.axisLabel*1.3*.7,e.font=m(g),u=u.map(a=>a.flatMap(d=>oe(e,d,Math.max(30,t/3)))),f=ue(40,s,h)),e.restore(),{size:f,lines:u,fontSize:g}}var ze={absbar:{render:$e,createDefaultData:Mt},"category-dot":{render:Ke,createDefaultData:Gt},climate:{render:et,createDefaultData:vt},cube:{render:tt,createDefaultData:Wt},"data-table":{render:Je,createDefaultData:Ot},"deviation-a":{render:nt,createDefaultData:Lt},"deviation-b":{render:ot,createDefaultData:Tt},"econ-plane":{render:Qe,createDefaultData:zt},hythergraph:{render:rt,createDefaultData:wt},line:{render:je,createDefaultData:It},"matrix-table":{render:Ve,createDefaultData:Bt},pyramid:{render:lt,createDefaultData:Dt},radar:{render:at,createDefaultData:Et},scatter:{render:st,createDefaultData:Rt},stacked:{render:mt,createDefaultData:At},ternary:{render:bt,createDefaultData:kt},treemap:{render:xe,createDefaultData:Ht}},ut=Object.freeze(Object.keys(ze).sort());function $t(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(ze,e)}var J=class extends Error{constructor(o){super(`csat-chart: ${o}`),this.name="CsatChartError"}},Xr={climate:{months:12},"deviation-a":{baseMonths:12,months:12},ternary:{axisLabels:3},scatter:{quadrantLabels:4}},$r={object:"\uAC1D\uCCB4",number:"\uC22B\uC790",string:"\uBB38\uC790\uC5F4",boolean:"\uBD88\uB9AC\uC5B8",undefined:"undefined",function:"\uD568\uC218"};function Ee(e){return Array.isArray(e)?"\uBC30\uC5F4":e===null?"null":$r[typeof e]??typeof e}function ht(e){let o=e.charCodeAt(e.length-1),t=o>=44032&&o<=55203?(o-44032)%28!==0:!0;return`${e}${t?"\uC774\uC5B4\uC57C":"\uC5EC\uC57C"} \uD569\uB2C8\uB2E4`}function qr(e,o){let r=Array.from({length:o.length+1},(t,n)=>n);for(let t=1;t<=e.length;t++){let n=[t];for(let i=1;i<=o.length;i++)n[i]=Math.min(r[i]+1,n[i-1]+1,r[i-1]+(e[t-1]===o[i-1]?0:1));r=n}return r[o.length]}function Kr(e){let o=null,r=1/0;for(let t of ut){let n=qr(e.toLowerCase(),t);n<r&&(r=n,o=t)}return r<=3?o:null}function Co(e){if($t(e))return;let o=typeof e=="string"?Kr(e):null;throw new J(`\uC54C \uC218 \uC5C6\uB294 type ${JSON.stringify(e)}`+(o?` \u2014 \uD639\uC2DC "${o}"?`:` \u2014 \uC4F8 \uC218 \uC788\uB294 \uAC12: ${ut.join(", ")}`))}function Po(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new J(`config \uB294 ${ht("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Ee(e)})`);let o=e.options;if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))throw new J(`config.options \uB294 ${ht("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Ee(o)})`)}function Sn(e,o){if(typeof o!="object"||o===null||Array.isArray(o))throw new J(`type "${e}" \uC758 data \uB294 ${ht("\uAC1D\uCCB4")} (\uC9C0\uAE08 ${Ee(o)})`);let r=o,t=ze[e].createDefaultData(),n=Xr[e]??{};for(let i of Object.keys(t)){if(!(i in r))throw new J(`type "${e}" \uC758 data \uC5D0 ${i} \uD56D\uBAA9\uC774 \uC5C6\uC2B5\uB2C8\uB2E4`);let l=Ee(t[i]),s=Ee(r[i]);if(l!==s)throw new J(`type "${e}" \uC758 data.${i}: ${ht(l)} (\uC9C0\uAE08 ${s})`);let m=n[i];if(m!==void 0){let p=r[i].length;if(p!==m)throw new J(`type "${e}" \uC758 data.${i}: ${m}\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${p}\uAC1C)`)}let g=t[i];if(l==="\uBC30\uC5F4"&&Array.isArray(g)&&g.length>0){let p=Ee(g[0]),u=r[i];for(let h=0;h<u.length;h++){let f=Ee(u[h]);if(f!==p)throw new J(`type "${e}" \uC758 data.${i}[${h}]: ${ht(p)} (\uC9C0\uAE08 ${f})`)}}}}var jr="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&family=Noto+Serif+KR:wght@400;700&display=swap",Vr=["Noto Serif KR","Noto Sans KR"],wo="csat-chart-fonts",Wo=null;function qt(e={}){return typeof document>"u"?Promise.resolve(!1):(Wo??(Wo=Jr(e)),Wo)}async function Jr(e){let o=e.href??jr,r=e.families??Vr,t=e.timeoutMs??5e3;try{if(!document.getElementById(wo)){let m=document.createElement("link");m.id=wo,m.rel="stylesheet",m.href=o,document.head.appendChild(m)}}catch{return!1}let n=document.fonts;if(!n)return!1;let i=(async()=>{for(let m of r)await n.load(`400 16px "${m}"`),await n.load(`700 16px "${m}"`);return!0})(),l,s=new Promise(m=>{l=setTimeout(()=>m(!1),t)});try{return await Promise.race([i.catch(()=>!1),s])}finally{clearTimeout(l)}}function Zr(e){if(e===void 0)return{tl:0,tr:0,br:0,bl:0};if(typeof e=="number"){if(!(e>=0))throw new RangeError("roundRect: \uBC18\uC9C0\uB984\uC740 0 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");return{tl:e,tr:e,br:e,bl:e}}if(e.some(o=>!(o>=0)))throw new RangeError("roundRect: \uBC18\uC9C0\uB984\uC740 0 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4");switch(e.length){case 1:return{tl:e[0],tr:e[0],br:e[0],bl:e[0]};case 2:return{tl:e[0],br:e[0],tr:e[1],bl:e[1]};case 3:return{tl:e[0],tr:e[1],bl:e[1],br:e[2]};case 4:return{tl:e[0],tr:e[1],br:e[2],bl:e[3]};default:throw new RangeError(`roundRect: \uBC18\uC9C0\uB984 \uBC30\uC5F4\uC740 1~4\uAC1C\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${e.length}\uAC1C)`)}}function Qr(e,o,r){let t=Math.min(1,o/(e.tl+e.tr)||1/0,r/(e.tr+e.br)||1/0,o/(e.bl+e.br)||1/0,r/(e.tl+e.bl)||1/0);return t>=1?e:{tl:e.tl*t,tr:e.tr*t,br:e.br*t,bl:e.bl*t}}function xr(e,o,r,t,n,i){let l=Qr(Zr(i),Math.abs(t),Math.abs(n));e.moveTo(o+l.tl,r),e.lineTo(o+t-l.tr,r),l.tr>0&&e.arcTo(o+t,r,o+t,r+l.tr,l.tr),e.lineTo(o+t,r+n-l.br),l.br>0&&e.arcTo(o+t,r+n,o+t-l.br,r+n,l.br),e.lineTo(o+l.bl,r+n),l.bl>0&&e.arcTo(o,r+n,o,r+n-l.bl,l.bl),e.lineTo(o,r+l.tl),l.tl>0&&e.arcTo(o,r,o+l.tl,r,l.tl),e.closePath()}function Kt(){if(typeof CanvasRenderingContext2D>"u")return!1;let e=CanvasRenderingContext2D.prototype;return typeof e.roundRect=="function"?!1:(e.roundRect=function(o,r,t,n,i){xr(this,o,r,t,n,i)},!0)}var ei=800,ti=600,ni=300,oi=150;function zo(e,o,r){let t=e[o];if(!t)return!0;if(t!==r)return!1;let n=e;return typeof n.getAttribute=="function"&&n.getAttribute(o)===null}function Eo(e,o){return{...e,...o,fontSize:{...e.fontSize,...o?.fontSize},fontStack:{...e.fontStack,...o?.fontStack},footnotes:[...o?.footnotes??e.footnotes]}}var jt=class{constructor(o,r){this.destroyed=!1;this.canvas=ri(o);let t=this.canvas.getContext("2d");if(!t)throw new J("\uCE94\uBC84\uC2A4\uC5D0\uC11C 2d \uCEE8\uD14D\uC2A4\uD2B8\uB97C \uC5BB\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4");this.ctx=t,Po(r),Co(r.type),Sn(r.type,r.data),this.type=r.type,this.data=r.data,this.options=Eo(St(),r.options),zo(this.canvas,"width",ni)&&(this.canvas.width=ei),zo(this.canvas,"height",oi)&&(this.canvas.height=ti),Kt(),this.draw(),this.redrawWhenFontsArrive()}static ensureFonts(o){return qt(o)}update(o){return this.assertAlive(),o.data!==void 0&&(Sn(this.type,o.data),this.data=o.data),o.options!==void 0&&(this.options=Eo(this.options,o.options)),this.draw(),this}resize(o,r){if(this.assertAlive(),!(o>0)||!(r>0))throw new J(`\uD06C\uAE30\uB294 0\uBCF4\uB2E4 \uCEE4\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${o}\xD7${r})`);return this.canvas.width=o,this.canvas.height=r,this.draw(),this}toDataURL(o={}){if(this.assertAlive(),typeof this.canvas.toDataURL!="function")throw new J("\uC774 \uCE94\uBC84\uC2A4\uB294 toDataURL \uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");let r=o.scale??1;if(!(Number.isFinite(r)&&r>0))throw new J(`scale \uC740 0\uBCF4\uB2E4 \uD070 \uC720\uD55C\uD55C \uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${r})`);if(r===1)return this.canvas.toDataURL("image/png");let t=this.canvas.width,n=this.canvas.height;try{return this.canvas.width=Math.round(t*r),this.canvas.height=Math.round(n*r),this.drawScaled(r,t,n),this.canvas.toDataURL("image/png")}finally{this.canvas.width=t,this.canvas.height=n,this.draw()}}download(o="csat-chart.png",r={}){if(this.assertAlive(),typeof document>"u")throw new J("download() \uB294 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C\uB9CC \uC501\uB2C8\uB2E4. Node \uC5D0\uC11C\uB294 toDataURL() \uC774\uB098 \uCE94\uBC84\uC2A4\uC758 \uBC84\uD37C\uB97C \uC4F0\uC138\uC694");let t=document.createElement("a");t.href=this.toDataURL(r),t.download=o,t.click()}destroy(){this.destroyed||(U(this.ctx,this.canvas.width,this.canvas.height),this.destroyed=!0)}redrawWhenFontsArrive(){if(typeof document>"u")return;let o=document.fonts;o?.ready&&Promise.resolve(o.ready).then(()=>{this.destroyed||this.draw()}).catch(()=>{})}draw(){let{width:o,height:r}=this.canvas;U(this.ctx,o,r),ze[this.type].render(this.ctx,o,r,this.data,this.options)}drawScaled(o,r,t){this.ctx.setTransform(o,0,0,o,0,0);try{U(this.ctx,r,t),ze[this.type].render(this.ctx,r,t,this.data,this.options)}finally{this.ctx.setTransform(1,0,0,1,0,0)}}assertAlive(){if(this.destroyed)throw new J("\uC774\uBBF8 destroy() \uB41C \uCC28\uD2B8\uC785\uB2C8\uB2E4")}};function ri(e){if(typeof e=="string"){if(typeof document>"u")throw new J(`id \uBB38\uC790\uC5F4\uC740 \uBE0C\uB77C\uC6B0\uC800\uC5D0\uC11C\uB9CC \uC501\uB2C8\uB2E4 ("${e}")`);let o=document.getElementById(e);if(!o)throw new J(`id "${e}" \uC778 \uC694\uC18C\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);if(o.tagName.toUpperCase()!=="CANVAS")throw new J(`id "${e}" \uC778 \uC694\uC18C\uB294 <canvas> \uAC00 \uC544\uB2D9\uB2C8\uB2E4`);return o}if(e===null||typeof e!="object")throw new J(`\uCCAB \uC778\uC790\uB294 <canvas> \uC694\uC18C\uC774\uAC70\uB098 id \uBB38\uC790\uC5F4\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4 (\uC9C0\uAE08 ${e===null?"null":typeof e})`+(e===null?" \u2014 getElementById \uAC00 \uADF8 id \uB97C \uCC3E\uC9C0 \uBABB\uD55C \uAC83\uC740 \uC544\uB2CC\uC9C0 \uBCF4\uC138\uC694":""));if(typeof e.getContext!="function")throw new J("\uCCAB \uC778\uC790\uC5D0 getContext \uAC00 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 <canvas> \uC694\uC18C\uAC00 \uB9DE\uB294\uC9C0 \uBCF4\uC138\uC694");return e}var ii=Object.freeze(Re),li=Object.freeze(Ft),ai=Object.freeze(qe),si=Object.freeze(Ce),fi=Object.freeze(Pt),mi=Object.freeze(Ct),bi=Object.freeze({solid:Object.freeze(De.solid),dashed:Object.freeze(De.dashed),dotted:Object.freeze(De.dotted),dashdot:Object.freeze(De.dashdot)});return Ho(ui);})();
|
|
3
3
|
globalThis.CsatChart=Object.assign(__csat.CsatChart,__csat);})();
|
|
4
4
|
//# sourceMappingURL=csat-chart.umd.min.js.map
|