@motionscript/charts 0.1.0 → 0.1.1-alpha.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 +19 -0
- package/dist/bar-chart/bar-chart.d.ts +22 -93
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +48 -121
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +11 -38
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +15 -38
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +43 -74
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +31 -59
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -10
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +0 -7
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +27 -90
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +15 -54
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-4SMRCU24.js +2 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +4 -16
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +4 -16
- package/dist/engine.js.map +1 -1
- package/dist/kit/cartesian.d.ts +8 -28
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +7 -19
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-border.d.ts +9 -18
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +4 -9
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +25 -36
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +13 -13
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +14 -61
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +17 -65
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +2 -0
- package/dist/kit/entries.d.ts.map +1 -1
- package/dist/kit/entries.js +2 -0
- package/dist/kit/entries.js.map +1 -1
- package/dist/kit/motion.d.ts +11 -3
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +7 -1
- package/dist/kit/motion.js.map +1 -1
- package/dist/kit/shared.d.ts +60 -175
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +40 -157
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +16 -45
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +17 -42
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +16 -41
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +14 -43
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -27
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +8 -22
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +16 -43
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +13 -42
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +1 -13
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +0 -12
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +23 -109
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +45 -141
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +33 -107
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +28 -81
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +14 -55
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +29 -111
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +0 -12
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -12
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +1 -12
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +0 -9
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +37 -71
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +31 -65
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +11 -26
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +14 -39
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +50 -192
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +75 -247
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +45 -131
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +29 -72
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +4 -4
- package/src/bar-chart/bar-chart.ts +51 -165
- package/src/bar-chart/category-axis.ts +16 -57
- package/src/bar-chart/chart-bars.ts +43 -120
- package/src/bar-chart/index.ts +2 -10
- package/src/bar-chart/shared.ts +29 -97
- package/src/engine.ts +4 -16
- package/src/kit/cartesian.ts +11 -26
- package/src/kit/chart-border.ts +6 -20
- package/src/kit/chart-canvas.ts +15 -40
- package/src/kit/chart-legend.ts +17 -86
- package/src/kit/entries.ts +4 -1
- package/src/kit/motion.ts +11 -2
- package/src/kit/shared.ts +58 -219
- package/src/kit/vertical-axis.ts +18 -71
- package/src/line-chart/chart-line.ts +16 -44
- package/src/line-chart/chart-region.ts +10 -23
- package/src/line-chart/horizontal-axis.ts +13 -42
- package/src/line-chart/index.ts +1 -13
- package/src/line-chart/line-chart.ts +50 -184
- package/src/line-chart/shared.ts +51 -145
- package/src/line-chart/x-scale.ts +31 -121
- package/src/nodes.ts +0 -12
- package/src/pie-chart/index.ts +1 -12
- package/src/pie-chart/pie-chart.ts +34 -102
- package/src/pie-chart/pie-legend.ts +14 -55
- package/src/pie-chart/pie-ring.ts +80 -307
- package/src/pie-chart/shared.ts +50 -139
- package/dist/browser/chunks/chunk-TJNHLQGV.js +0 -2
- package/dist/browser/chunks/chunk-TJNHLQGV.js.map +0 -7
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as Te,A as xe,B as $,C as j,D as ye,E as be,F as K,G as q,H as Gt,I as Ht,J as we,K as Se,L as Ut,M as Nt,N as Vo,O as F,P as Ae,Q as $e,R as L,S as ue,T as ke,U as Xt,V as I,W as Wo,X as ve,Y as Ee,Z as Re,_ as D,a as f,aa as Le,b as z,ba as Z,c as b,ca as Yo,d as S,e as Uo,f as V,g as w,h as N,i as P,j as W,k as ae,l as No,m as le,n as ce,o as v,p as Xo,q as O,r as x,s as A,t as Y,u as zo,v as R,w as ge,x as me,y as T,z as Bt}from"./chunks/chunk-TJNHLQGV.js";import{Rect as En,Types as G,component2d as Rn,easeOut as B}from"@motionscript/sdk";import{formatNumber as Tn}from"@motionscript/sdk/component";import{Graphics2D as et,Types as tt,component2d as fn,strokeOps as Yt}from"@motionscript/sdk";import{Fills as sn,fillOps as zt,lerpNumber as an,strokeOps as Vt}from"@motionscript/sdk";var J={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function Q(e){return e.right>e.left&&e.top>e.bottom}function je(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return J;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let y=Math.min(d[0],d[1]),U=Math.max(d[0],d[1]),k=Ye=>g+(Ye-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,k(y))),Math.max(g,Math.min(p,k(U))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Ke(e,t){if(e.length<2||!Q(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=cn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&ln(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function ln(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function cn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var un={...T,markerStyle:{...T.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:R,yAxis:ge,plotArea:me,legend:un,region:{stroke:{weight:3,fill:v.regionColor,dash:[14,12],cap:"butt"},fill:sn.color(v.regionColor,{opacity:.08}),dimOpacity:O}};function dn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:zt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function hn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:zt.lerp(e.fill,t.fill,r),dimOpacity:an(e.dimOpacity,t.dimOpacity,r)}}function qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),region:dn(e?.region,r.region)}}function Ze(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),region:hn(e.region,t.region,r)}}function Je(e,t,r){return e.map((n,o)=>[t.at(o),A(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Wt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=A(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function Qe(e,t,r,n){if(r)return r;let[o,i]=Wt(e,t),s=Math.max(1,Math.round(n));if(i===o)return pn(o,s);let a=ue((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function pn(e,t){if(e===0)return[0,1];let r=ue(Math.abs(e)/t);return[e-r,e+r]}function gn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var Me=fn({key:"chartLine",state:{points:f(()=>[]),stroke:tt.custom([],{resolve:Yt.resolve,lerp:Yt.lerp}),progress:1,enabled:!0,spotlight:f(()=>J),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:tt.number(0,{min:0,max:1}),to:tt.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=b(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=gn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!Q(a)){e.draw(new et().line({points:o,radius:s}).stroke(i));return}e.draw(new et().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Ke(o,a))e.draw(new et().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as $t,Types as jt,component2d as mn,fillOps as Kt,strokeOps as qt}from"@motionscript/sdk";var rt=mn({key:"chartRegion",state:{box:f(()=>J),stroke:jt.custom(X.region.stroke,{resolve:qt.resolve,lerp:qt.lerp}),fill:jt.custom(X.region.fill,{resolve:Kt.resolve,lerp:Kt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!Q(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new $t().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new $t().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Zt,Text as Jt,Types as nt,component2d as xn,insetsOps as Qt,textOps as er}from"@motionscript/sdk";var yn=24,Ce=xn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:nt.custom(R),label:"",arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=Qt.resolve(e.axis.tickPadding).top,r=Qt.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Jt({...er.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":Xt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>w(e.arrivals,u).opacity,y:()=>w(e.arrivals,u).shift});return d}),c=[new Zt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Jt({...er.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new Zt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:nt.custom(void 0),slide:nt.number(yn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=t.markers.map((p,y)=>({at:y*l,duration:u,piece:P(e,y,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...m,...g])])}}}});import{formatNumber as bn}from"@motionscript/sdk/component";var _e=864e5,ir=["january","february","march","april","may","june","july","august","september","october","november","december"],tr=2024;function rr(e){return e.length<3?-1:ir.findIndex(t=>t.startsWith(e))}function wn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*_e+(t-1)*7*_e}function ar(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:wn(n[1]===void 0?tr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=rr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?tr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=rr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function lr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ir[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*_e?String(n):t>60*_e?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function Sn(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function An(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=ar(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function nr(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function or(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return L([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of L([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function kn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var sr=new WeakMap;function ot(e,t,r){let n=sr.get(e);n||sr.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=vn(e,t,r)),i}function vn(e,t,r){if(t!==""&&Sn(e,t)){let s=e.map(a=>A(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:nr(s),label:a=>r===void 0?F(a):bn(a,r),ticks:L}}let n=e.map(s=>Y(s,t)),o=t===""?null:An(e,t);if(o){let s=nr(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>kn(o,n,c,l=>lr(l,a)),ticks:(c,l)=>or(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>or(i,s,a)}}var st=G.custom(0,{kind:"series",min:0,step:1}),cr=G.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Ln=20,it=5,Mn=.35,Cn=.5,_n=.15;function lt(e,t=e.xAxis.format){return ot(e.data,e.xField,t)}function Pn(e,t){let r=lt(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,it-1)}}function On(e,t){let r=(t.ticks?.length??it)-1,n=Qe(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,it-1)}}var ur=new WeakMap;function Pe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=ur.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:ce(n,c=>Pn(e,c)),y:ce(o,c=>On(e,c))};return ur.set(t,{xField:r,xAxis:n,yAxis:o,series:i,domains:a}),a}function Fn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=Je(e.data,lt(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function dr(e,t,r){let{width:n,height:o}=r;return je(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function hr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function pr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function fr(e,t){let r=In(e);return{range:r,ticks:L(r,Math.max(2,t.length)-1)}}function gr(e,t,r){return{...t.x&&{xAxis:ae(e.x,t.x,r)},...t.y&&{yAxis:ae(e.y,t.y,r)}}}function at(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Ce.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(Me.is),legend:t.below.find(Z.is)??null}}function mr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function xr(e,t,r,n){let o=at(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ct=Rn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:G.custom({},{resolve:W,lerp:le}),yAxis:G.custom({},{resolve:W,lerp:le}),theme:G.custom(X,{resolve:qe,lerp:Ze}),region:G.custom(null),regionReveal:0,showLegend:G.boolean(!0,{animatable:!1}),home:G.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Pe(e),n,o=()=>Re(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ae(d)):Tn(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Ce({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=lt(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Me({points:()=>Fn(e,r(),h,o()),stroke:()=>Ut(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>dr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>Nt(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new En({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new rt({box:()=>dr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.duration,i=hr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*Mn,c=s*Cn,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return S(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-Ln}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*_n,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?mr(e,t):n<=0||!hr(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>mr(e,t)},zoomTo:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Pe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...fr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...fr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...gr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Pe(t);return e.animate(o=>({home:null,...gr(n,r,o)}))}},showSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:O})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as qn,Types as C,component2d as Zn,easeOut as ee}from"@motionscript/sdk";import{formatNumber as Jn}from"@motionscript/sdk/component";import{Rect as ut,Text as yr,Types as dt,component2d as Dn,insetsOps as br,textOps as wr}from"@motionscript/sdk";var Bn=24,Oe=Dn({key:"categoryAxis",state:{categories:f(()=>[]),axis:dt.custom(R),label:"",dims:f(()=>[]),arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=br.resolve(e.axis.tickPadding).top,r=br.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new ut({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[l]??1),x:()=>i(l),children:[new yr({...wr.styleProps(e.axis.labelStyle),text:c,opacity:()=>w(e.arrivals,l).opacity,y:()=>w(e.arrivals,l).shift})]})),a=[new ut({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new yr({...wr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new ut({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:dt.custom(void 0),slide:dt.number(Bn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=(o-1)*l+u,g=t.categories.map((y,U)=>({at:U*l,duration:u,piece:P(e,U,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...g,...p])])}}}});import{Graphics2D as Nn,Text as Xn,Types as Be,component2d as zn,fillOps as Er,shadowOps as Rr,strokeOps as Tr,textOps as Vn}from"@motionscript/sdk";import{fillOps as Gn,lerpNumber as Fe,shadowOps as Sr,strokeOps as Ar,textOps as kr}from"@motionscript/sdk";function Ie(e,t,r){let n=0;return t.map(o=>{let i=A(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function ht(e,t){let r=-1;for(let n=0;n<t.length;n++)A(e,t[n].field)!==0&&(r=n);return r}function pt(e,t){return e.map(r=>Y(r,t))}function vr(e,t,r){let n=0,o=0;for(let i of e)for(let s of Ie(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function ft(e,t,r,n,o){if(n)return n;let[i,s]=vr(e,t,r),a=Math.max(1,Math.round(o)),c=ue((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var M={seriesFills:xe,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...R,labelStyle:{...R.labelStyle,fontWeight:600},tickPadding:16},yAxis:ge,plotArea:me,legend:T,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:v.markerColor},spotlight:{dimOpacity:O}};function Hn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:Ar.resolve(e?.stroke??t.stroke),shadow:Sr.resolve(e?.shadow??t.shadow)}}function Un(e,t,r){return{cornerRadius:Fe(e.cornerRadius,t.cornerRadius,r),slotFill:Fe(e.slotFill,t.slotFill,r),groupGap:Fe(e.groupGap,t.groupGap,r),stroke:Ar.lerp(e.stroke,t.stroke,r),shadow:Sr.lerp(e.shadow,t.shadow,r)}}function gt(e,t){let r=t??M;return{seriesFills:we(e?.seriesFills,r.seriesFills),bar:Hn(e?.bar,r.bar),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),valueStyle:kr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function mt(e,t,r){return{seriesFills:Se(e.seriesFills,t.seriesFills,r),bar:Un(e.bar,t.bar,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),valueStyle:kr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:Fe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function De(e,t,r){return t.fill!=null?Gn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var Wn=10,Yn=1.6,$n=24;function Lr(e,t){return e.enabled?x(e.dims[t]??1):0}function xt(e,t){let r=e.bars[t];if(!r)return null;let n=x(e.growth);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function Mr(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:$n}function Cr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function jn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Cr(e,t)){let n=xt(e,t);if(!n||Math.abs(n.end-n.base)<Mr(e)*Yn)return""}return r.caption??F(r.value)}function Kn(e,t){let r=xt(e,t);if(!r)return 0;if(Cr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(Wn+Mr(e)/2)}var Ge=zn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:Be.custom([],{resolve:Er.resolve,lerp:Er.lerp}),barStroke:Be.custom(M.bar.stroke,{resolve:Tr.resolve,lerp:Tr.lerp}),barShadow:Be.custom(M.bar.shadow,{resolve:Rr.resolve,lerp:Rr.lerp}),cornerRadius:M.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:Be.custom(M.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Xn({...Vn.styleProps(e.valueStyle),text:()=>jn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Kn(e,r),opacity:()=>Lr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=xt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Nn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Lr(t,r)))}e.children()}});var yt=C.custom(0,{kind:"series",min:0,step:1}),Qn=20,_r=5,eo=.35,to=.5,ro=.15;function no(e,t){let r=(t.ticks?.length??_r)-1,n=ft(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,_r-1)}}var Pr=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Pr.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=ce(o,a=>no(e,a));return Pr.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Ir(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ae(t.ticks)):Jn(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function oo(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function de(e,t){return Math.max(0,e.weights[t]??1)}function so(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*de(e,o))}),r}function io(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*x(e.theme.bar.slotFill),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=de(e,p);let h=l/(d>0?d:1),m=de(e,t),g=0;for(let p=0;p<t;p++)g+=de(e,p);return e.data.map((p,y)=>{let k=Ie(e.stacked?so(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ye=e.stacked?ht(p,e.series):t,rn=c(y)-l/2,nn=e.stacked?c(y):rn+h*g+h*m/2,on=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=A(p,o.field);return{x:nn,width:on,from:bt(i,r,k.from),to:bt(i,r,k.to),round:Ye===t,value:Dt,...n&&{caption:Ir(e,i,Dt)}}})}function Or(e){let t=x(e.spotlightReveal),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Oe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ge.is),legend:t.below.find(Z.is)??null}}function Fr(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>de(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=Zn({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:C.custom({},{resolve:W,lerp:le}),categoryAxis:C.custom({},{resolve:W,lerp:ae}),theme:C.custom(M,{resolve:gt,lerp:mt}),growth:1,weights:f(()=>[]),spotlight:C.custom(null),spotlightReveal:0,showLegend:C.boolean(!0,{animatable:!1}),showValues:C.boolean(!1,{animatable:!1}),showing:C.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Re(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Ir(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Oe({categories:pt(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Or(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ge({bars:()=>io(e,h,o(),i),baseline:()=>oo(r(),o()),fill:()=>De(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Or(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>De(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new qn({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*eo,s=o*to,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return S(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-Qn}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*ro,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:C.number(0,{min:0,step:1})},easing:ee(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:ee(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as tn,Types as se,component2d as Fo,easeOut as oe}from"@motionscript/sdk";import{Flow as kt,Paint as he,Rect as vt,Shapes as Dr,Text as ao,Types as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Br=16,He=co({key:"pieLegend",state:{...he.state,...kt.state,...Dr.corners,slices:f(()=>[]),legend:lo.custom(T),dims:f(()=>[]),arrivals:V()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[n]??1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>w(e.arrivals,n).opacity,x:()=>w(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),ao({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...he.commands,arm:(e,t)=>e.animate(()=>({arrivals:N([...t.slices.keys()],{opacity:0,shift:Br})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Br},o=e.animate(()=>({arrivals:N([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=b(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,S(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,he.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,he.inset(t)),render:(e,t)=>he.draw(e,t,Dr.rect(e.size,t))});import{Graphics2D as Ur,PathBuilder as wo,Rect as Ct,Text as re,Types as fe,component2d as So,fillOps as Nr,shadowOps as Ao,strokeOps as Xr,textOps as ne}from"@motionscript/sdk";import{lerpNumber as pe,shadowOps as Gr,strokeOps as Ue,textOps as E}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:Y(o,t),value:A(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var ho=Math.PI/180;function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Hr(e){let t=0;for(let r of e)t+=Tt(r);return t}function te(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ne(e,t){let r=Hr(e);if(r<=0)return[];let n=[],o=t*ho;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function Xe(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:v.markerColor},po=.1,_={sliceFills:xe,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:v.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:v.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:v.markerColor}},legend:T,spotlight:{dimOpacity:po}};function fo(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:Ue.resolve(e?.stroke??t.stroke),shadow:Gr.resolve(e?.shadow??t.shadow)}}function go(e,t,r){return{gap:pe(e.gap,t.gap,r),holeRadius:pe(e.holeRadius,t.holeRadius,r),startAngle:pe(e.startAngle,t.startAngle,r),selectedGrow:pe(e.selectedGrow,t.selectedGrow,r),stroke:Ue.lerp(e.stroke,t.stroke,r),shadow:Gr.lerp(e.shadow,t.shadow,r)}}function mo(e,t){return{textStyle:E.resolveStyle(e?.textStyle,t.textStyle),percentStyle:E.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:E.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:Ue.resolve(e?.leaderStroke??t.leaderStroke)}}function xo(e,t,r){return{textStyle:E.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:E.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:E.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:Ue.lerp(e.leaderStroke,t.leaderStroke,r)}}function yo(e,t){return{labelStyle:E.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:E.resolveStyle(e?.captionStyle,t.captionStyle)}}function bo(e,t,r){return{labelStyle:E.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:E.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??_;return{sliceFills:we(e?.sliceFills,r.sliceFills),ring:fo(e?.ring,r.ring),label:mo(e?.label,r.label),center:yo(e?.center,r.center),legend:K(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:Se(e.sliceFills,t.sliceFills,r),ring:go(e.ring,t.ring,r),label:xo(e.label,t.label,r),center:bo(e.center,t.center,r),legend:q(e.legend,t.legend,r),spotlight:{dimOpacity:pe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var zr=12,ko=14,_t=.62,vo=6,Vr=34,Wr=26,Yr=8,Eo=.18,Ro=240,To=8,$r=2,Zr=.44,Pt=.62,Lo=.78,Mo=.9,jr=.001,Jr=26;function H(e,t=Jr){let r=e.fontSize;return typeof r=="number"?r:t}function Co(e,t,r,n,o,i){let s=new wo,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*Ro)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,y=te(d,g+(p-g)*h/c);return{x:y.x+i,y:y.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var ze=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ne(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>jr?o/s:1/0,l=a>jr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?$e(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Zr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,Jr*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Mo/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*Lo/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:$r,right:$r};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Vr+Wr+Yr+this.captionGlyphs(n.index)*r+ko,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Vr}popOf(t){return x(this.s.pops[t]??0)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=te(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){let r=this.selectionStrength;return r<=0?1:1-(1-x(this.s.dimOpacity))*r*(1-this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return $e(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=te(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return Xe(a,n+zr,o,i),Xe(c,n+zr,o,i),[...a,...c].map(l=>{let u=te(this.anchorRadius(l.index)+vo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Eo),m=s+l.side*(r+Wr);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*Yr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var _o={width:0,height:0},Kr=new WeakMap;function Po(e){if(typeof e!="object"||e===null)return Nr.resolve(e);let t=Kr.get(e);return t===void 0&&Kr.set(e,t=Nr.resolve(e)),t}function qr(e){return e.map(t=>Po(t.fill))}function Oo(e){let t=[],r=()=>new ze(e,t[0]?.parent?.layoutBounds??_o),n=o=>{let i=()=>x(e.labelReveal)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Zr})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new re({...ne.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new re({...ne.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ne(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new re({...ne.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new re({...ne.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>x(e.centerReveal),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var Ve=So({key:"pieRing",state:{slices:f(()=>[]),ring:fe.custom(_.ring),label:fe.custom(_.label),centerStyle:fe.custom(_.center),labelMode:fe.custom("percent"),labelPlacement:fe.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:_.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Oo(e),load:(e,t)=>D(e,{fills:qr(t.slices),shadows:[Ao.resolve(t.ring.shadow)],strokes:[Xr.resolve(t.ring.stroke),Xr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=b(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=b(e),n=x(t.centerReveal);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new ze(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=x(t.growth),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=qr(t.slices);for(let p of o){let y=Math.min(p.a1,s);if(y<=p.a0)continue;let U=Co(p.a0,y,a,r.anchorRadius(p.index),c,l),k=new Ur().path(U.toPathState({centerBounds:d,width:h,height:h}));k.shadow(t.ring.shadow),k.fill(m[p.index]??[]),k.stroke(t.ring.stroke),e.draw(k.opacity(r.sliceOpacity(p.index)))}let g=x(t.labelReveal);if(g>.001)for(let p of r.placements())e.draw(new Ur().line({points:p.leader,radius:To}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Io=.65,Do=.35,Ft=se.number(0,{min:0,step:1});function Qr(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ie(e,t){return x(e.pops[t]??0)}function Bo(e,t){return ie(e,t)>.5}function Go(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ie(e,n));let r=e.theme.spotlight.dimOpacity;return t<=0?e.data.map(()=>1):e.data.map((n,o)=>1-(1-x(r))*t*(1-ie(e,o)))}function We(e,t,r){let n=t.data.map((i,s)=>ie(t,s)),o=t.data.map((i,s)=>x(r(s)));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function en(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=tn.is(r)?r.children.find(Ve.is):void 0;if(n)return{ring:n,legend:r.children.find(He.is)??null}}return null}var It=Fo({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:se.custom(_,{resolve:Lt,lerp:Mt}),labelMode:se.custom("percent"),labelPlacement:se.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:se.boolean(!0,{animatable:!1}),showCenter:se.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>Qr(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Qr(e),n=[new Ve({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new He({slices:r,legend:()=>t().legend,dims:()=>Go(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new tn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:oe(),run:(e,t,r)=>{let n=en(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Io,a=e.duration*Do,c=l=>({at:0,duration:0,piece:l});return S(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:oe(),run:(e,t,r)=>en(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:ie(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?0:ie(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:oe(),run:(e,t)=>We(e,t,()=>0)}}});var Ho=[ct,At,It];export{At as BarChart,v as CHART_PALETTE,Oe as CategoryAxis,Ge as ChartBars,Te as ChartBorder,Le as ChartCanvas,Z as ChartLegend,Me as ChartLine,rt as ChartRegion,M as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,T as DEFAULT_LEGEND,_ as DEFAULT_PIE_CHART_THEME,me as DEFAULT_PLOT_AREA,Xo as DEFAULT_SERIES_COLORS,xe as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,R as DEFAULT_X_AXIS,ge as DEFAULT_Y_AXIS,J as EMPTY_REGION_BOX,Ce as HorizontalAxis,Uo as LANDED,ct as LineChart,Ho as NODES,It as PieChart,He as PieLegend,Ve as PieRing,O as SPOTLIGHT_DIM,Wo as TOP_HEADROOM,I as VerticalAxis,N as armed,P as arrival,w as arrivalOf,V as arrivalsEntry,z as asParts,No as axisTweenTarget,pt as barCategories,St as barChartDomain,Ie as barSpans,vr as barValueExtent,S as beats,ve as cartesianFrame,Ee as cartesianViews,x as clampUnit,Ke as clipPolylineToBox,ke as enterBudget,lr as formatInstant,F as formatMarker,$e as formatPercent,b as frameEase,f as fresh,Q as hasRegion,Bo as isSliceSelected,Re as laidOutSize,Yo as legendShows,j as lerpAxisConfig,ae as lerpAxisDomain,le as lerpAxisEntry,mt as lerpBarChartTheme,Ze as lerpChartTheme,q as lerpLegendConfig,Mt as lerpPieChartTheme,be as lerpPlotArea,Se as lerpSeriesFills,Ht as lerpSeriesStrokes,Pe as lineChartDomains,D as loadPaints,Xt as markerCaption,Ae as markerStep,L as markerValues,ue as niceStep,A as num,zo as numericFields,ar as parseInstant,Ne as pieArcs,Xe as relaxLabels,$ as resolveAxisConfig,W as resolveAxisDomain,gt as resolveBarChartTheme,De as resolveBarFill,ft as resolveBarScale,qe as resolveChartTheme,K as resolveLegendConfig,Vo as resolvePalettePaint,Lt as resolvePieChartTheme,Rt as resolvePieSlices,ye as resolvePlotArea,je as resolveRegionBox,Nt as resolveSeriesFill,we as resolveSeriesFills,Ut as resolveSeriesStroke,Gt as resolveSeriesStrokes,ot as resolveXScale,Qe as resolveYScale,te as ringPoint,Je as seriesPoints,ce as settleAxisDomain,Hr as sliceTotal,Tt as sliceValue,ht as stackCapIndex,Y as text,Wt as yExtent};
|
|
1
|
+
import{A as Bt,B as we,C as K,D as q,E as Se,F as Ae,G as Z,H as J,I as Gt,J as Ht,K as ke,L as ve,M as Nt,N as Ut,O as F,P as Ee,Q as qe,R as T,S as zt,T as I,U as Re,V as Te,W as Le,X as D,Y as Me,Z as Ce,_ as Q,a as f,b as W,c as C,d as xe,e as U,f as _,g as y,h as w,i as Y,j as b,k as z,l as P,m as $,n as ue,o as de,p as he,q as k,r as Uo,s as O,t as S,u as j,v as zo,w as E,x as ye,y as be,z as R}from"./chunks/chunk-4SMRCU24.js";import{Rect as Mn,Types as V,component2d as Cn,easeOut as B}from"@motionscript/sdk";import{formatNumber as _n}from"@motionscript/sdk/component";import{Graphics2D as nt,Types as ot,component2d as xn,strokeOps as $t}from"@motionscript/sdk";import{Fills as cn,fillOps as Xt,lerpNumber as un,strokeOps as Vt}from"@motionscript/sdk";import{niceStep as Wt}from"@motionscript/sdk/component";var ee={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function te(e){return e.right>e.left&&e.top>e.bottom}function Ze(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return ee;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let x=Math.min(d[0],d[1]),N=Math.max(d[0],d[1]),A=Ke=>g+(Ke-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,A(x))),Math.max(g,Math.min(p,A(N))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Je(e,t){if(e.length<2||!te(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=hn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&dn(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function dn(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function hn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var pn={...R,markerStyle:{...R.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:E,yAxis:ye,plotArea:be,legend:pn,region:{stroke:{weight:3,fill:k.regionColor,dash:[14,12],cap:"butt"},fill:cn.color(k.regionColor,{opacity:.08}),dimOpacity:O}};function fn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:Xt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function gn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:Xt.lerp(e.fill,t.fill,r),dimOpacity:un(e.dimOpacity,t.dimOpacity,r)}}function Qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),region:fn(e?.region,r.region)}}function et(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),region:gn(e.region,t.region,r)}}function tt(e,t,r){return e.map((n,o)=>[t.at(o),S(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Yt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=S(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function rt(e,t,r,n){if(r)return r;let[o,i]=Yt(e,t),s=Math.max(1,Math.round(n));if(i===o)return mn(o,s);let a=Wt((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function mn(e,t){if(e===0)return[0,1];let r=Wt(Math.abs(e)/t);return[e-r,e+r]}function yn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var _e=xn({key:"chartLine",state:{points:f(()=>[]),stroke:ot.custom([],{resolve:$t.resolve,lerp:$t.lerp}),progress:1,enabled:!0,spotlight:f(()=>ee),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:ot.number(0,{min:0,max:1}),to:ot.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=y(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=yn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!te(a)){e.draw(new nt().line({points:o,radius:s}).stroke(i));return}e.draw(new nt().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Je(o,a))e.draw(new nt().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as jt,Types as Kt,component2d as bn,fillOps as qt,strokeOps as Zt}from"@motionscript/sdk";var st=bn({key:"chartRegion",state:{box:f(()=>ee),stroke:Kt.custom(X.region.stroke,{resolve:Zt.resolve,lerp:Zt.lerp}),fill:Kt.custom(X.region.fill,{resolve:qt.resolve,lerp:qt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!te(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new jt().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new jt().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Jt,Text as Qt,Types as it,component2d as wn,insetsOps as er,textOps as tr}from"@motionscript/sdk";import{enterBudget as Sn}from"@motionscript/sdk/component";var An=24,Pe=wn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:it.custom(E),label:"",arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=er.resolve(e.axis.tickPadding).top,r=er.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Qt({...tr.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":zt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>b(e.arrivals,u).opacity,y:()=>b(e.arrivals,u).shift});return d}),c=[new Jt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Qt({...tr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new Jt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:it.custom(void 0),slide:it.number(An)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Sn(e.duration,o,i,r),h=y(e),m=t.markers.map((p,x)=>({at:x*l,duration:u,piece:P(e,x,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...m,...g])])}}}});import{formatNumber as kn}from"@motionscript/sdk/component";var Oe=864e5,ar=["january","february","march","april","may","june","july","august","september","october","november","december"],rr=2024;function nr(e){return e.length<3?-1:ar.findIndex(t=>t.startsWith(e))}function vn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*Oe+(t-1)*7*Oe}function lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:vn(n[1]===void 0?rr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=nr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?rr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=nr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function cr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ar[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*Oe?String(n):t>60*Oe?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function En(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function Rn(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=lr(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function or(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function sr(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return T([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of T([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function Tn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var ir=new WeakMap;function at(e,t,r){let n=ir.get(e);n||ir.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=Ln(e,t,r)),i}function Ln(e,t,r){if(t!==""&&En(e,t)){let s=e.map(a=>S(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:or(s),label:a=>r===void 0?F(a):kn(a,r),ticks:T}}let n=e.map(s=>j(s,t)),o=t===""?null:Rn(e,t);if(o){let s=or(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>Tn(o,n,c,l=>cr(l,a)),ticks:(c,l)=>sr(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>sr(i,s,a)}}var ur=V.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}});function ct(e,t=e.xAxis.format){return at(e.data,e.xField,t)}function Pn(e,t){let r=ct(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,U-1)}}function On(e,t){let r=(t.ticks?.length??U)-1,n=rt(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var dr=new WeakMap;function Fe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=dr.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:he(n,c=>Pn(e,c)),y:he(o,c=>On(e,c))};return dr.set(t,{xField:r,xAxis:n,yAxis:o,series:i,domains:a}),a}function Fn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=tt(e.data,ct(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function hr(e,t,r){let{width:n,height:o}=r;return Ze(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function pr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function fr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function gr(e,t){let r=In(e);return{range:r,ticks:T(r,Math.max(2,t.length)-1)}}function mr(e,t,r){return{...t.x&&{xAxis:ue(e.x,t.x,r)},...t.y&&{yAxis:ue(e.y,t.y,r)}}}function lt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Pe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(_e.is),legend:t.below.find(Q.is)??null}}function xr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function yr(e,t,r,n){let o=lt(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ut=Cn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:V.custom({},{resolve:$,lerp:de}),yAxis:V.custom({},{resolve:$,lerp:de}),theme:V.custom(X,{resolve:Qe,lerp:et}),region:V.custom(null),regionReveal:0,showLegend:V.boolean(!0,{animatable:!1}),home:V.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Fe(e),n,o=()=>Le(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ee(d)):_n(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Pe({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=ct(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new _e({points:()=>Fn(e,r(),h,o()),stroke:()=>Nt(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>hr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ut(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Mn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new st({box:()=>hr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=pr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*_.axes,c=s*_.marks,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return w(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-xe}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*_.legend,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?xr(e,t):n<=0||!pr(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>xr(e,t)},zoomTo:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Fe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...gr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...gr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...mr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Fe(t);return e.animate(o=>({home:null,...mr(n,r,o)}))}},showSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:O})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Qn,Types as G,clamp as Dr,component2d as eo,easeOut as re}from"@motionscript/sdk";import{formatNumber as to}from"@motionscript/sdk/component";import{Rect as dt,Text as br,Types as ht,clamp as Dn,component2d as Bn,insetsOps as wr,textOps as Sr}from"@motionscript/sdk";import{enterBudget as Gn}from"@motionscript/sdk/component";var Hn=24,Ie=Bn({key:"categoryAxis",state:{categories:f(()=>[]),axis:ht.custom(E),label:"",dims:f(()=>[]),arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=wr.resolve(e.axis.tickPadding).top,r=wr.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new dt({width:"hug",height:"hug",flow:"freeform",opacity:()=>Dn(e.dims[l]??1,0,1),x:()=>i(l),children:[new br({...Sr.styleProps(e.axis.labelStyle),text:c,opacity:()=>b(e.arrivals,l).opacity,y:()=>b(e.arrivals,l).shift})]})),a=[new dt({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new br({...Sr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new dt({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:ht.custom(void 0),slide:ht.number(Hn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Gn(e.duration,o,i,r),h=y(e),m=(o-1)*l+u,g=t.categories.map((x,N)=>({at:N*l,duration:u,piece:P(e,N,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...g,...p])])}}}});import{Graphics2D as Vn,Text as Wn,Types as He,clamp as Cr,component2d as Yn,fillOps as Rr,shadowOps as Tr,strokeOps as Lr,textOps as $n}from"@motionscript/sdk";import{fillOps as Nn,lerpNumber as De,shadowOps as Ar,strokeOps as kr,textOps as vr}from"@motionscript/sdk";import{niceStep as Un}from"@motionscript/sdk/component";function Be(e,t,r){let n=0;return t.map(o=>{let i=S(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function pt(e,t){let r=-1;for(let n=0;n<t.length;n++)S(e,t[n].field)!==0&&(r=n);return r}function ft(e,t){return e.map(r=>j(r,t))}function Er(e,t,r){let n=0,o=0;for(let i of e)for(let s of Be(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function gt(e,t,r,n,o){if(n)return n;let[i,s]=Er(e,t,r),a=Math.max(1,Math.round(o)),c=Un((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var L={seriesFills:we,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...E,labelStyle:{...E.labelStyle,fontWeight:600},tickPadding:16},yAxis:ye,plotArea:be,legend:R,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:k.markerColor},spotlight:{dimOpacity:O}};function zn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:kr.resolve(e?.stroke??t.stroke),shadow:Ar.resolve(e?.shadow??t.shadow)}}function Xn(e,t,r){return{cornerRadius:De(e.cornerRadius,t.cornerRadius,r),slotFill:De(e.slotFill,t.slotFill,r),groupGap:De(e.groupGap,t.groupGap,r),stroke:kr.lerp(e.stroke,t.stroke,r),shadow:Ar.lerp(e.shadow,t.shadow,r)}}function mt(e,t){let r=t??L;return{seriesFills:ke(e?.seriesFills,r.seriesFills),bar:zn(e?.bar,r.bar),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),valueStyle:vr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function xt(e,t,r){return{seriesFills:ve(e.seriesFills,t.seriesFills,r),bar:Xn(e.bar,t.bar,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),valueStyle:vr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:De(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function Ge(e,t,r){return t.fill!=null?Nn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var jn=10,Kn=1.6,qn=24;function Mr(e,t){return e.enabled?Cr(e.dims[t]??1,0,1):0}function yt(e,t){let r=e.bars[t];if(!r)return null;let n=Cr(e.growth,0,1);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function _r(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:qn}function Pr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function Zn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Pr(e,t)){let n=yt(e,t);if(!n||Math.abs(n.end-n.base)<_r(e)*Kn)return""}return r.caption??F(r.value)}function Jn(e,t){let r=yt(e,t);if(!r)return 0;if(Pr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(jn+_r(e)/2)}var Ne=Yn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:He.custom([],{resolve:Rr.resolve,lerp:Rr.lerp}),barStroke:He.custom(L.bar.stroke,{resolve:Lr.resolve,lerp:Lr.lerp}),barShadow:He.custom(L.bar.shadow,{resolve:Tr.resolve,lerp:Tr.lerp}),cornerRadius:L.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:He.custom(L.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Wn({...$n.styleProps(e.valueStyle),text:()=>Zn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Jn(e,r),opacity:()=>Mr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=yt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Vn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Mr(t,r)))}e.children()}});function ro(e,t){let r=(t.ticks?.length??U)-1,n=gt(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var Or=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Or.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=he(o,a=>ro(e,a));return Or.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Br(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ee(t.ticks)):to(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function no(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function pe(e,t){return Math.max(0,e.weights[t]??1)}function oo(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*pe(e,o))}),r}function so(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*Dr(e.theme.bar.slotFill,0,1),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=pe(e,p);let h=l/(d>0?d:1),m=pe(e,t),g=0;for(let p=0;p<t;p++)g+=pe(e,p);return e.data.map((p,x)=>{let A=Be(e.stacked?oo(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ke=e.stacked?pt(p,e.series):t,sn=c(x)-l/2,an=e.stacked?c(x):sn+h*g+h*m/2,ln=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=S(p,o.field);return{x:an,width:ln,from:bt(i,r,A.from),to:bt(i,r,A.to),round:Ke===t,value:Dt,...n&&{caption:Br(e,i,Dt)}}})}function Fr(e){let t=Dr(e.spotlightReveal,0,1),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Ie.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ne.is),legend:t.below.find(Q.is)??null}}function Ir(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>pe(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=eo({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:G.custom({},{resolve:$,lerp:de}),categoryAxis:G.custom({},{resolve:$,lerp:ue}),theme:G.custom(L,{resolve:mt,lerp:xt}),growth:1,weights:f(()=>[]),spotlight:G.custom(null),spotlightReveal:0,showLegend:G.boolean(!0,{animatable:!1}),showValues:G.boolean(!1,{animatable:!1}),showing:G.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Le(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Br(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Ie({categories:ft(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Fr(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ne({bars:()=>so(e,h,o(),i),baseline:()=>no(r(),o()),fill:()=>Ge(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Fr(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ge(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Qn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*_.axes,s=o*_.marks,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return w(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-xe}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*_.legend,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:G.number(0,{min:0,step:1})},easing:re(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:re(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as nn,Types as le,clamp as on,component2d as Io,easeOut as ae}from"@motionscript/sdk";import{Flow as kt,Paint as fe,Rect as vt,Shapes as Gr,Text as io,Types as ao,clamp as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Hr=16,Ue=co({key:"pieLegend",state:{...fe.state,...kt.state,...Gr.corners,slices:f(()=>[]),legend:ao.custom(R),dims:f(()=>[]),arrivals:Y()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>lo(e.dims[n]??1,0,1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>b(e.arrivals,n).opacity,x:()=>b(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),io({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...fe.commands,arm:(e,t)=>e.animate(()=>({arrivals:z([...t.slices.keys()],{opacity:0,shift:Hr})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Hr},o=e.animate(()=>({arrivals:z([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=y(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,w(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,fe.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,fe.inset(t)),render:(e,t)=>fe.draw(e,t,Gr.rect(e.size,t))});import{Graphics2D as zr,PathBuilder as So,Rect as Ct,Text as oe,Types as me,clamp as ie,component2d as Ao,fillOps as Xr,shadowOps as ko,strokeOps as Vr,textOps as se}from"@motionscript/sdk";import{clamp as ho,lerpNumber as ge,shadowOps as Nr,strokeOps as ze,textOps as v}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:j(o,t),value:S(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var po=Math.PI/180;function Xe(e,t,r){return e<=0?1:1-(1-ho(t,0,1))*e*(1-r)}function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Ur(e){let t=0;for(let r of e)t+=Tt(r);return t}function ne(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ve(e,t){let r=Ur(e);if(r<=0)return[];let n=[],o=t*po;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function We(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:k.markerColor},fo=.1,M={sliceFills:we,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:k.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:k.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:k.markerColor}},legend:R,spotlight:{dimOpacity:fo}};function go(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:ze.resolve(e?.stroke??t.stroke),shadow:Nr.resolve(e?.shadow??t.shadow)}}function mo(e,t,r){return{gap:ge(e.gap,t.gap,r),holeRadius:ge(e.holeRadius,t.holeRadius,r),startAngle:ge(e.startAngle,t.startAngle,r),selectedGrow:ge(e.selectedGrow,t.selectedGrow,r),stroke:ze.lerp(e.stroke,t.stroke,r),shadow:Nr.lerp(e.shadow,t.shadow,r)}}function xo(e,t){return{textStyle:v.resolveStyle(e?.textStyle,t.textStyle),percentStyle:v.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:v.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:ze.resolve(e?.leaderStroke??t.leaderStroke)}}function yo(e,t,r){return{textStyle:v.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:v.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:v.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:ze.lerp(e.leaderStroke,t.leaderStroke,r)}}function bo(e,t){return{labelStyle:v.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:v.resolveStyle(e?.captionStyle,t.captionStyle)}}function wo(e,t,r){return{labelStyle:v.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:v.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??M;return{sliceFills:ke(e?.sliceFills,r.sliceFills),ring:go(e?.ring,r.ring),label:xo(e?.label,r.label),center:bo(e?.center,r.center),legend:Z(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:ve(e.sliceFills,t.sliceFills,r),ring:mo(e.ring,t.ring,r),label:yo(e.label,t.label,r),center:wo(e.center,t.center,r),legend:J(e.legend,t.legend,r),spotlight:{dimOpacity:ge(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var Wr=12,vo=14,_t=.62,Eo=6,Yr=34,$r=26,jr=8,Ro=.18,To=240,Lo=8,Kr=2,Qr=.44,Pt=.62,Mo=.78,Co=.9,qr=.001,en=26;function H(e,t=en){let r=e.fontSize;return typeof r=="number"?r:t}function _o(e,t,r,n,o,i){let s=new So,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*To)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,x=ne(d,g+(p-g)*h/c);return{x:x.x+i,y:x.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var Ye=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ve(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>qr?o/s:1/0,l=a>qr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?qe(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Qr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,en*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Co/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*Mo/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:Kr,right:Kr};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Yr+$r+jr+this.captionGlyphs(n.index)*r+vo,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Yr}popOf(t){return ie(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=ne(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){return Xe(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return qe(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=ne(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return We(a,n+Wr,o,i),We(c,n+Wr,o,i),[...a,...c].map(l=>{let u=ne(this.anchorRadius(l.index)+Eo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Ro),m=s+l.side*(r+$r);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*jr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var Po={width:0,height:0},Zr=new WeakMap;function Oo(e){if(typeof e!="object"||e===null)return Xr.resolve(e);let t=Zr.get(e);return t===void 0&&Zr.set(e,t=Xr.resolve(e)),t}function Jr(e){return e.map(t=>Oo(t.fill))}function Fo(e){let t=[],r=()=>new Ye(e,t[0]?.parent?.layoutBounds??Po),n=o=>{let i=()=>ie(e.labelReveal,0,1)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Qr})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new oe({...se.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new oe({...se.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ve(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new oe({...se.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new oe({...se.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ie(e.centerReveal,0,1),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var $e=Ao({key:"pieRing",state:{slices:f(()=>[]),ring:me.custom(M.ring),label:me.custom(M.label),centerStyle:me.custom(M.center),labelMode:me.custom("percent"),labelPlacement:me.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:M.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Fo(e),load:(e,t)=>D(e,{fills:Jr(t.slices),shadows:[ko.resolve(t.ring.shadow)],strokes:[Vr.resolve(t.ring.stroke),Vr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=y(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=y(e),n=ie(t.centerReveal,0,1);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new Ye(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=ie(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=Jr(t.slices);for(let p of o){let x=Math.min(p.a1,s);if(x<=p.a0)continue;let N=_o(p.a0,x,a,r.anchorRadius(p.index),c,l),A=new zr().path(N.toPathState({centerBounds:d,width:h,height:h}));A.shadow(t.ring.shadow),A.fill(m[p.index]??[]),A.stroke(t.ring.stroke),e.draw(A.opacity(r.sliceOpacity(p.index)))}let g=ie(t.labelReveal,0,1);if(g>.001)for(let p of r.placements())e.draw(new zr().line({points:p.leader,radius:Lo}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Do=.65,Bo=.35,Ft=le.number(0,{min:0,step:1});function tn(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ce(e,t){return on(e.pops[t]??0,0,1)}function Go(e,t){return ce(e,t)>.5}function Ho(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ce(e,n));let r=e.theme.spotlight.dimOpacity;return e.data.map((n,o)=>Xe(t,r,ce(e,o)))}function je(e,t,r){let n=t.data.map((i,s)=>ce(t,s)),o=t.data.map((i,s)=>on(r(s),0,1));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function rn(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=nn.is(r)?r.children.find($e.is):void 0;if(n)return{ring:n,legend:r.children.find(Ue.is)??null}}return null}var It=Io({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:le.custom(M,{resolve:Lt,lerp:Mt}),labelMode:le.custom("percent"),labelPlacement:le.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:le.boolean(!0,{animatable:!1}),showCenter:le.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>tn(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>tn(e),n=[new $e({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new Ue({slices:r,legend:()=>t().legend,dims:()=>Ho(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new nn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:ae(),run:(e,t,r)=>{let n=rn(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Do,a=e.duration*Bo,c=l=>({at:0,duration:0,piece:l});return w(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:ae(),run:(e,t,r)=>rn(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:ce(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?0:ce(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:ae(),run:(e,t)=>je(e,t,()=>0)}}});var No=[ut,At,It];export{At as BarChart,k as CHART_PALETTE,Ie as CategoryAxis,Ne as ChartBars,Me as ChartBorder,Ce as ChartCanvas,Q as ChartLegend,_e as ChartLine,st as ChartRegion,L as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,R as DEFAULT_LEGEND,U as DEFAULT_MARKERS,M as DEFAULT_PIE_CHART_THEME,be as DEFAULT_PLOT_AREA,Uo as DEFAULT_SERIES_COLORS,we as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,E as DEFAULT_X_AXIS,ye as DEFAULT_Y_AXIS,ee as EMPTY_REGION_BOX,_ as ENTER_SHARE,Pe as HorizontalAxis,xe as LEGEND_SLIDE,ut as LineChart,No as NODES,It as PieChart,Ue as PieLegend,$e as PieRing,C as SERIES_ARG,O as SPOTLIGHT_DIM,I as VerticalAxis,z as armed,P as arrival,b as arrivalOf,Y as arrivalsEntry,W as asParts,ft as barCategories,St as barChartDomain,Be as barSpans,Er as barValueExtent,w as beats,Re as cartesianFrame,Te as cartesianViews,Je as clipPolylineToBox,cr as formatInstant,F as formatMarker,qe as formatPercent,y as frameEase,f as fresh,te as hasRegion,Go as isSliceSelected,Le as laidOutSize,q as lerpAxisConfig,ue as lerpAxisDomain,de as lerpAxisEntry,xt as lerpBarChartTheme,et as lerpChartTheme,J as lerpLegendConfig,Mt as lerpPieChartTheme,Ae as lerpPlotArea,ve as lerpSeriesFills,Ht as lerpSeriesStrokes,Fe as lineChartDomains,D as loadPaints,zt as markerCaption,Ee as markerStep,T as markerValues,S as num,zo as numericFields,lr as parseInstant,Ve as pieArcs,We as relaxLabels,K as resolveAxisConfig,$ as resolveAxisDomain,mt as resolveBarChartTheme,Ge as resolveBarFill,gt as resolveBarScale,Qe as resolveChartTheme,Z as resolveLegendConfig,Lt as resolvePieChartTheme,Rt as resolvePieSlices,Se as resolvePlotArea,Ze as resolveRegionBox,Ut as resolveSeriesFill,ke as resolveSeriesFills,Nt as resolveSeriesStroke,Gt as resolveSeriesStrokes,at as resolveXScale,rt as resolveYScale,ne as ringPoint,tt as seriesPoints,he as settleAxisDomain,Ur as sliceTotal,Tt as sliceValue,pt as stackCapIndex,j as text,Yt as yExtent};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|