UNPKG

sui-explorer-local

Version:
18 lines (17 loc) 3.11 kB
import{j as e}from"./jsx-runtime-ffb262ed.js";import{c as $}from"./clsx-0839fdbe.js";import{r as D}from"./index-76fb7be0.js";import{H as j}from"./Heading-31d5eddc.js";import"./_commonjsHelpers-de833af9.js";import"./index-dca19ccf.js";import"./sizeAndWeight-05769a6b.js";function B({deg:t,values:l}){const a=[];t&&a.push(`${t}deg`);const o=l.map(({percent:r,color:s})=>`${s} ${r}%`);return a.push(...o),`linear-gradient(${a.join(",")})`}function f({data:t,title:l}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(j,{variant:"heading5/semibold",color:"steel-darker",children:l}),e.jsx("div",{className:"flex flex-col items-start justify-center gap-2",children:t.map(({color:a,gradient:o,label:r,value:s})=>{const n=o?B(o):a;return e.jsxs("div",{className:$("flex items-center gap-1.5",s===0&&"hidden"),children:[e.jsx("div",{style:{background:n},className:"h-3 w-3 rounded-sm"}),e.jsxs("div",{style:{backgroundImage:n,color:n},className:"bg-clip-text text-body font-medium text-transparent",children:[s," ",r]})]},r)})})]})}function u({data:t}){const r=2*Math.PI*20,s=-90,n=t.reduce((c,{value:d})=>c+d,0);let p=0;const _=t.map(({value:c,label:d,color:N,gradient:m},b)=>{const g=`gradient-${b}`,x=100/n*c,C=p*360/100+s,R=r-r*x/100;return p+=x,e.jsxs(D.Fragment,{children:[m&&e.jsx("defs",{children:e.jsx("linearGradient",{id:g,children:m.values.map(({percent:k,color:A},F)=>e.jsx("stop",{offset:k,stopColor:A},F))})}),e.jsx("circle",{cx:25,cy:25,r:20,fill:"transparent",stroke:m?`url(#${g})`:N,strokeWidth:5,strokeDasharray:r,strokeDashoffset:R,transform:`rotate(${C} 25 25)`})]},d)});return e.jsxs("div",{className:"relative",children:[e.jsx("svg",{viewBox:"0 0 50 50",strokeLinecap:"butt",children:_}),e.jsx("div",{className:"absolute inset-0 mx-auto flex items-center justify-center",children:e.jsx("div",{className:"flex flex-col items-center gap-1.5",children:e.jsx(j,{variant:"heading2/semibold",color:"sui-dark",children:n})})})]})}try{f.displayName="RingChartLegend",f.__docgenInfo={description:"",displayName:"RingChartLegend",props:{data:{defaultValue:null,description:"",name:"data",required:!0,type:{name:"RingChartData"}},title:{defaultValue:null,description:"",name:"title",required:!0,type:{name:"string"}}}}}catch{}try{u.displayName="RingChart",u.__docgenInfo={description:"",displayName:"RingChart",props:{data:{defaultValue:null,description:"",name:"data",required:!0,type:{name:"RingChartData"}}}}}catch{}const H={component:u},i={args:{data:[{value:63,label:"Active",color:"#589AEA"},{value:2,label:"New",color:"#6FBCF0"},{value:4,label:"At Risk",color:"#FF794B"}]}};var h,v,y;i.parameters={...i.parameters,docs:{...(h=i.parameters)==null?void 0:h.docs,source:{originalSource:`{ args: { data: [{ value: 63, label: 'Active', color: '#589AEA' }, { value: 2, label: 'New', color: '#6FBCF0' }, { value: 4, label: 'At Risk', color: '#FF794B' }] } }`,...(y=(v=i.parameters)==null?void 0:v.docs)==null?void 0:y.source}}};const M=["Default"];export{i as Default,M as __namedExportsOrder,H as default};