csat-chart.js 1.2.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 +381 -0
- package/LICENSE +21 -0
- package/README.md +369 -0
- package/dist/csat-chart.cjs +6171 -0
- package/dist/csat-chart.cjs.map +1 -0
- package/dist/csat-chart.d.cts +914 -0
- package/dist/csat-chart.d.mts +914 -0
- package/dist/csat-chart.mjs +6097 -0
- package/dist/csat-chart.mjs.map +1 -0
- package/dist/csat-chart.umd.min.js +4 -0
- package/dist/csat-chart.umd.min.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,4 @@
|
|
|
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);})();
|
|
3
|
+
globalThis.CsatChart=Object.assign(__csat.CsatChart,__csat);})();
|
|
4
|
+
//# sourceMappingURL=csat-chart.umd.min.js.map
|