@awc-ui/core 1.0.0-beta → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/p-6wZSqm_2.js +2 -0
- package/dist/components/{p-Bx5sxRqa.js.map → p-6wZSqm_2.js.map} +1 -1
- package/dist/components/p-7fN_yCXW.js +2 -0
- package/dist/components/{p-CJdqKSuf.js.map → p-7fN_yCXW.js.map} +1 -1
- package/dist/components/{p-G5m2pHZ2.js → p-B0Opn6dK.js} +2 -2
- package/dist/components/{p-pDrTJmeT.js → p-B3MWYEEJ.js} +2 -2
- package/dist/components/{p-DGGkdSZk.js → p-BwXpiUsu.js} +2 -2
- package/dist/{md3/p-B0NLeNWu.js → components/p-Bx6--dQF.js} +2 -2
- package/dist/components/{p-BIIp3Qod.js → p-C8EP4S21.js} +2 -2
- package/dist/components/{p-CWM3KSti.js → p-C_ogF68H.js} +2 -2
- package/dist/components/{p-BlwGYUkt.js → p-Ch2-tttM.js} +2 -2
- package/dist/components/p-DXXUoRSH.js +2 -0
- package/dist/components/{p-DWUCvzfU.js.map → p-DXXUoRSH.js.map} +1 -1
- package/dist/components/p-Dp-w93ot.js +2 -0
- package/dist/components/{p-BUYYCrGa.js.map → p-Dp-w93ot.js.map} +1 -1
- package/dist/{md3/p-CGStn3Iq.js → components/p-DvOKnoqK.js} +2 -2
- package/dist/components/{p-B7yMxWo-.js → p-DzPKu-Ma.js} +2 -2
- package/dist/components/{p-CXpXrhQH.js → p-RLxbNqRv.js} +2 -2
- package/dist/components/p-UdGDg2oJ.js +2 -0
- package/dist/components/{p-BujtL9xW.js.map → p-UdGDg2oJ.js.map} +1 -1
- package/dist/components/p-e2HRV63Y.js +2 -0
- package/dist/components/{p-CrlkPxeB.js.map → p-e2HRV63Y.js.map} +1 -1
- package/dist/components/p-stybaFzj.js +2 -0
- package/dist/components/{p-JbwZ84YK.js.map → p-stybaFzj.js.map} +1 -1
- package/dist/components/p-uTEkf0sE.js +2 -0
- package/dist/components/{p-BXwh1zjF.js.map → p-uTEkf0sE.js.map} +1 -1
- package/dist/esm/{a11y-C9_cZAF_.js → a11y-C6CRqodW.js} +3 -3
- package/dist/esm/{a11y-C9_cZAF_.js.map → a11y-C6CRqodW.js.map} +1 -1
- package/dist/esm/{bar-chart-IvBgAmmF.js → bar-chart-ZZrajEkM.js} +4 -4
- package/dist/esm/{bar-chart-IvBgAmmF.js.map → bar-chart-ZZrajEkM.js.map} +1 -1
- package/dist/esm/{chart-D1kP9gfW.js → chart-32olae06.js} +4 -4
- package/dist/esm/{chart-D1kP9gfW.js.map → chart-32olae06.js.map} +1 -1
- package/dist/esm/{hit-test-DFfwlMb9.js → hit-test-DHldf5Lm.js} +3 -3
- package/dist/esm/{hit-test-DFfwlMb9.js.map → hit-test-DHldf5Lm.js.map} +1 -1
- package/dist/esm/{rtl-CGStn3Iq.js → rtl-DvOKnoqK.js} +3 -3
- package/dist/esm/{rtl-CGStn3Iq.js.map → rtl-DvOKnoqK.js.map} +1 -1
- package/dist/md3/p-04e97f5d.entry.js +2 -0
- package/dist/md3/{p-ec14eaca.entry.js.map → p-04e97f5d.entry.js.map} +1 -1
- package/dist/md3/p-3cce1de3.entry.js +2 -0
- package/dist/md3/{p-2121c939.entry.js.map → p-3cce1de3.entry.js.map} +1 -1
- package/dist/md3/p-4d82132d.entry.js +2 -0
- package/dist/md3/{p-fe78659d.entry.js.map → p-4d82132d.entry.js.map} +1 -1
- package/dist/{components/p-Bu-m4Gm2.js → md3/p-Bx6--dQF.js} +2 -2
- package/dist/md3/{p-B0NLeNWu.js.map → p-Bx6--dQF.js.map} +1 -1
- package/dist/md3/{p-CWM3KSti.js → p-C_ogF68H.js} +2 -2
- package/dist/md3/{p-CWM3KSti.js.map → p-C_ogF68H.js.map} +1 -1
- package/dist/{components/p-CGStn3Iq.js → md3/p-DvOKnoqK.js} +2 -2
- package/dist/md3/{p-CGStn3Iq.js.map → p-DvOKnoqK.js.map} +1 -1
- package/dist/md3/{p-B7yMxWo-.js → p-DzPKu-Ma.js} +2 -2
- package/dist/md3/{p-B7yMxWo-.js.map → p-DzPKu-Ma.js.map} +1 -1
- package/dist/md3/{p-CXpXrhQH.js → p-RLxbNqRv.js} +2 -2
- package/dist/md3/{p-CXpXrhQH.js.map → p-RLxbNqRv.js.map} +1 -1
- package/dist/md3/{p-f6373c6c.entry.js → p-aaec2698.entry.js} +2 -2
- package/dist/md3/{p-9ff2d5d1.entry.js → p-c063c823.entry.js} +2 -2
- package/main-llm.md +2 -2
- package/package.json +24 -3
- package/dist/components/p-BUYYCrGa.js +0 -2
- package/dist/components/p-BXwh1zjF.js +0 -2
- package/dist/components/p-BujtL9xW.js +0 -2
- package/dist/components/p-Bx5sxRqa.js +0 -2
- package/dist/components/p-CJdqKSuf.js +0 -2
- package/dist/components/p-CrlkPxeB.js +0 -2
- package/dist/components/p-DWUCvzfU.js +0 -2
- package/dist/components/p-JbwZ84YK.js +0 -2
- package/dist/md3/p-2121c939.entry.js +0 -2
- package/dist/md3/p-ec14eaca.entry.js +0 -2
- package/dist/md3/p-fe78659d.entry.js +0 -2
- /package/dist/components/{p-G5m2pHZ2.js.map → p-B0Opn6dK.js.map} +0 -0
- /package/dist/components/{p-pDrTJmeT.js.map → p-B3MWYEEJ.js.map} +0 -0
- /package/dist/components/{p-DGGkdSZk.js.map → p-BwXpiUsu.js.map} +0 -0
- /package/dist/components/{p-Bu-m4Gm2.js.map → p-Bx6--dQF.js.map} +0 -0
- /package/dist/components/{p-BIIp3Qod.js.map → p-C8EP4S21.js.map} +0 -0
- /package/dist/components/{p-CWM3KSti.js.map → p-C_ogF68H.js.map} +0 -0
- /package/dist/components/{p-BlwGYUkt.js.map → p-Ch2-tttM.js.map} +0 -0
- /package/dist/components/{p-CGStn3Iq.js.map → p-DvOKnoqK.js.map} +0 -0
- /package/dist/components/{p-B7yMxWo-.js.map → p-DzPKu-Ma.js.map} +0 -0
- /package/dist/components/{p-CXpXrhQH.js.map → p-RLxbNqRv.js.map} +0 -0
- /package/dist/md3/{p-f6373c6c.entry.js.map → p-aaec2698.entry.js.map} +0 -0
- /package/dist/md3/{p-9ff2d5d1.entry.js.map → p-c063c823.entry.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v as t,x as s,y as i,z as n,A as e,B as o,C as h,D as c,E as a,F as r,G as l,H as f,I as u,J as d,K as x,w as m,c as y,i as M,e as p,f as b,s as g,h as v,g as w,L as k,l as I,M as A,n as z,m as F,N as S}from"./p-CGStn3Iq.js";import{n as $}from"./p-B7yMxWo-.js";function L(t,s){return t.length*s*.58}function T(t,s){const i=t[1];const n=s[1];if(!(i>0)||!(n>0))return[t,s];const e=t[0]<0?-t[0]/i:0;const o=s[0]<0?-s[0]/n:0;const h=Math.max(e,o);if(h<=0)return[t,s];return[[-h*i,i],[-h*n,n]]}function B(t,s,i){if(s<=0||L(t,i)<=s)return t;const n=i*.58;const e=Math.floor(s/n)-1;return e>=1?`${t.slice(0,e)}…`:""}function q(t,s){const i=t.categories.length||Math.max(0,...t.series.map((t=>(t.range??t.data??[]).length)));const n=t.stack!=="none";const e=t.series.map((t=>n&&!t.range?t.stack||"stacked":"__unstacked__"));const o=h(t.series.map((t=>t.hidden||t.range?[]:t.data??[])),t.stack,e);t.series.forEach(((t,s)=>{if(!t.range||t.hidden)return;o[s]=t.range.map((t=>t?[Math.min(t[0],t[1]),Math.max(t[0],t[1])]:t))}));const d=[];t.series.forEach(((t,s)=>{if(t.hidden)return;o[s].forEach((t=>{if(t)d.push(t[0],t[1])}))}));const x=s=>(t.series[s].axisIndex??0)===1;const m=!!t.valueAxis2&&t.series.some(((t,s)=>!t.hidden&&x(s)));const y=[];if(m){d.length=0;t.series.forEach(((t,s)=>{if(t.hidden)return;o[s].forEach((t=>{if(t)(x(s)?y:d).push(t[0],t[1])}))}))}let M=c(d,{min:t.valueMin,max:t.valueMax,scale:t.valueScale,includeZero:true});let p=m?c(y,{min:t.valueAxis2.min,max:t.valueAxis2.max,scale:t.valueScale,includeZero:true}):M;if(m&&t.valueScale==="value"&&t.valueMin==null&&t.valueMax==null&&t.valueAxis2.min==null&&t.valueAxis2.max==null){[M,p]=T(M,p)}const b=a(t.valueBreaks,d,t.valueScale);const g={...b,ranges:r(l(b.ranges,M),M,t.valueScale)};const v=f(M,g.ranges,t.valueScale,6).filter((t=>!u(g.ranges,t)));const w=v.map((s=>(t.valueTickFormatter??t.valueFormatter)(s)));const k=t.valueAxis2?.formatter??t.valueTickFormatter??t.valueFormatter;const I=m&&!t.valueAxis2.hidden?f(p,[],t.valueScale,6):[];const A=I.map((t=>k(t)));const z=Math.max(0,...A.map((t=>L(t,s.labelSize))));const F=[];for(let s=0;s<i;s++)F.push(t.categoryFormatter(t.categories[s]??s));return{C:i,stacked:n,stackKeys:e,bands:o,onAxis2:x,hasAxis2:m,vDomain:M,vDomain2:p,vBreaks:g,vTickVals:v,vTickLabels:w,v2TickVals:I,v2TickLabels:A,maxV2LabelW:z,catLabels:F}}function C(t,s,i,n,e,o,h){const c=i?s.y:s.x;const a=i?s.height:s.width;const r=t.series.find((t=>!t.hidden&&t.pointWidths))?.pointWidths;const l=t=>{const s=r?.[t];return typeof s==="number"&&Number.isFinite(s)&&s>0?s:1};let f=0;const u=[];for(let t=0;t<n;t++){u.push(f);f+=l(t)}if(f<=0)f=Math.max(1,n);const d=t=>n>0?a*l(t)/f:a;const x=t=>c+a*u[t]/f;const m=t=>x(t)+d(t)/2;const y=s=>d(s)*(1-t.categoryGapRatio);const M=t.series.map(((t,s)=>s)).filter((s=>!t.series[s].hidden&&!t.series[s].overlay));const p=[];for(const t of M){const s=o[t];if(!p.includes(s))p.push(s)}const b=e?Math.max(1,p.length):Math.max(1,M.length);const g=s=>y(s)/(b+(b-1)*t.barGapRatio);const v=new Map;const w=new Map;if(e){for(let s=0;s<n;s++){const i=new Map;const n=new Map;t.series.forEach(((t,e)=>{if(t.hidden)return;const c=h[e][s];if(!c)return;const a=`${o[e]}|${s}`;if(c[1]>(i.get(a)??-Infinity)){i.set(a,c[1]);v.set(a,e)}if(c[0]<(n.get(a)??Infinity)){n.set(a,c[0]);w.set(a,e)}}))}}return{sizeAt:d,bandCenter:m,groupInnerAt:y,barWAt:g,groupNames:p,visibleIdx:M,topSeriesFor:v,botSeriesFor:w,mainLen:a}}function R(t,s,i,n,e,o,h,c,a){const r=t.subtitle?s.labelSize+4:0;const l=t.title?s.titleSize+10+r:0;const f=t.valueHidden||t.valueHideTicks?0:Math.max(0,...h.map((t=>L(t,s.labelSize))));const u=t.categoryHidden||t.categoryHideTicks?0:Math.max(0,...c.map((t=>L(t,s.labelSize))));const x=t.showLabels?Math.max(0,...t.series.flatMap((i=>i.range?i.range.flatMap((i=>i?[L(t.valueFormatter(i[0]),s.labelSize),L(t.valueFormatter(i[1]),s.labelSize)]:[])):(i.data??[]).map((i=>typeof i==="number"?L(t.valueFormatter(i),s.labelSize):0))))):0;const m=t.valueLabel?s.labelSize+6:0;const y=t.categoryLabel?s.labelSize+6:0;const M=s.labelSize+8;const p=!e?t.categoryLabelRotation??0:0;const b=Math.abs(p)*Math.PI/180;const g=p?u*Math.sin(b)+s.labelSize*Math.cos(b)+8:M;const v=!!t.legend&&t.legend!=="none"&&t.series.length>1;const w=v&&(t.legend==="left"||t.legend==="right");const k=v&&!w&&t.legend.startsWith("bottom");const I=v&&!w&&!k;const A=I||k?d(t.series.map((t=>t.label)),s.labelSize,i*.86):1;const z=t.legendExtent!=null&&(I||k)?t.legendExtent+8:A*(s.labelSize+8)+6;const F=I?z:0;const S=k?z:0;const $=w?t.legendExtent!=null?t.legendExtent+16:Math.max(0,...t.series.map((t=>L(t.label,s.labelSize))))+34:0;const T=t.legend==="left"?$:0;const B=t.legend==="right"?$:0;const q=(t.showLabels||t.showTotals)&&t.series.some((t=>!t.hidden&&(!!t.range||(t.data??[]).some((t=>typeof t==="number"&&t<0)))));const C=!!t.categoryLabelsMirrored&&e&&!t.categoryHidden&&!t.categoryHideTicks;const R=!!t.compact;const W=q?e?x+8:s.labelSize+4:0;let D;let E;let V;let P;if(R){D=E=V=P=2}else if(e){D=l+8+F;P=u+12+y+T+(q?x+8:0);V=(t.valueHidden||t.valueHideTicks?0:M)+m+6+S;E=12+(t.showLabels?x+8:0)+B+(C?u+12:0)}else{D=l+8+F+(t.showLabels?s.labelSize+4:0);E=12+B+(t.showLabels?x/2:0)+(o?a+10+(t.valueAxis2.label?s.labelSize+6:0):0);P=f+10+m+T;V=(t.categoryHidden||t.categoryHideTicks?0:g)+y+6+S+(q?s.labelSize+4:0)}const N={x:P,y:D,width:Math.max(1,i-P-E),height:Math.max(1,n-D-V)};return{plot:N,compact:R,legendBandTop:F,legendBandBottom:S,lowEndRoom:W,mirrorCats:C,maxDataLabelW:x,catRot:p,catRotRad:b}}function W(h,c,a,r){const l=h.horizontal;const{C:f,stacked:u,stackKeys:d,bands:m,onAxis2:y,hasAxis2:M,vDomain:p,vDomain2:b,vBreaks:g,vTickVals:v,vTickLabels:w,v2TickVals:k,v2TickLabels:I,maxV2LabelW:A,catLabels:z}=q(h,c);if(h.polar)return D(h,c,a,r,m,p,z,f);const{plot:F,compact:S,legendBandTop:$,legendBandBottom:T,lowEndRoom:W,mirrorCats:E,maxDataLabelW:V,catRot:P,catRotRad:N}=R(h,c,a,r,l,M,w,z,A);const _=l?F.width:F.height;const G=t(p,_,h.valueScale,g.ranges,g.sizing);const K=Math.min(p[1],Math.max(p[0],0));const j=M?t(b,_,h.valueScale,[],g.sizing):G;const H=t=>l?F.x+G.scale(t):F.y+F.height-G.scale(t);const Z=t=>l?F.x+j.scale(t):F.y+F.height-j.scale(t);const J=(t,s)=>M&&y(t)?Z(s):H(s);const O=H(K);const U=(G.breaks??[]).map((t=>l?{lo:F.x+t.px,hi:F.x+t.px+t.gap}:{lo:F.y+F.height-t.px-t.gap,hi:F.y+F.height-t.px}));const Q=t=>{if(!U.length)return[t];const s=l?t.x:t.y;const i=s+(l?t.w:t.h);let n=[{lo:s,hi:i}];for(const t of U){const s=[];for(const i of n){if(t.hi<=i.lo||t.lo>=i.hi){s.push(i);continue}if(t.lo>i.lo)s.push({lo:i.lo,hi:t.lo});if(t.hi<i.hi)s.push({lo:t.hi,hi:i.hi})}n=s}if(n.length===1&&n[0].lo===s&&n[0].hi===i)return[t];return n.filter((t=>t.hi-t.lo>.5)).map(((s,i,n)=>({...t,radius:i===(l?n.length-1:0)?t.radius:[0,0,0,0],...l?{x:s.lo,w:s.hi-s.lo}:{y:s.lo,h:s.hi-s.lo}})))};const{sizeAt:X,bandCenter:Y,groupInnerAt:tt,barWAt:st,groupNames:it,visibleIdx:nt,topSeriesFor:et,botSeriesFor:ot,mainLen:ht}=C(h,F,l,f,u,d,m);const ct=[];const at=[];const rt=[];const lt=[];const ft=h.cornerRadius;h.series.forEach(((t,i)=>{if(t.hidden)return;const n=u?Math.max(0,it.indexOf(d[i])):Math.max(0,nt.indexOf(i));const e={};for(let o=0;o<f;o++){const a=m[i][o];if(!a)continue;const r=!!t.range;const f=r?null:t.data[o];const y=typeof f==="number"?f:a[1];const M=J(i,a[0]);const p=J(i,a[1]);const b=t.overlay?X(o)*(t.widthRatio??.45):st(o);const g=b*h.barGapRatio;const v=h.barWidth!=null&&!t.overlay?Math.min(Math.max(1,h.barWidth),b):b;const w=t.overlay?Y(o)-b/2:Y(o)-tt(o)/2+n*(b+g);const k=w+(b-v)/2;const I=y>=0;const A=`${d[i]}|${o}`;const z=I?a[0]===0:a[1]===0;const F=r||!u||(I?et.get(A)===i:ot.get(A)===i);const S=h.chevron?Math.min(v*.03,5,Math.abs(p-M)*.35):0;const $=h.chevron?x(v)-S/2:0;let T;if(l){const s=Math.min(M,p)+S/2;const n=Math.abs(p-M)-S;const c=r?[ft,ft,ft,ft]:F?I?[0,ft,ft,0]:[ft,0,0,ft]:[0,0,0,0];T={x:s,y:k,w:n,h:v,color:t.pointColors?.[o]??t.color,radius:c,seriesIndex:i,dataIndex:o,horizontal:true,arrow:h.chevron?I?1:-1:undefined,notch:h.chevron?!z:undefined};e[o]={x:I?Math.max(M,p)+$:Math.min(M,p)-$,y:k+v/2,value:y,color:T.color,...r?{low:a[0],high:a[1]}:null}}else{const s=Math.min(M,p)+S/2;const n=Math.abs(p-M)-S;const c=r?[ft,ft,ft,ft]:F?I?[ft,ft,0,0]:[0,0,ft,ft]:[0,0,0,0];T={x:k,y:s,w:v,h:n,color:t.pointColors?.[o]??t.color,radius:c,seriesIndex:i,dataIndex:o,horizontal:false,arrow:h.chevron?I?1:-1:undefined,notch:h.chevron?!z:undefined};e[o]={x:k+v/2,y:I?Math.min(M,p)-$:Math.max(M,p)+$,value:y,color:T.color,...r?{low:a[0],high:a[1]}:null}}ct.push(...Q(T));if(h.showLabels&&r){lt.push({seriesIndex:i,dataIndex:o,text:h.valueFormatter(a[0]),color:c.textColor,size:c.labelSize,atLowEnd:true},{seriesIndex:i,dataIndex:o,text:h.valueFormatter(a[1]),color:c.textColor,size:c.labelSize,atLowEnd:false})}else if(h.showLabels&&u&&typeof f==="number"){const t=h.stack==="percentage"?Math.abs(a[1]-a[0])*(f<0?-1:1):f;const n=h.valueFormatter(t);const e=l?T.w>L(n,c.labelSize)+8&&T.h>c.labelSize:T.h>c.labelSize+6&&T.w>L(n,c.labelSize)+4;if(e){lt.push({seriesIndex:i,dataIndex:o,text:n,color:s(T.color),size:c.labelSize,fontWeight:600,inside:true})}}else if(h.showLabels&&typeof f==="number"){lt.push({seriesIndex:i,dataIndex:o,text:h.valueFormatter(f),color:c.textColor,size:c.labelSize,atLowEnd:!I})}}at.push({seriesIndex:i,color:t.color,label:t.label,byIndex:e,values:t.range?m[i].map((t=>t?t[1]:null)):t.data})}));if(h.showTotals&&u&&h.stack!=="percentage"){for(let t=0;t<f;t++){for(const s of it){let i=-Infinity;let n=Infinity;let e=0;let o=false;h.series.forEach(((h,c)=>{if(h.hidden||d[c]!==s)return;const a=m[c][t];const r=h.data?.[t];if(!a)return;o=true;i=Math.max(i,a[1]);n=Math.min(n,a[0]);if(typeof r==="number")e+=r}));if(!o)continue;const a=h.valueFormatter(e);const r=i>0||n>=0;const l=r?et.get(`${s}|${t}`):ot.get(`${s}|${t}`);if(l==null)continue;lt.push({seriesIndex:l,dataIndex:t,text:a,color:c.textColor,size:c.labelSize,fontWeight:600,atLowEnd:!r})}}}const ut=[];const dt=[];const xt=5;const mt=F.y+F.height;const yt=i(h.valueDash);const Mt=i(h.valueGridDash);const pt=i(h.categoryDash);if(!h.valueHidden&&!S){for(const t of v){const s=H(t);if(l){ut.push({x1:s,y1:F.y,x2:s,y2:mt,color:c.gridLineColor,width:1,dash:Mt});if(h.axisTicks)dt.push({x1:s,y1:mt,x2:s,y2:mt+xt,color:c.axisLineColor,width:1,dash:yt})}else{ut.push({x1:F.x,y1:s,x2:F.x+F.width,y2:s,color:c.gridLineColor,width:1,dash:Mt});if(h.axisTicks)dt.push({x1:F.x-xt,y1:s,x2:F.x,y2:s,color:c.axisLineColor,width:1,dash:yt})}}}if(!S){const t=h.categoryAxisLine!==false;const s=h.valueAxisLine!==false;const i=G.breaks??[];if(t){dt.push(l?{x1:F.x,y1:F.y,x2:F.x,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:pt}:{x1:F.x,y1:F.y+F.height,x2:F.x+F.width,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:pt})}if(s){if(l){const t=i.map((t=>({px:t.px,gap:t.gap})));dt.push(...n("x",F.x,F.x+F.width,F.y+F.height,t,c.axisLineColor,yt));for(const s of t)dt.push(...e("x",F.x+s.px,F.x+s.px+s.gap,F.y,F.y+F.height,c.axisLineColor))}else{const t=i.map((t=>({px:F.height-t.px-t.gap,gap:t.gap})));dt.push(...n("y",F.y,F.y+F.height,F.x,t,c.axisLineColor,yt));for(const s of t)dt.push(...e("y",F.y+s.px,F.y+s.px+s.gap,F.x,F.x+F.width,c.axisLineColor))}}}if(h.title&&!S){const t=o(h.titleAlign,F.x,F.width);rt.push({x:t.x,y:$+6,text:h.title,color:c.textColor,fontSize:c.titleSize,fontWeight:600,align:t.align,baseline:"top",key:"title"});if(h.subtitle){rt.push({x:t.x,y:$+6+c.titleSize+4,text:h.subtitle,color:c.textColorMuted,fontSize:c.labelSize,align:t.align,baseline:"top",key:"subtitle"})}}if(M&&!h.valueAxis2.hidden&&!S&&!l){const t=F.x+F.width;dt.push({x1:t,y1:F.y,x2:t,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:yt});k.forEach(((s,i)=>{const n=Z(s);if(h.axisTicks)dt.push({x1:t,y1:n,x2:t+xt,y2:n,color:c.axisLineColor,width:1,dash:yt});rt.push({x:t+8,y:n,text:I[i],color:c.textColorMuted,fontSize:c.labelSize,align:"start",baseline:"middle",key:`v2t-${i}`})}));if(h.valueAxis2.label){rt.push({x:a-4,y:F.y+F.height/2,text:h.valueAxis2.label,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",rotate:-90,key:"val2-axis-title"})}}if(!h.valueHidden&&!h.valueHideTicks&&!S){v.forEach(((t,s)=>{const i=H(t);if(l){rt.push({x:i,y:F.y+F.height+6,text:w[s],color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"top",key:`vt-${s}`})}else{rt.push({x:F.x-8,y:i,text:w[s],color:c.textColorMuted,fontSize:c.labelSize,align:"end",baseline:"middle",key:`vt-${s}`})}}))}const bt=[];const gt=l?c.labelSize+6:48;const vt=Math.max(1,Math.ceil(f/Math.max(1,Math.floor(ht/gt))));for(let t=0;t<f;t++){const s=Y(t);bt.push(s);const i=t%vt===0;if(h.axisTicks&&!S&&i&&!h.categoryHidden){if(l)dt.push({x1:F.x-xt,y1:s,x2:F.x,y2:s,color:c.axisLineColor,width:1});else dt.push({x1:s,y1:mt,x2:s,y2:mt+xt,color:c.axisLineColor,width:1})}if(h.categoryHidden||h.categoryHideTicks||S||!i)continue;if(l){rt.push({x:F.x-8-W,y:s,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"end",baseline:"middle",key:`ct-${t}`});if(E){rt.push({x:F.x+F.width+8+(h.showLabels?V+4:0),y:s,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"start",baseline:"middle",key:`ctm-${t}`})}}else if(P){const i=L(z[t],c.labelSize);const n=P<0?-1:1;rt.push({x:s+n*i*Math.cos(N)/2,y:F.y+F.height+6+W+i*Math.sin(N)/2,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"middle",rotate:P,key:`ct-${t}`})}else{const i=t+vt<f?Y(t+vt):s+vt*X(t);const n=t-vt>=0?Y(t-vt):s-vt*X(t);const e=Math.min(i-s,s-n)-6;rt.push({x:s,y:F.y+F.height+6+W,text:B(z[t],e,c.labelSize),color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"top",key:`ct-${t}`})}}if(!S){const t=h.categoryLabel;const s=h.valueLabel;if(l){if(t)rt.push({x:4,y:F.y+F.height/2,text:t,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"top",rotate:-90,key:"cat-axis-title"});if(s)rt.push({x:F.x+F.width/2,y:r-2-T,text:s,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",key:"val-axis-title"})}else{if(s)rt.push({x:4,y:F.y+F.height/2,text:s,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"top",rotate:-90,key:"val-axis-title"});if(t)rt.push({x:F.x+F.width/2,y:r-2-T,text:t,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",key:"cat-axis-title"})}}const wt=h.legend==="none"||S?[]:h.series.map(((t,s)=>({label:t.label,color:t.color,seriesIndex:s,hidden:t.hidden,x:0,y:0})));return{width:a,height:r,plot:F,background:c.background==="transparent"?undefined:c.background,gridlines:ut,axisLines:dt,areas:[],bars:ct,slices:[],lines:[],markers:[],texts:rt,barLabels:lt,legend:wt,legendPosition:h.legend,xPositions:bt,xValues:h.categories,xLabels:z,barBaseline:O,hoverPoints:at}}function D(t,s,i,n,e,h,c,a){const r=[];const l=t.subtitle?s.labelSize+4:0;const u=t.title?s.titleSize+10+l:0;const x=!!t.legend&&t.legend!=="none"&&t.series.length>1;const m=x&&t.legend.startsWith("bottom");const y=x&&!m&&!(t.legend==="left"||t.legend==="right");const M=x?d(t.series.map((t=>t.label)),s.labelSize,i*.86):1;const p=t.legendExtent!=null&&(y||m)?t.legendExtent+8:M*(s.labelSize+8)+6;const b=y?p:0;const g=m?p:0;const v=t.categoryHidden||t.categoryHideTicks?0:Math.max(0,...c.map((t=>L(t,s.labelSize))))+12;const w={x:v,y:u+b,width:Math.max(1,i-v),height:Math.max(1,n-u-b-g)};const k=w.x+w.width/2;const I=w.y+w.height/2;const A=t.valueTickFormatter??t.valueFormatter;const z=t.valueHidden||t.valueHideTicks?[]:f(h,[],t.valueScale,8).filter((t=>t>=h[0]-1e-9&&t<=h[1]+1e-9));const F=Math.max(0,...z.map((t=>L(A(t),s.labelSize))));const S=z.length?F+18:0;const $=Math.max(8,Math.min(w.width,w.height)/2-8-S);const T=$*Math.max(0,Math.min(.9,t.polarHole??.22));const B=a>0?($-T)/a:$-T;const q=Math.max(1,B*(1-t.categoryGapRatio));const C=-Math.PI/2;const R=2*Math.PI*Math.max(.1,Math.min(1,t.polarSweep??.75));const[W,D]=h;const E=D-W||1;const V=t=>C+(t-W)/E*R;const P=[];const N=[];const _=[];for(let t=0;t<a;t++){const s=$-t*B;_.push(s-q/2)}t.series.forEach(((t,s)=>{if(t.hidden)return;const i={};for(let n=0;n<a;n++){const o=e[s][n];if(!o)continue;const h=$-n*B;const c=h-q;const a=V(o[0]);const r=V(o[1]);if(Math.abs(r-a)<1e-6)continue;P.push({cx:k,cy:I,innerR:c,outerR:h,startAngle:Math.min(a,r),endAngle:Math.max(a,r),color:t.pointColors?.[n]??t.color,dataIndex:n,seriesIndex:s,pill:true,capStart:false,capEnd:false});const l=(a+r)/2;const f=(c+h)/2;i[n]={x:k+f*Math.cos(l),y:I+f*Math.sin(l),value:typeof t.data?.[n]==="number"?t.data[n]:o[1]}}N.push({seriesIndex:s,color:t.color,label:t.label,byIndex:i,values:t.data??[]})}));for(let t=0;t<a;t++){const s=P.filter((s=>s.dataIndex===t));if(!s.length)continue;let i=s[0];let n=s[0];for(const t of s){if(t.startAngle<i.startAngle)i=t;if(t.endAngle>n.endAngle)n=t}i.capStart=true;n.capEnd=true}const G=$+16;for(const t of z){const i=V(t);const n=Math.cos(i);const e=Math.sin(i);r.push({x:k+G*n,y:I+G*e,text:A(t),color:s.textColorMuted,fontSize:s.labelSize,align:n>.35?"start":n<-.35?"end":"center",baseline:e>.35?"top":e<-.35?"bottom":"middle",key:`vt-${t}`})}if(!t.categoryHidden&&!t.categoryHideTicks){for(let t=0;t<a;t++){r.push({x:k-q/2-12,y:I-_[t],text:c[t],color:s.textColorMuted,fontSize:s.labelSize,align:"end",baseline:"middle",key:`ct-${t}`})}}if(t.title){const i=o(t.titleAlign,w.x,w.width);r.push({x:i.x,y:b+6,text:t.title,color:s.textColor,fontSize:s.titleSize,fontWeight:600,align:i.align,baseline:"top",key:"title"});if(t.subtitle){r.push({x:i.x,y:b+6+s.titleSize+6,text:t.subtitle,color:s.textColorMuted,fontSize:s.labelSize,align:i.align,baseline:"top",key:"subtitle"})}}const K=t.legend==="none"?[]:t.series.map(((t,s)=>({label:t.label,color:t.color,seriesIndex:s,hidden:t.hidden,x:0,y:0})));return{width:i,height:n,plot:w,background:s.background==="transparent"?undefined:s.background,gridlines:[],axisLines:[],areas:[],bars:[],slices:P,lines:[],markers:[],texts:r,legend:K,legendPosition:t.legend,polar:true,xPositions:_,xValues:t.categories,xLabels:c,hoverPoints:N}}function E(t,s,i){const n=t-i.cx;const e=s-i.cy;const o=Math.hypot(n,e);if(o<i.innerR||o>i.outerR)return false;const h=Math.min(i.startAngle,i.endAngle);const c=Math.max(i.startAngle,i.endAngle);const a=Math.PI*2;let r=(Math.atan2(e,n)-h)%a;if(r<0)r+=a;return r<=c-h}function V(t,s,i){for(const n of t)if(n.endAngle!==n.startAngle&&E(s,i,n))return n;return null}const P=.62;const N=200;const _=220;const G=(t,s)=>`${t}:${s??-1}`;function K(t,s,i){return{...t,slices:t.slices.map((t=>{const n=s.get(G(t.dataIndex,t.seriesIndex))??0;return n>.002?{...t,color:S(t.color,i,P*n)}:t}))}}const j=(t,s,i)=>t+(s-t)*i;const H=260;function Z(t){const s=(t.xValues??[]).map((t=>t==null?"":String(t)));const i=s.length>0&&new Set(s).size===s.length;return i?t=>`${t.seriesIndex}::${s[t.dataIndex]??t.dataIndex}`:t=>`${t.seriesIndex}#${t.dataIndex}`}function J(t,s){return Z(t)(s)}function O(t){const s=Z(t);const i=new Map;return t.bars.map((t=>{const n=s(t);const e=i.get(n)??0;i.set(n,e+1);return e===0?n:`${n}~${e}`}))}function U(t){const s=O(t);const i=new Map;t.bars.forEach(((t,n)=>i.set(s[n],t)));return i}function Q(t,s,i){return{...s,x:j(t.x,s.x,i),y:j(t.y,s.y,i),w:j(t.w,s.w,i),h:j(t.h,s.h,i)}}function X(t,s){if(t.bars.length!==s.bars.length)return true;const i=U(t);for(const t of s.bars){const n=i.get(J(s,t));if(!n)return true;if(Math.abs(n.x-t.x)>.5||Math.abs(n.y-t.y)>.5||Math.abs(n.w-t.w)>.5||Math.abs(n.h-t.h)>.5)return true}return false}class Y{constructor(t){this.container=t;this.ctx=null;this.spec=null;this.theme=null;this.scene=null;this.cb={};this.hoverRaf=0;this.lastHoverIndex=-2;this.hoverEnabled=true;this.clickable=false;this.hoverOpts={};this.hasRendered=false;this.introRaf=0;this.lastDpr=1;this.followRaf=0;this.followLast=0;this.hoverSlice=null;this.dimAnim=new Map;this.dimRaf=0;this.dimLast=0;this.lastPointer={x:0,y:0};this.tooltipTimer=0;this.tooltipShown=false;this.displayed=null;this.pendingDrill=null;this.drillArmRaf=0;this.lastW=0;this.lastH=0;this.dprWatch=m((()=>this.render()));this.rtl=false;this.dirWatch=y((()=>{if(M(this.container)!==this.rtl)this.render()}));this.followStep=t=>{if(!this.scene){this.followRaf=0;return}const s=this.followLast?t-this.followLast:16;this.followLast=t;const i=this.renderFollow(Math.min(1,s/H));this.followRaf=i?requestAnimationFrame(this.followStep):0};this.stepDim=t=>{if(!this.scene||!this.theme){this.dimRaf=0;return}const s=this.dimLast?t-this.dimLast:16;this.dimLast=t;let i=false;for(const t of this.scene.slices){const n=G(t.dataIndex,t.seriesIndex);const e=this.dimTarget(t);const o=this.dimAnim.get(n)??0;let h=o+Math.sign(e-o)*(s/N);if((e-o)*(e-h)<=0)h=e;this.dimAnim.set(n,h);if(h!==e)i=true}this.drawGeometry(K(this.scene,this.dimAnim,this.theme.surface),this.lastDpr);this.dimRaf=i?requestAnimationFrame(this.stepDim):0};this.handlePointerMove=t=>{if(!this.scene||!this.spec||!this.hoverEnabled)return;const s=this.canvas.getBoundingClientRect();const i=t.clientX-s.left;const n=t.clientY-s.top;if(this.spec.polar){const t=V(this.scene.slices,i,n);const s=t?{dataIndex:t.dataIndex,seriesIndex:t.seriesIndex??-1}:null;this.lastPointer={x:i,y:n};if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.hoverRaf=requestAnimationFrame((()=>{this.hoverRaf=0;if(!this.scene||!this.spec||!this.theme)return;this.canvas.style.cursor=s?"pointer":"";const t=s?.dataIndex!==this.hoverSlice?.dataIndex||s?.seriesIndex!==this.hoverSlice?.seriesIndex;if(t){this.hoverSlice=s;this.startDim();this.armTooltip(s)}else if(this.tooltipShown&&s){this.showPolarTooltip(s)}const i=s?s.dataIndex:-1;if(i!==this.lastHoverIndex){this.lastHoverIndex=i;this.cb.onHover?.(i)}}));return}const e=$(this.scene.xPositions,this.spec.horizontal?n:i);if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.hoverRaf=requestAnimationFrame((()=>{this.hoverRaf=0;if(!this.scene||!this.spec||!this.theme)return;this.canvas.style.cursor=this.clickable&&this.overBar(i,n)?"pointer":"";p(this.hoverLayer,this.scene,e,this.spec.valueFormatter,this.theme.fontFamily,{x:i,y:n},this.spec.horizontal?"horizontal":"vertical",-1,this.hoverOpts);if(e!==this.lastHoverIndex){this.lastHoverIndex=e;this.cb.onHover?.(e)}}))};this.handlePointerLeave=()=>{if(this.hoverRaf){cancelAnimationFrame(this.hoverRaf);this.hoverRaf=0}this.canvas.style.cursor="";b(this.hoverLayer);if(this.spec?.polar&&this.scene){clearTimeout(this.tooltipTimer);this.tooltipShown=false;this.canvas.style.cursor="";if(this.hoverSlice){this.hoverSlice=null;this.startDim()}}if(this.lastHoverIndex!==-1){this.lastHoverIndex=-1;this.cb.onHover?.(-1)}};this.handleClick=t=>{if(!this.scene||!this.cb.onPointClick)return;const s=this.canvas.getBoundingClientRect();const i=t.clientX-s.left;const n=t.clientY-s.top;for(const s of this.scene.bars){if(i>=s.x&&i<=s.x+s.w&&n>=s.y&&n<=s.y+s.h){this.cb.onPointClick(s.seriesIndex,s.dataIndex,t);return}}};this.onLegendToggle=t=>{if(this.spec){this.spec.series[t.seriesIndex].hidden=!this.spec.series[t.seriesIndex].hidden;this.hasRendered=false;this.render();this.cb.onLegendClick?.({...t,hidden:this.spec.series[t.seriesIndex].hidden})}else{this.cb.onLegendClick?.(t)}};if(getComputedStyle(t).position==="static")t.style.position="relative";this.canvas=document.createElement("canvas");this.canvas.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block";this.canvas.setAttribute("part","plot-canvas");this.overlay=document.createElement("div");this.overlay.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";this.legendLayer=document.createElement("div");this.legendLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:visible";this.barLabelLayer=document.createElement("div");this.barLabelLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";this.hoverLayer=document.createElement("div");this.hoverLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";t.append(this.canvas,this.overlay,this.legendLayer,this.barLabelLayer,this.hoverLayer);this.ctx=this.canvas.getContext("2d");this.canvas.addEventListener("pointermove",this.handlePointerMove);this.canvas.addEventListener("pointerleave",this.handlePointerLeave);this.canvas.addEventListener("click",this.handleClick)}getScene(){return this.scene}setHoverEnabled(t){this.hoverEnabled=t;if(!t)b(this.hoverLayer)}setClickable(t){this.clickable=t;if(!t)this.canvas.style.cursor=""}overBar(t,s){return!!this.scene?.bars.some((i=>t>=i.x&&t<=i.x+i.w&&s>=i.y&&s<=i.y+i.h))}setTooltip(t){this.hoverOpts=t}setSpec(t,s,i={},n={}){this.spec=t;this.theme=s;this.cb=i;this.render(n)}resize(){const t=this.container.getBoundingClientRect();if(Math.round(t.width)===this.lastW&&Math.round(t.height)===this.lastH)return;this.render()}toDataURL(t="image/png"){return typeof this.canvas.toDataURL==="function"?this.canvas.toDataURL(t):""}dispose(){if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.stopIntro();cancelAnimationFrame(this.drillArmRaf);cancelAnimationFrame(this.dimRaf);cancelAnimationFrame(this.followRaf);clearTimeout(this.tooltipTimer);this.canvas.removeEventListener("pointermove",this.handlePointerMove);this.canvas.removeEventListener("pointerleave",this.handlePointerLeave);this.canvas.removeEventListener("click",this.handleClick);this.dprWatch.dispose();this.dirWatch.dispose();this.canvas.remove();this.overlay.remove();this.barLabelLayer.remove();this.hoverLayer.remove();this.spec=null;this.scene=null}render(t={}){if(!this.spec||!this.theme)return;this.dprWatch.update();const s=this.container.getBoundingClientRect();const i=Math.round(s.width);const n=Math.round(s.height);if(i<2||n<2)return;const e=this.scene;const o=i!==this.lastW||n!==this.lastH;this.lastW=i;this.lastH=n;const h=Math.min(window.devicePixelRatio||1,4);this.lastDpr=h;this.hoverSlice=null;this.dimAnim.clear();cancelAnimationFrame(this.dimRaf);this.dimRaf=0;if(this.hoverRaf){cancelAnimationFrame(this.hoverRaf);this.hoverRaf=0}clearTimeout(this.tooltipTimer);this.tooltipShown=false;this.canvas.width=i*h;this.canvas.height=n*h;const c=this.scene?.xPositions.length??0;this.rtl=M(this.container);const a=()=>{const t=W(this.spec,this.theme,i,n);return this.rtl?F(t):t};this.scene=a();if(this.lastHoverIndex>=0){if(this.lastHoverIndex<this.scene.xPositions.length&&c===this.scene.xPositions.length){this.focusIndexInternal(this.lastHoverIndex)}else{b(this.hoverLayer);this.lastHoverIndex=-1}}g(this.overlay,this.scene,this.theme.fontFamily,{onLegendClick:this.onLegendToggle},this.rtl,this.legendLayer);const r=this.legendLayer.querySelector('[part="legend"]');if(r&&this.spec.legend&&this.spec.legend!=="none"){const t=this.spec.legend==="left"||this.spec.legend==="right";const s=t?r.offsetWidth:r.offsetHeight;if(s>0&&Math.abs((this.spec.legendExtent??-1)-s)>2){this.spec.legendExtent=s;this.scene=a();g(this.overlay,this.scene,this.theme.fontFamily,{onLegendClick:this.onLegendToggle},this.rtl,this.legendLayer)}}const{variant:l,duration:f}=v(this.spec);const u=this.pendingDrill;const d=w();const x=l!=="none"&&!d;const m=this.scene.bars.length>0||this.scene.slices.length>0;const y=!this.hasRendered&&x;if(u&&x){this.hasRendered=true;this.playDrill(h,u,f);return}if(y){this.hasRendered=m;this.playIntro(h,l,f);return}this.hasRendered=this.hasRendered||m;const p=!!e&&X(e,this.scene);if(t.animate!==false&&!d&&!o&&e&&(p||this.followRaf)){this.stopIntro();this.ensureFollow();return}this.stopIntro();cancelAnimationFrame(this.followRaf);this.followRaf=0;this.paint(this.scene,h);this.displayed=U(this.scene)}drill(t,s="down"){const i=this.scene;if(!i)return;const n=!!this.spec?.horizontal;if(s==="up"){this.arm(n?{from:i.plot.y,size:i.plot.height,split:false}:{from:i.plot.x,size:i.plot.width,split:false});return}const e=i.bars.filter((s=>s.dataIndex===t));if(!e.length){this.arm(null);return}const o=Math.min(...e.map((t=>n?t.y:t.x)));const h=Math.max(...e.map((t=>n?t.y+t.h:t.x+t.w)));this.arm({from:o,size:Math.max(1,h-o),split:true})}arm(t){this.pendingDrill=t;cancelAnimationFrame(this.drillArmRaf);if(!t)return;this.drillArmRaf=requestAnimationFrame((()=>{this.pendingDrill=null}))}clearIntroOpacity(){this.canvas.style.opacity="";this.barLabelLayer.style.opacity=""}stopIntro(){cancelAnimationFrame(this.introRaf);this.introRaf=0;this.clearIntroOpacity()}playDrill(t,s,i){const n=this.scene;if(!n)return;this.stopIntro();this.paint(k(n,s.from,s.size,0,s.split),t);let e=0;const o=h=>{if(!e)e=h;const c=(h-e)/i;if(c>=1){this.displayed=U(n);this.paint(n,t);return}this.paint(k(n,s.from,s.size,c,s.split),t);this.introRaf=requestAnimationFrame(o)};this.introRaf=requestAnimationFrame(o)}replay(){this.hasRendered=false;this.render()}drawGeometry(t,s){if(this.ctx){this.ctx.setTransform(s,0,0,s,0,0);I(this.ctx,t)}}paint(t,s){this.drawGeometry(t,s);A(this.barLabelLayer,t,this.theme?.fontFamily)}playIntro(t,s,i){const n=this.scene;if(!n)return;this.stopIntro();const e=t=>{const s=t<1?String(t):"";this.canvas.style.opacity=s;this.barLabelLayer.style.opacity=s};const o=z(s,n,0);e(o.alpha);this.paint(o.scene,t);let h=0;const c=o=>{if(!h)h=o;const a=(o-h)/i;if(a>=1){e(1);this.displayed=U(n);this.paint(n,t);return}const{scene:r,alpha:l}=z(s,n,a);e(l);this.paint(r,t);this.introRaf=requestAnimationFrame(c)};this.introRaf=requestAnimationFrame(c)}ensureFollow(){if(!this.scene)return;if(w()){cancelAnimationFrame(this.followRaf);this.followRaf=0;this.displayed=U(this.scene);this.paint(this.scene,this.lastDpr);return}const t=this.renderFollow(0);if(t&&!this.followRaf){this.followLast=0;this.followRaf=requestAnimationFrame(this.followStep)}}renderFollow(t){const s=this.scene;if(!s)return false;const i=O(s);const n=this.displayed??U(s);const e=new Map;const o=[];let h=false;s.bars.forEach(((s,c)=>{const a=i[c];const r=n.get(a);const l=r?Q(r,s,t):s;e.set(a,l);o.push(l);if(Math.abs(l.x-s.x)>.3||Math.abs(l.y-s.y)>.3||Math.abs(l.w-s.w)>.3||Math.abs(l.h-s.h)>.3)h=true}));this.displayed=e;this.paint({...s,bars:o},this.lastDpr);return h}focusIndex(t){this.lastHoverIndex=t;this.focusIndexInternal(t)}focusIndexInternal(t){if(!this.scene||!this.spec||!this.theme)return;if(this.spec.polar){const s=t<0?null:{dataIndex:t,seriesIndex:-1};if(s?.dataIndex!==this.hoverSlice?.dataIndex||s?.seriesIndex!==this.hoverSlice?.seriesIndex){this.hoverSlice=s;this.startDim()}}if(t<0){b(this.hoverLayer);return}const s=!!this.spec.horizontal;const i=this.scene.hoverPoints.map((s=>s.byIndex[t])).find(Boolean);const n=this.scene.xPositions[t]??0;const e=i?{x:i.x,y:i.y}:{x:s?this.scene.plot.x:n,y:s?n:this.scene.plot.y};p(this.hoverLayer,this.scene,t,this.spec.valueFormatter,this.theme.fontFamily,e,this.spec.polar?"none":s?"horizontal":"vertical",-1,this.hoverOpts)}dimTarget(t){const s=this.hoverSlice;if(!s)return 0;if(s.seriesIndex<0)return t.dataIndex===s.dataIndex?0:1;return t.dataIndex===s.dataIndex&&t.seriesIndex===s.seriesIndex?0:1}startDim(){if(!this.scene||!this.theme)return;if(w()){cancelAnimationFrame(this.dimRaf);this.dimRaf=0;for(const t of this.scene.slices)this.dimAnim.set(G(t.dataIndex,t.seriesIndex),this.dimTarget(t));this.drawGeometry(K(this.scene,this.dimAnim,this.theme.surface),this.lastDpr);return}if(!this.dimRaf){this.dimLast=0;this.dimRaf=requestAnimationFrame(this.stepDim)}}armTooltip(t){clearTimeout(this.tooltipTimer);b(this.hoverLayer);this.tooltipShown=false;if(!t)return;this.tooltipTimer=window.setTimeout((()=>{const s=this.hoverSlice;if(s&&s.dataIndex===t.dataIndex&&s.seriesIndex===t.seriesIndex){this.showPolarTooltip(t);this.tooltipShown=true}}),_)}showPolarTooltip(t){if(!this.scene||!this.spec||!this.theme)return;p(this.hoverLayer,this.scene,t.dataIndex,this.spec.valueFormatter,this.theme.fontFamily,this.lastPointer,"none",t.seriesIndex,{...this.hoverOpts,trigger:"item"})}}export{Y as B};
|
|
2
|
-
//# sourceMappingURL=p-
|
|
1
|
+
import{v as t,x as s,y as i,z as n,A as e,B as o,C as h,D as c,E as a,F as r,G as l,H as f,I as u,J as d,K as x,w as m,c as y,e as M,f as p,i as b,s as g,g as v,h as w,L as k,l as I,M as A,n as z,m as F,N as S}from"./p-DvOKnoqK.js";import{n as $}from"./p-DzPKu-Ma.js";function L(t,s){return t.length*s*.58}function T(t,s){const i=t[1];const n=s[1];if(!(i>0)||!(n>0))return[t,s];const e=t[0]<0?-t[0]/i:0;const o=s[0]<0?-s[0]/n:0;const h=Math.max(e,o);if(h<=0)return[t,s];return[[-h*i,i],[-h*n,n]]}function B(t,s,i){if(s<=0||L(t,i)<=s)return t;const n=i*.58;const e=Math.floor(s/n)-1;return e>=1?`${t.slice(0,e)}…`:""}function q(t,s){const i=t.categories.length||Math.max(0,...t.series.map((t=>(t.range??t.data??[]).length)));const n=t.stack!=="none";const e=t.series.map((t=>n&&!t.range?t.stack||"stacked":"__unstacked__"));const o=h(t.series.map((t=>t.hidden||t.range?[]:t.data??[])),t.stack,e);t.series.forEach(((t,s)=>{if(!t.range||t.hidden)return;o[s]=t.range.map((t=>t?[Math.min(t[0],t[1]),Math.max(t[0],t[1])]:t))}));const d=[];t.series.forEach(((t,s)=>{if(t.hidden)return;o[s].forEach((t=>{if(t)d.push(t[0],t[1])}))}));const x=s=>(t.series[s].axisIndex??0)===1;const m=!!t.valueAxis2&&t.series.some(((t,s)=>!t.hidden&&x(s)));const y=[];if(m){d.length=0;t.series.forEach(((t,s)=>{if(t.hidden)return;o[s].forEach((t=>{if(t)(x(s)?y:d).push(t[0],t[1])}))}))}let M=l(d,{min:t.valueMin,max:t.valueMax,scale:t.valueScale,includeZero:true});let p=m?l(y,{min:t.valueAxis2.min,max:t.valueAxis2.max,scale:t.valueScale,includeZero:true}):M;if(m&&t.valueScale==="value"&&t.valueMin==null&&t.valueMax==null&&t.valueAxis2.min==null&&t.valueAxis2.max==null){[M,p]=T(M,p)}const b=c(t.valueBreaks,d,t.valueScale);const g={...b,ranges:a(r(b.ranges,M),M,t.valueScale)};const v=f(M,g.ranges,t.valueScale,6).filter((t=>!u(g.ranges,t)));const w=v.map((s=>(t.valueTickFormatter??t.valueFormatter)(s)));const k=t.valueAxis2?.formatter??t.valueTickFormatter??t.valueFormatter;const I=m&&!t.valueAxis2.hidden?f(p,[],t.valueScale,6):[];const A=I.map((t=>k(t)));const z=Math.max(0,...A.map((t=>L(t,s.labelSize))));const F=[];for(let s=0;s<i;s++)F.push(t.categoryFormatter(t.categories[s]??s));return{C:i,stacked:n,stackKeys:e,bands:o,onAxis2:x,hasAxis2:m,vDomain:M,vDomain2:p,vBreaks:g,vTickVals:v,vTickLabels:w,v2TickVals:I,v2TickLabels:A,maxV2LabelW:z,catLabels:F}}function D(t,s,i,n,e,o,h){const c=i?s.y:s.x;const a=i?s.height:s.width;const r=t.series.find((t=>!t.hidden&&t.pointWidths))?.pointWidths;const l=t=>{const s=r?.[t];return typeof s==="number"&&Number.isFinite(s)&&s>0?s:1};let f=0;const u=[];for(let t=0;t<n;t++){u.push(f);f+=l(t)}if(f<=0)f=Math.max(1,n);const d=t=>n>0?a*l(t)/f:a;const x=t=>c+a*u[t]/f;const m=t=>x(t)+d(t)/2;const y=s=>d(s)*(1-t.categoryGapRatio);const M=t.series.map(((t,s)=>s)).filter((s=>!t.series[s].hidden&&!t.series[s].overlay));const p=[];for(const t of M){const s=o[t];if(!p.includes(s))p.push(s)}const b=e?Math.max(1,p.length):Math.max(1,M.length);const g=s=>y(s)/(b+(b-1)*t.barGapRatio);const v=new Map;const w=new Map;if(e){for(let s=0;s<n;s++){const i=new Map;const n=new Map;t.series.forEach(((t,e)=>{if(t.hidden)return;const c=h[e][s];if(!c)return;const a=`${o[e]}|${s}`;if(c[1]>(i.get(a)??-Infinity)){i.set(a,c[1]);v.set(a,e)}if(c[0]<(n.get(a)??Infinity)){n.set(a,c[0]);w.set(a,e)}}))}}return{sizeAt:d,bandCenter:m,groupInnerAt:y,barWAt:g,groupNames:p,visibleIdx:M,topSeriesFor:v,botSeriesFor:w,mainLen:a}}function C(t,s,i,n,e,o,h,c,a){const r=t.subtitle?s.labelSize+4:0;const l=t.title?s.titleSize+10+r:0;const f=t.valueHidden||t.valueHideTicks?0:Math.max(0,...h.map((t=>L(t,s.labelSize))));const u=t.categoryHidden||t.categoryHideTicks?0:Math.max(0,...c.map((t=>L(t,s.labelSize))));const x=t.showLabels?Math.max(0,...t.series.flatMap((i=>i.range?i.range.flatMap((i=>i?[L(t.valueFormatter(i[0]),s.labelSize),L(t.valueFormatter(i[1]),s.labelSize)]:[])):(i.data??[]).map((i=>typeof i==="number"?L(t.valueFormatter(i),s.labelSize):0))))):0;const m=t.valueLabel?s.labelSize+6:0;const y=t.categoryLabel?s.labelSize+6:0;const M=s.labelSize+8;const p=!e?t.categoryLabelRotation??0:0;const b=Math.abs(p)*Math.PI/180;const g=p?u*Math.sin(b)+s.labelSize*Math.cos(b)+8:M;const v=!!t.legend&&t.legend!=="none"&&t.series.length>1;const w=v&&(t.legend==="left"||t.legend==="right");const k=v&&!w&&t.legend.startsWith("bottom");const I=v&&!w&&!k;const A=I||k?d(t.series.map((t=>t.label)),s.labelSize,i*.86):1;const z=t.legendExtent!=null&&(I||k)?t.legendExtent+8:A*(s.labelSize+8)+6;const F=I?z:0;const S=k?z:0;const $=w?t.legendExtent!=null?t.legendExtent+16:Math.max(0,...t.series.map((t=>L(t.label,s.labelSize))))+34:0;const T=t.legend==="left"?$:0;const B=t.legend==="right"?$:0;const q=(t.showLabels||t.showTotals)&&t.series.some((t=>!t.hidden&&(!!t.range||(t.data??[]).some((t=>typeof t==="number"&&t<0)))));const D=!!t.categoryLabelsMirrored&&e&&!t.categoryHidden&&!t.categoryHideTicks;const C=!!t.compact;const R=q?e?x+8:s.labelSize+4:0;let W;let E;let P;let V;if(C){W=E=P=V=2}else if(e){W=l+8+F;V=u+12+y+T+(q?x+8:0);P=(t.valueHidden||t.valueHideTicks?0:M)+m+6+S;E=12+(t.showLabels?x+8:0)+B+(D?u+12:0)}else{W=l+8+F+(t.showLabels?s.labelSize+4:0);E=12+B+(t.showLabels?x/2:0)+(o?a+10+(t.valueAxis2.label?s.labelSize+6:0):0);V=f+10+m+T;P=(t.categoryHidden||t.categoryHideTicks?0:g)+y+6+S+(q?s.labelSize+4:0)}const K={x:V,y:W,width:Math.max(1,i-V-E),height:Math.max(1,n-W-P)};return{plot:K,compact:C,legendBandTop:F,legendBandBottom:S,lowEndRoom:R,mirrorCats:D,maxDataLabelW:x,catRot:p,catRotRad:b}}function R(h,c,a,r){const l=h.horizontal;const{C:f,stacked:u,stackKeys:d,bands:m,onAxis2:y,hasAxis2:M,vDomain:p,vDomain2:b,vBreaks:g,vTickVals:v,vTickLabels:w,v2TickVals:k,v2TickLabels:I,maxV2LabelW:A,catLabels:z}=q(h,c);if(h.polar)return W(h,c,a,r,m,p,z,f);const{plot:F,compact:S,legendBandTop:$,legendBandBottom:T,lowEndRoom:R,mirrorCats:E,maxDataLabelW:P,catRot:V,catRotRad:K}=C(h,c,a,r,l,M,w,z,A);const N=l?F.width:F.height;const _=t(p,N,h.valueScale,g.ranges,g.sizing);const j=Math.min(p[1],Math.max(p[0],0));const G=M?t(b,N,h.valueScale,[],g.sizing):_;const H=t=>l?F.x+_.scale(t):F.y+F.height-_.scale(t);const O=t=>l?F.x+G.scale(t):F.y+F.height-G.scale(t);const Z=(t,s)=>M&&y(t)?O(s):H(s);const J=H(j);const U=(_.breaks??[]).map((t=>l?{lo:F.x+t.px,hi:F.x+t.px+t.gap}:{lo:F.y+F.height-t.px-t.gap,hi:F.y+F.height-t.px}));const Q=t=>{if(!U.length)return[t];const s=l?t.x:t.y;const i=s+(l?t.w:t.h);let n=[{lo:s,hi:i}];for(const t of U){const s=[];for(const i of n){if(t.hi<=i.lo||t.lo>=i.hi){s.push(i);continue}if(t.lo>i.lo)s.push({lo:i.lo,hi:t.lo});if(t.hi<i.hi)s.push({lo:t.hi,hi:i.hi})}n=s}if(n.length===1&&n[0].lo===s&&n[0].hi===i)return[t];return n.filter((t=>t.hi-t.lo>.5)).map(((s,i,n)=>({...t,radius:i===(l?n.length-1:0)?t.radius:[0,0,0,0],...l?{x:s.lo,w:s.hi-s.lo}:{y:s.lo,h:s.hi-s.lo}})))};const{sizeAt:X,bandCenter:Y,groupInnerAt:tt,barWAt:st,groupNames:it,visibleIdx:nt,topSeriesFor:et,botSeriesFor:ot,mainLen:ht}=D(h,F,l,f,u,d,m);const ct=[];const at=[];const rt=[];const lt=[];const ft=h.cornerRadius;h.series.forEach(((t,i)=>{if(t.hidden)return;const n=u?Math.max(0,it.indexOf(d[i])):Math.max(0,nt.indexOf(i));const e={};for(let o=0;o<f;o++){const a=m[i][o];if(!a)continue;const r=!!t.range;const f=r?null:t.data[o];const y=typeof f==="number"?f:a[1];const M=Z(i,a[0]);const p=Z(i,a[1]);const b=t.overlay?X(o)*(t.widthRatio??.45):st(o);const g=b*h.barGapRatio;const v=h.barWidth!=null&&!t.overlay?Math.min(Math.max(1,h.barWidth),b):b;const w=t.overlay?Y(o)-b/2:Y(o)-tt(o)/2+n*(b+g);const k=w+(b-v)/2;const I=y>=0;const A=`${d[i]}|${o}`;const z=I?a[0]===0:a[1]===0;const F=r||!u||(I?et.get(A)===i:ot.get(A)===i);const S=h.chevron?Math.min(v*.03,5,Math.abs(p-M)*.35):0;const $=h.chevron?x(v)-S/2:0;let T;if(l){const s=Math.min(M,p)+S/2;const n=Math.abs(p-M)-S;const c=r?[ft,ft,ft,ft]:F?I?[0,ft,ft,0]:[ft,0,0,ft]:[0,0,0,0];T={x:s,y:k,w:n,h:v,color:t.pointColors?.[o]??t.color,radius:c,seriesIndex:i,dataIndex:o,horizontal:true,arrow:h.chevron?I?1:-1:undefined,notch:h.chevron?!z:undefined};e[o]={x:I?Math.max(M,p)+$:Math.min(M,p)-$,y:k+v/2,value:y,color:T.color,...r?{low:a[0],high:a[1]}:null}}else{const s=Math.min(M,p)+S/2;const n=Math.abs(p-M)-S;const c=r?[ft,ft,ft,ft]:F?I?[ft,ft,0,0]:[0,0,ft,ft]:[0,0,0,0];T={x:k,y:s,w:v,h:n,color:t.pointColors?.[o]??t.color,radius:c,seriesIndex:i,dataIndex:o,horizontal:false,arrow:h.chevron?I?1:-1:undefined,notch:h.chevron?!z:undefined};e[o]={x:k+v/2,y:I?Math.min(M,p)-$:Math.max(M,p)+$,value:y,color:T.color,...r?{low:a[0],high:a[1]}:null}}ct.push(...Q(T));if(h.showLabels&&r){lt.push({seriesIndex:i,dataIndex:o,text:h.valueFormatter(a[0]),color:c.textColor,size:c.labelSize,atLowEnd:true},{seriesIndex:i,dataIndex:o,text:h.valueFormatter(a[1]),color:c.textColor,size:c.labelSize,atLowEnd:false})}else if(h.showLabels&&u&&typeof f==="number"){const t=h.stack==="percentage"?Math.abs(a[1]-a[0])*(f<0?-1:1):f;const n=h.valueFormatter(t);const e=l?T.w>L(n,c.labelSize)+8&&T.h>c.labelSize:T.h>c.labelSize+6&&T.w>L(n,c.labelSize)+4;if(e){lt.push({seriesIndex:i,dataIndex:o,text:n,color:s(T.color),size:c.labelSize,fontWeight:600,inside:true})}}else if(h.showLabels&&typeof f==="number"){lt.push({seriesIndex:i,dataIndex:o,text:h.valueFormatter(f),color:c.textColor,size:c.labelSize,atLowEnd:!I})}}at.push({seriesIndex:i,color:t.color,label:t.label,byIndex:e,values:t.range?m[i].map((t=>t?t[1]:null)):t.data})}));if(h.showTotals&&u&&h.stack!=="percentage"){for(let t=0;t<f;t++){for(const s of it){let i=-Infinity;let n=Infinity;let e=0;let o=false;h.series.forEach(((h,c)=>{if(h.hidden||d[c]!==s)return;const a=m[c][t];const r=h.data?.[t];if(!a)return;o=true;i=Math.max(i,a[1]);n=Math.min(n,a[0]);if(typeof r==="number")e+=r}));if(!o)continue;const a=h.valueFormatter(e);const r=i>0||n>=0;const l=r?et.get(`${s}|${t}`):ot.get(`${s}|${t}`);if(l==null)continue;lt.push({seriesIndex:l,dataIndex:t,text:a,color:c.textColor,size:c.labelSize,fontWeight:600,atLowEnd:!r})}}}const ut=[];const dt=[];const xt=5;const mt=F.y+F.height;const yt=i(h.valueDash);const Mt=i(h.valueGridDash);const pt=i(h.categoryDash);if(!h.valueHidden&&!S){for(const t of v){const s=H(t);if(l){ut.push({x1:s,y1:F.y,x2:s,y2:mt,color:c.gridLineColor,width:1,dash:Mt});if(h.axisTicks)dt.push({x1:s,y1:mt,x2:s,y2:mt+xt,color:c.axisLineColor,width:1,dash:yt})}else{ut.push({x1:F.x,y1:s,x2:F.x+F.width,y2:s,color:c.gridLineColor,width:1,dash:Mt});if(h.axisTicks)dt.push({x1:F.x-xt,y1:s,x2:F.x,y2:s,color:c.axisLineColor,width:1,dash:yt})}}}if(!S){const t=h.categoryAxisLine!==false;const s=h.valueAxisLine!==false;const i=_.breaks??[];if(t){dt.push(l?{x1:F.x,y1:F.y,x2:F.x,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:pt}:{x1:F.x,y1:F.y+F.height,x2:F.x+F.width,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:pt})}if(s){if(l){const t=i.map((t=>({px:t.px,gap:t.gap})));dt.push(...n("x",F.x,F.x+F.width,F.y+F.height,t,c.axisLineColor,yt));for(const s of t)dt.push(...e("x",F.x+s.px,F.x+s.px+s.gap,F.y,F.y+F.height,c.axisLineColor))}else{const t=i.map((t=>({px:F.height-t.px-t.gap,gap:t.gap})));dt.push(...n("y",F.y,F.y+F.height,F.x,t,c.axisLineColor,yt));for(const s of t)dt.push(...e("y",F.y+s.px,F.y+s.px+s.gap,F.x,F.x+F.width,c.axisLineColor))}}}if(h.title&&!S){const t=o(h.titleAlign,F.x,F.width);rt.push({x:t.x,y:$+6,text:h.title,color:c.textColor,fontSize:c.titleSize,fontWeight:600,align:t.align,baseline:"top",key:"title"});if(h.subtitle){rt.push({x:t.x,y:$+6+c.titleSize+4,text:h.subtitle,color:c.textColorMuted,fontSize:c.labelSize,align:t.align,baseline:"top",key:"subtitle"})}}if(M&&!h.valueAxis2.hidden&&!S&&!l){const t=F.x+F.width;dt.push({x1:t,y1:F.y,x2:t,y2:F.y+F.height,color:c.axisLineColor,width:1,dash:yt});k.forEach(((s,i)=>{const n=O(s);if(h.axisTicks)dt.push({x1:t,y1:n,x2:t+xt,y2:n,color:c.axisLineColor,width:1,dash:yt});rt.push({x:t+8,y:n,text:I[i],color:c.textColorMuted,fontSize:c.labelSize,align:"start",baseline:"middle",key:`v2t-${i}`})}));if(h.valueAxis2.label){rt.push({x:a-4,y:F.y+F.height/2,text:h.valueAxis2.label,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",rotate:-90,key:"val2-axis-title"})}}if(!h.valueHidden&&!h.valueHideTicks&&!S){v.forEach(((t,s)=>{const i=H(t);if(l){rt.push({x:i,y:F.y+F.height+6,text:w[s],color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"top",key:`vt-${s}`})}else{rt.push({x:F.x-8,y:i,text:w[s],color:c.textColorMuted,fontSize:c.labelSize,align:"end",baseline:"middle",key:`vt-${s}`})}}))}const bt=[];const gt=l?c.labelSize+6:48;const vt=Math.max(1,Math.ceil(f/Math.max(1,Math.floor(ht/gt))));for(let t=0;t<f;t++){const s=Y(t);bt.push(s);const i=t%vt===0;if(h.axisTicks&&!S&&i&&!h.categoryHidden){if(l)dt.push({x1:F.x-xt,y1:s,x2:F.x,y2:s,color:c.axisLineColor,width:1});else dt.push({x1:s,y1:mt,x2:s,y2:mt+xt,color:c.axisLineColor,width:1})}if(h.categoryHidden||h.categoryHideTicks||S||!i)continue;if(l){rt.push({x:F.x-8-R,y:s,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"end",baseline:"middle",key:`ct-${t}`});if(E){rt.push({x:F.x+F.width+8+(h.showLabels?P+4:0),y:s,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"start",baseline:"middle",key:`ctm-${t}`})}}else if(V){const i=L(z[t],c.labelSize);const n=V<0?-1:1;rt.push({x:s+n*i*Math.cos(K)/2,y:F.y+F.height+6+R+i*Math.sin(K)/2,text:z[t],color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"middle",rotate:V,key:`ct-${t}`})}else{const i=t+vt<f?Y(t+vt):s+vt*X(t);const n=t-vt>=0?Y(t-vt):s-vt*X(t);const e=Math.min(i-s,s-n)-6;rt.push({x:s,y:F.y+F.height+6+R,text:B(z[t],e,c.labelSize),color:c.textColorMuted,fontSize:c.labelSize,align:"center",baseline:"top",key:`ct-${t}`})}}if(!S){const t=h.categoryLabel;const s=h.valueLabel;if(l){if(t)rt.push({x:4,y:F.y+F.height/2,text:t,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"top",rotate:-90,key:"cat-axis-title"});if(s)rt.push({x:F.x+F.width/2,y:r-2-T,text:s,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",key:"val-axis-title"})}else{if(s)rt.push({x:4,y:F.y+F.height/2,text:s,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"top",rotate:-90,key:"val-axis-title"});if(t)rt.push({x:F.x+F.width/2,y:r-2-T,text:t,color:c.textColor,fontSize:c.labelSize,align:"center",baseline:"bottom",key:"cat-axis-title"})}}const wt=h.legend==="none"||S?[]:h.series.map(((t,s)=>({label:t.label,color:t.color,seriesIndex:s,hidden:t.hidden,x:0,y:0})));return{width:a,height:r,plot:F,background:c.background==="transparent"?undefined:c.background,gridlines:ut,axisLines:dt,areas:[],bars:ct,slices:[],lines:[],markers:[],texts:rt,barLabels:lt,legend:wt,legendPosition:h.legend,xPositions:bt,xValues:h.categories,xLabels:z,barBaseline:J,hoverPoints:at}}function W(t,s,i,n,e,h,c,a){const r=[];const l=t.subtitle?s.labelSize+4:0;const u=t.title?s.titleSize+10+l:0;const x=!!t.legend&&t.legend!=="none"&&t.series.length>1;const m=x&&t.legend.startsWith("bottom");const y=x&&!m&&!(t.legend==="left"||t.legend==="right");const M=x?d(t.series.map((t=>t.label)),s.labelSize,i*.86):1;const p=t.legendExtent!=null&&(y||m)?t.legendExtent+8:M*(s.labelSize+8)+6;const b=y?p:0;const g=m?p:0;const v=t.categoryHidden||t.categoryHideTicks?0:Math.max(0,...c.map((t=>L(t,s.labelSize))))+12;const w={x:v,y:u+b,width:Math.max(1,i-v),height:Math.max(1,n-u-b-g)};const k=w.x+w.width/2;const I=w.y+w.height/2;const A=t.valueTickFormatter??t.valueFormatter;const z=t.valueHidden||t.valueHideTicks?[]:f(h,[],t.valueScale,8).filter((t=>t>=h[0]-1e-9&&t<=h[1]+1e-9));const F=Math.max(0,...z.map((t=>L(A(t),s.labelSize))));const S=z.length?F+18:0;const $=Math.max(8,Math.min(w.width,w.height)/2-8-S);const T=$*Math.max(0,Math.min(.9,t.polarHole??.22));const B=a>0?($-T)/a:$-T;const q=Math.max(1,B*(1-t.categoryGapRatio));const D=-Math.PI/2;const C=2*Math.PI*Math.max(.1,Math.min(1,t.polarSweep??.75));const[R,W]=h;const E=W-R||1;const P=t=>D+(t-R)/E*C;const V=[];const K=[];const N=[];for(let t=0;t<a;t++){const s=$-t*B;N.push(s-q/2)}t.series.forEach(((t,s)=>{if(t.hidden)return;const i={};for(let n=0;n<a;n++){const o=e[s][n];if(!o)continue;const h=$-n*B;const c=h-q;const a=P(o[0]);const r=P(o[1]);if(Math.abs(r-a)<1e-6)continue;V.push({cx:k,cy:I,innerR:c,outerR:h,startAngle:Math.min(a,r),endAngle:Math.max(a,r),color:t.pointColors?.[n]??t.color,dataIndex:n,seriesIndex:s,pill:true,capStart:false,capEnd:false});const l=(a+r)/2;const f=(c+h)/2;i[n]={x:k+f*Math.cos(l),y:I+f*Math.sin(l),value:typeof t.data?.[n]==="number"?t.data[n]:o[1]}}K.push({seriesIndex:s,color:t.color,label:t.label,byIndex:i,values:t.data??[]})}));for(let t=0;t<a;t++){const s=V.filter((s=>s.dataIndex===t));if(!s.length)continue;let i=s[0];let n=s[0];for(const t of s){if(t.startAngle<i.startAngle)i=t;if(t.endAngle>n.endAngle)n=t}i.capStart=true;n.capEnd=true}const _=$+16;for(const t of z){const i=P(t);const n=Math.cos(i);const e=Math.sin(i);r.push({x:k+_*n,y:I+_*e,text:A(t),color:s.textColorMuted,fontSize:s.labelSize,align:n>.35?"start":n<-.35?"end":"center",baseline:e>.35?"top":e<-.35?"bottom":"middle",key:`vt-${t}`})}if(!t.categoryHidden&&!t.categoryHideTicks){for(let t=0;t<a;t++){r.push({x:k-q/2-12,y:I-N[t],text:c[t],color:s.textColorMuted,fontSize:s.labelSize,align:"end",baseline:"middle",key:`ct-${t}`})}}if(t.title){const i=o(t.titleAlign,w.x,w.width);r.push({x:i.x,y:b+6,text:t.title,color:s.textColor,fontSize:s.titleSize,fontWeight:600,align:i.align,baseline:"top",key:"title"});if(t.subtitle){r.push({x:i.x,y:b+6+s.titleSize+6,text:t.subtitle,color:s.textColorMuted,fontSize:s.labelSize,align:i.align,baseline:"top",key:"subtitle"})}}const j=t.legend==="none"?[]:t.series.map(((t,s)=>({label:t.label,color:t.color,seriesIndex:s,hidden:t.hidden,x:0,y:0})));return{width:i,height:n,plot:w,background:s.background==="transparent"?undefined:s.background,gridlines:[],axisLines:[],areas:[],bars:[],slices:V,lines:[],markers:[],texts:r,legend:j,legendPosition:t.legend,polar:true,xPositions:N,xValues:t.categories,xLabels:c,hoverPoints:K}}function E(t,s,i){const n=t-i.cx;const e=s-i.cy;const o=Math.hypot(n,e);if(o<i.innerR||o>i.outerR)return false;const h=Math.min(i.startAngle,i.endAngle);const c=Math.max(i.startAngle,i.endAngle);const a=Math.PI*2;let r=(Math.atan2(e,n)-h)%a;if(r<0)r+=a;return r<=c-h}function P(t,s,i){for(const n of t)if(n.endAngle!==n.startAngle&&E(s,i,n))return n;return null}const V=.62;const K=200;const N=220;const _=(t,s)=>`${t}:${s??-1}`;function j(t,s,i){return{...t,slices:t.slices.map((t=>{const n=s.get(_(t.dataIndex,t.seriesIndex))??0;return n>.002?{...t,color:S(t.color,i,V*n)}:t}))}}const G=(t,s,i)=>t+(s-t)*i;const H=260;function O(t){const s=(t.xValues??[]).map((t=>t==null?"":String(t)));const i=s.length>0&&new Set(s).size===s.length;return i?t=>`${t.seriesIndex}::${s[t.dataIndex]??t.dataIndex}`:t=>`${t.seriesIndex}#${t.dataIndex}`}function Z(t,s){return O(t)(s)}function J(t){const s=O(t);const i=new Map;return t.bars.map((t=>{const n=s(t);const e=i.get(n)??0;i.set(n,e+1);return e===0?n:`${n}~${e}`}))}function U(t){const s=J(t);const i=new Map;t.bars.forEach(((t,n)=>i.set(s[n],t)));return i}function Q(t,s,i){return{...s,x:G(t.x,s.x,i),y:G(t.y,s.y,i),w:G(t.w,s.w,i),h:G(t.h,s.h,i)}}function X(t,s){if(t.bars.length!==s.bars.length)return true;const i=U(t);for(const t of s.bars){const n=i.get(Z(s,t));if(!n)return true;if(Math.abs(n.x-t.x)>.5||Math.abs(n.y-t.y)>.5||Math.abs(n.w-t.w)>.5||Math.abs(n.h-t.h)>.5)return true}return false}class Y{constructor(t){this.container=t;this.ctx=null;this.spec=null;this.theme=null;this.scene=null;this.cb={};this.hoverRaf=0;this.lastHoverIndex=-2;this.hoverEnabled=true;this.clickable=false;this.hoverOpts={};this.hasRendered=false;this.introRaf=0;this.lastDpr=1;this.followRaf=0;this.followLast=0;this.hoverSlice=null;this.dimAnim=new Map;this.dimRaf=0;this.dimLast=0;this.lastPointer={x:0,y:0};this.tooltipTimer=0;this.tooltipShown=false;this.displayed=null;this.pendingDrill=null;this.drillArmRaf=0;this.lastW=0;this.lastH=0;this.dprWatch=m((()=>this.render()));this.rtl=false;this.dirWatch=y((()=>{if(b(this.container)!==this.rtl)this.render()}));this.followStep=t=>{if(!this.scene){this.followRaf=0;return}const s=this.followLast?t-this.followLast:16;this.followLast=t;const i=this.renderFollow(Math.min(1,s/H));this.followRaf=i?requestAnimationFrame(this.followStep):0};this.stepDim=t=>{if(!this.scene||!this.theme){this.dimRaf=0;return}const s=this.dimLast?t-this.dimLast:16;this.dimLast=t;let i=false;for(const t of this.scene.slices){const n=_(t.dataIndex,t.seriesIndex);const e=this.dimTarget(t);const o=this.dimAnim.get(n)??0;let h=o+Math.sign(e-o)*(s/K);if((e-o)*(e-h)<=0)h=e;this.dimAnim.set(n,h);if(h!==e)i=true}this.drawGeometry(j(this.scene,this.dimAnim,this.theme.surface),this.lastDpr);this.dimRaf=i?requestAnimationFrame(this.stepDim):0};this.handlePointerMove=t=>{if(!this.scene||!this.spec||!this.hoverEnabled)return;const s=this.canvas.getBoundingClientRect();const i=t.clientX-s.left;const n=t.clientY-s.top;if(this.spec.polar){const t=P(this.scene.slices,i,n);const s=t?{dataIndex:t.dataIndex,seriesIndex:t.seriesIndex??-1}:null;this.lastPointer={x:i,y:n};if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.hoverRaf=requestAnimationFrame((()=>{this.hoverRaf=0;if(!this.scene||!this.spec||!this.theme)return;this.canvas.style.cursor=s?"pointer":"";const t=s?.dataIndex!==this.hoverSlice?.dataIndex||s?.seriesIndex!==this.hoverSlice?.seriesIndex;if(t){this.hoverSlice=s;this.startDim();this.armTooltip(s)}else if(this.tooltipShown&&s){this.showPolarTooltip(s)}const i=s?s.dataIndex:-1;if(i!==this.lastHoverIndex){this.lastHoverIndex=i;this.cb.onHover?.(i)}}));return}const e=$(this.scene.xPositions,this.spec.horizontal?n:i);if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.hoverRaf=requestAnimationFrame((()=>{this.hoverRaf=0;if(!this.scene||!this.spec||!this.theme)return;this.canvas.style.cursor=this.clickable&&this.overBar(i,n)?"pointer":"";M(this.hoverLayer,this.scene,e,this.spec.valueFormatter,this.theme.fontFamily,{x:i,y:n},this.spec.horizontal?"horizontal":"vertical",-1,this.hoverOpts);if(e!==this.lastHoverIndex){this.lastHoverIndex=e;this.cb.onHover?.(e)}}))};this.handlePointerLeave=()=>{if(this.hoverRaf){cancelAnimationFrame(this.hoverRaf);this.hoverRaf=0}this.canvas.style.cursor="";p(this.hoverLayer);if(this.spec?.polar&&this.scene){clearTimeout(this.tooltipTimer);this.tooltipShown=false;this.canvas.style.cursor="";if(this.hoverSlice){this.hoverSlice=null;this.startDim()}}if(this.lastHoverIndex!==-1){this.lastHoverIndex=-1;this.cb.onHover?.(-1)}};this.handleClick=t=>{if(!this.scene||!this.cb.onPointClick)return;const s=this.canvas.getBoundingClientRect();const i=t.clientX-s.left;const n=t.clientY-s.top;for(const s of this.scene.bars){if(i>=s.x&&i<=s.x+s.w&&n>=s.y&&n<=s.y+s.h){this.cb.onPointClick(s.seriesIndex,s.dataIndex,t);return}}};this.onLegendToggle=t=>{if(this.spec){this.spec.series[t.seriesIndex].hidden=!this.spec.series[t.seriesIndex].hidden;this.hasRendered=false;this.render();this.cb.onLegendClick?.({...t,hidden:this.spec.series[t.seriesIndex].hidden})}else{this.cb.onLegendClick?.(t)}};if(getComputedStyle(t).position==="static")t.style.position="relative";this.canvas=document.createElement("canvas");this.canvas.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block";this.canvas.setAttribute("part","plot-canvas");this.overlay=document.createElement("div");this.overlay.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";this.legendLayer=document.createElement("div");this.legendLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:visible";this.barLabelLayer=document.createElement("div");this.barLabelLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";this.hoverLayer=document.createElement("div");this.hoverLayer.style.cssText="position:absolute;inset:0;pointer-events:none;overflow:hidden";t.append(this.canvas,this.overlay,this.legendLayer,this.barLabelLayer,this.hoverLayer);this.ctx=this.canvas.getContext("2d");this.canvas.addEventListener("pointermove",this.handlePointerMove);this.canvas.addEventListener("pointerleave",this.handlePointerLeave);this.canvas.addEventListener("click",this.handleClick)}getScene(){return this.scene}setHoverEnabled(t){this.hoverEnabled=t;if(!t)p(this.hoverLayer)}setClickable(t){this.clickable=t;if(!t)this.canvas.style.cursor=""}overBar(t,s){return!!this.scene?.bars.some((i=>t>=i.x&&t<=i.x+i.w&&s>=i.y&&s<=i.y+i.h))}setTooltip(t){this.hoverOpts=t}setSpec(t,s,i={},n={}){this.spec=t;this.theme=s;this.cb=i;this.render(n)}resize(){const t=this.container.getBoundingClientRect();if(Math.round(t.width)===this.lastW&&Math.round(t.height)===this.lastH)return;this.render()}toDataURL(t="image/png"){return typeof this.canvas.toDataURL==="function"?this.canvas.toDataURL(t):""}dispose(){if(this.hoverRaf)cancelAnimationFrame(this.hoverRaf);this.stopIntro();cancelAnimationFrame(this.drillArmRaf);cancelAnimationFrame(this.dimRaf);cancelAnimationFrame(this.followRaf);clearTimeout(this.tooltipTimer);this.canvas.removeEventListener("pointermove",this.handlePointerMove);this.canvas.removeEventListener("pointerleave",this.handlePointerLeave);this.canvas.removeEventListener("click",this.handleClick);this.dprWatch.dispose();this.dirWatch.dispose();this.canvas.remove();this.overlay.remove();this.barLabelLayer.remove();this.hoverLayer.remove();this.spec=null;this.scene=null}render(t={}){if(!this.spec||!this.theme)return;this.dprWatch.update();const s=this.container.getBoundingClientRect();const i=Math.round(s.width);const n=Math.round(s.height);if(i<2||n<2)return;const e=this.scene;const o=i!==this.lastW||n!==this.lastH;this.lastW=i;this.lastH=n;const h=Math.min(window.devicePixelRatio||1,4);this.lastDpr=h;this.hoverSlice=null;this.dimAnim.clear();cancelAnimationFrame(this.dimRaf);this.dimRaf=0;if(this.hoverRaf){cancelAnimationFrame(this.hoverRaf);this.hoverRaf=0}clearTimeout(this.tooltipTimer);this.tooltipShown=false;this.canvas.width=i*h;this.canvas.height=n*h;const c=this.scene?.xPositions.length??0;this.rtl=b(this.container);const a=()=>{const t=R(this.spec,this.theme,i,n);return this.rtl?F(t):t};this.scene=a();if(this.lastHoverIndex>=0){if(this.lastHoverIndex<this.scene.xPositions.length&&c===this.scene.xPositions.length){this.focusIndexInternal(this.lastHoverIndex)}else{p(this.hoverLayer);this.lastHoverIndex=-1}}g(this.overlay,this.scene,this.theme.fontFamily,{onLegendClick:this.onLegendToggle},this.rtl,this.legendLayer);const r=this.legendLayer.querySelector('[part="legend"]');if(r&&this.spec.legend&&this.spec.legend!=="none"){const t=this.spec.legend==="left"||this.spec.legend==="right";const s=t?r.offsetWidth:r.offsetHeight;if(s>0&&Math.abs((this.spec.legendExtent??-1)-s)>2){this.spec.legendExtent=s;this.scene=a();g(this.overlay,this.scene,this.theme.fontFamily,{onLegendClick:this.onLegendToggle},this.rtl,this.legendLayer)}}const{variant:l,duration:f}=w(this.spec);const u=this.pendingDrill;const d=v();const x=l!=="none"&&!d;const m=this.scene.bars.length>0||this.scene.slices.length>0;const y=!this.hasRendered&&x;if(u&&x){this.hasRendered=true;this.playDrill(h,u,f);return}if(y){this.hasRendered=m;this.playIntro(h,l,f);return}this.hasRendered=this.hasRendered||m;const M=!!e&&X(e,this.scene);if(t.animate!==false&&!d&&!o&&e&&(M||this.followRaf)){this.stopIntro();this.ensureFollow();return}this.stopIntro();cancelAnimationFrame(this.followRaf);this.followRaf=0;this.paint(this.scene,h);this.displayed=U(this.scene)}drill(t,s="down"){const i=this.scene;if(!i)return;const n=!!this.spec?.horizontal;if(s==="up"){this.arm(n?{from:i.plot.y,size:i.plot.height,split:false}:{from:i.plot.x,size:i.plot.width,split:false});return}const e=i.bars.filter((s=>s.dataIndex===t));if(!e.length){this.arm(null);return}const o=Math.min(...e.map((t=>n?t.y:t.x)));const h=Math.max(...e.map((t=>n?t.y+t.h:t.x+t.w)));this.arm({from:o,size:Math.max(1,h-o),split:true})}arm(t){this.pendingDrill=t;cancelAnimationFrame(this.drillArmRaf);if(!t)return;this.drillArmRaf=requestAnimationFrame((()=>{this.pendingDrill=null}))}clearIntroOpacity(){this.canvas.style.opacity="";this.barLabelLayer.style.opacity=""}stopIntro(){cancelAnimationFrame(this.introRaf);this.introRaf=0;this.clearIntroOpacity()}playDrill(t,s,i){const n=this.scene;if(!n)return;this.stopIntro();this.paint(k(n,s.from,s.size,0,s.split),t);let e=0;const o=h=>{if(!e)e=h;const c=(h-e)/i;if(c>=1){this.displayed=U(n);this.paint(n,t);return}this.paint(k(n,s.from,s.size,c,s.split),t);this.introRaf=requestAnimationFrame(o)};this.introRaf=requestAnimationFrame(o)}replay(){this.hasRendered=false;this.render()}drawGeometry(t,s){if(this.ctx){this.ctx.setTransform(s,0,0,s,0,0);I(this.ctx,t)}}paint(t,s){this.drawGeometry(t,s);A(this.barLabelLayer,t,this.theme?.fontFamily)}playIntro(t,s,i){const n=this.scene;if(!n)return;this.stopIntro();const e=t=>{const s=t<1?String(t):"";this.canvas.style.opacity=s;this.barLabelLayer.style.opacity=s};const o=z(s,n,0);e(o.alpha);this.paint(o.scene,t);let h=0;const c=o=>{if(!h)h=o;const a=(o-h)/i;if(a>=1){e(1);this.displayed=U(n);this.paint(n,t);return}const{scene:r,alpha:l}=z(s,n,a);e(l);this.paint(r,t);this.introRaf=requestAnimationFrame(c)};this.introRaf=requestAnimationFrame(c)}ensureFollow(){if(!this.scene)return;if(v()){cancelAnimationFrame(this.followRaf);this.followRaf=0;this.displayed=U(this.scene);this.paint(this.scene,this.lastDpr);return}const t=this.renderFollow(0);if(t&&!this.followRaf){this.followLast=0;this.followRaf=requestAnimationFrame(this.followStep)}}renderFollow(t){const s=this.scene;if(!s)return false;const i=J(s);const n=this.displayed??U(s);const e=new Map;const o=[];let h=false;s.bars.forEach(((s,c)=>{const a=i[c];const r=n.get(a);const l=r?Q(r,s,t):s;e.set(a,l);o.push(l);if(Math.abs(l.x-s.x)>.3||Math.abs(l.y-s.y)>.3||Math.abs(l.w-s.w)>.3||Math.abs(l.h-s.h)>.3)h=true}));this.displayed=e;this.paint({...s,bars:o},this.lastDpr);return h}focusIndex(t){this.lastHoverIndex=t;this.focusIndexInternal(t)}focusIndexInternal(t){if(!this.scene||!this.spec||!this.theme)return;if(this.spec.polar){const s=t<0?null:{dataIndex:t,seriesIndex:-1};if(s?.dataIndex!==this.hoverSlice?.dataIndex||s?.seriesIndex!==this.hoverSlice?.seriesIndex){this.hoverSlice=s;this.startDim()}}if(t<0){p(this.hoverLayer);return}const s=!!this.spec.horizontal;const i=this.scene.hoverPoints.map((s=>s.byIndex[t])).find(Boolean);const n=this.scene.xPositions[t]??0;const e=i?{x:i.x,y:i.y}:{x:s?this.scene.plot.x:n,y:s?n:this.scene.plot.y};M(this.hoverLayer,this.scene,t,this.spec.valueFormatter,this.theme.fontFamily,e,this.spec.polar?"none":s?"horizontal":"vertical",-1,this.hoverOpts)}dimTarget(t){const s=this.hoverSlice;if(!s)return 0;if(s.seriesIndex<0)return t.dataIndex===s.dataIndex?0:1;return t.dataIndex===s.dataIndex&&t.seriesIndex===s.seriesIndex?0:1}startDim(){if(!this.scene||!this.theme)return;if(v()){cancelAnimationFrame(this.dimRaf);this.dimRaf=0;for(const t of this.scene.slices)this.dimAnim.set(_(t.dataIndex,t.seriesIndex),this.dimTarget(t));this.drawGeometry(j(this.scene,this.dimAnim,this.theme.surface),this.lastDpr);return}if(!this.dimRaf){this.dimLast=0;this.dimRaf=requestAnimationFrame(this.stepDim)}}armTooltip(t){clearTimeout(this.tooltipTimer);p(this.hoverLayer);this.tooltipShown=false;if(!t)return;this.tooltipTimer=window.setTimeout((()=>{const s=this.hoverSlice;if(s&&s.dataIndex===t.dataIndex&&s.seriesIndex===t.seriesIndex){this.showPolarTooltip(t);this.tooltipShown=true}}),N)}showPolarTooltip(t){if(!this.scene||!this.spec||!this.theme)return;M(this.hoverLayer,this.scene,t.dataIndex,this.spec.valueFormatter,this.theme.fontFamily,this.lastPointer,"none",t.seriesIndex,{...this.hoverOpts,trigger:"item"})}}export{Y as B};
|
|
2
|
+
//# sourceMappingURL=p-Bx6--dQF.js.map
|