Comparing version 0.83.1 to 0.84.0
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("react"),i=require("@nivo/core"),r=require("@nivo/arcs"),n=require("@nivo/legends"),t=require("react/jsx-runtime"),a=require("d3-shape"),o=require("@nivo/colors"),s=require("@nivo/tooltip");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},d.apply(this,arguments)}function l(e,i){if(null==e)return{};var r,n,t={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],i.indexOf(r)>=0||(t[r]=e[r]);return t}var c,u=function(e){var i=e.width,r=e.height,a=e.legends,o=e.data,s=e.toggleSerie;return t.jsx(t.Fragment,{children:a.map((function(e,a){var l;return t.jsx(n.BoxLegendSvg,d({},e,{containerWidth:i,containerHeight:r,data:null!=(l=e.data)?l:o,toggleSerie:e.toggleSerie?s:void 0}),a)}))})},v={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var i=e.datum;return t.jsx(s.BasicTooltip,{id:i.id,value:i.formattedValue,enableChip:!0,color:i.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(c=window.devicePixelRatio)?c:1},f=["points"],g=function(r){var n=r.data,t=r.id,a=void 0===t?v.id:t,s=r.value,l=void 0===s?v.value:s,c=r.valueFormat,u=r.colors,f=void 0===u?v.colors:u,g=i.usePropertyAccessor(a),L=i.usePropertyAccessor(l),h=i.useValueFormatter(c),b=o.useOrdinalColorScale(f,"id");return e.useMemo((function(){return n.map((function(e){var i,r=g(e),n=L(e),t={id:r,label:null!=(i=e.label)?i:r,hidden:!1,value:n,formattedValue:h(n),data:e};return d({},t,{color:b(t)})}))}),[n,g,L,h,b])},L=function(r){var n=r.data,t=r.startAngle,o=r.endAngle,s=r.innerRadius,l=r.outerRadius,c=r.padAngle,u=r.sortByValue,v=r.activeId,f=r.activeInnerRadiusOffset,g=r.activeOuterRadiusOffset,L=r.hiddenIds,h=e.useMemo((function(){var e=a.pie().value((function(e){return e.value})).startAngle(i.degreesToRadians(t)).endAngle(i.degreesToRadians(o)).padAngle(i.degreesToRadians(c));return u||e.sortValues(null),e}),[t,o,c,u]);return e.useMemo((function(){var e=n.filter((function(e){return!L.includes(e.id)}));return{dataWithArc:h(e).map((function(e){var r=Math.abs(e.endAngle-e.startAngle);return d({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:v===e.data.id?s-f:s,outerRadius:v===e.data.id?l+g:l,thickness:l-s,padAngle:e.padAngle,angle:r,angleDeg:i.radiansToDegrees(r)}})})),legendData:n.map((function(e){return d({},e,{hidden:L.includes(e.id)})}))}}),[h,n,L,v,s,f,l,g])},h=function(n){var t=n.data,a=n.width,o=n.height,s=n.innerRadius,c=void 0===s?v.innerRadius:s,u=n.startAngle,g=void 0===u?v.startAngle:u,h=n.endAngle,b=void 0===h?v.endAngle:h,p=n.padAngle,A=void 0===p?v.padAngle:p,k=n.sortByValue,R=void 0===k?v.sortByValue:k,m=n.cornerRadius,x=void 0===m?v.cornerRadius:m,O=n.fit,C=void 0===O?v.fit:O,I=n.activeInnerRadiusOffset,M=void 0===I?v.activeInnerRadiusOffset:I,y=n.activeOuterRadiusOffset,T=void 0===y?v.activeOuterRadiusOffset:y,S=e.useState(null),W=S[0],w=S[1],j=e.useState([]),B=j[0],V=j[1],E=e.useMemo((function(){var e,i=Math.min(a,o)/2,n=i*Math.min(c,1),t=a/2,s=o/2;if(C){var d=r.computeArcBoundingBox(t,s,i,g-90,b-90),u=d.points,v=l(d,f),L=Math.min(a/v.width,o/v.height),h={width:v.width*L,height:v.height*L};h.x=(a-h.width)/2,h.y=(o-h.height)/2,t=(t-v.x)/v.width*v.width*L+h.x,s=(s-v.y)/v.height*v.height*L+h.y,e={box:v,ratio:L,points:u},i*=L,n*=L}return{centerX:t,centerY:s,radius:i,innerRadius:n,debug:e}}),[a,o,c,g,b,C,x]),P=L({data:t,startAngle:g,endAngle:b,innerRadius:E.innerRadius,outerRadius:E.radius,padAngle:A,sortByValue:R,activeId:W,activeInnerRadiusOffset:M,activeOuterRadiusOffset:T,hiddenIds:B}),D=e.useCallback((function(e){V((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return d({arcGenerator:r.useArcGenerator({cornerRadius:x,padAngle:i.degreesToRadians(A)}),setActiveId:w,toggleSerie:D},P,E)},b=function(i){var r=i.dataWithArc,n=i.arcGenerator,t=i.centerX,a=i.centerY,o=i.radius,s=i.innerRadius;return e.useMemo((function(){return{dataWithArc:r,arcGenerator:n,centerX:t,centerY:a,radius:o,innerRadius:s}}),[r,n,t,a,o,s])},p=function(i){var n=i.center,a=i.data,o=i.arcGenerator,d=i.borderWidth,l=i.borderColor,c=i.isInteractive,u=i.onClick,v=i.onMouseEnter,f=i.onMouseMove,g=i.onMouseLeave,L=i.setActiveId,h=i.tooltip,b=i.transitionMode,p=s.useTooltip(),A=p.showTooltipFromEvent,k=p.hideTooltip,R=e.useMemo((function(){if(c)return function(e,i){null==u||u(e,i)}}),[c,u]),m=e.useMemo((function(){if(c)return function(i,r){A(e.createElement(h,{datum:i}),r),L(i.id),null==v||v(i,r)}}),[c,A,L,v,h]),x=e.useMemo((function(){if(c)return function(i,r){A(e.createElement(h,{datum:i}),r),null==f||f(i,r)}}),[c,A,f,h]),O=e.useMemo((function(){if(c)return function(e,i){k(),L(null),null==g||g(e,i)}}),[c,k,L,g]);return t.jsx(r.ArcsLayer,{center:n,data:a,arcGenerator:o,borderWidth:d,borderColor:l,transitionMode:b,onClick:R,onMouseEnter:m,onMouseMove:x,onMouseLeave:O})},A=["isInteractive","animate","motionConfig","theme","renderWrapper"],k=function(n){var a=n.data,o=n.id,s=void 0===o?v.id:o,d=n.value,l=void 0===d?v.value:d,c=n.valueFormat,f=n.sortByValue,L=void 0===f?v.sortByValue:f,A=n.layers,k=void 0===A?v.layers:A,R=n.startAngle,m=void 0===R?v.startAngle:R,x=n.endAngle,O=void 0===x?v.endAngle:x,C=n.padAngle,I=void 0===C?v.padAngle:C,M=n.fit,y=void 0===M?v.fit:M,T=n.innerRadius,S=void 0===T?v.innerRadius:T,W=n.cornerRadius,w=void 0===W?v.cornerRadius:W,j=n.activeInnerRadiusOffset,B=void 0===j?v.activeInnerRadiusOffset:j,V=n.activeOuterRadiusOffset,E=void 0===V?v.activeOuterRadiusOffset:V,P=n.width,D=n.height,G=n.margin,F=n.colors,q=void 0===F?v.colors:F,H=n.borderWidth,X=void 0===H?v.borderWidth:H,Y=n.borderColor,z=void 0===Y?v.borderColor:Y,N=n.enableArcLabels,U=void 0===N?v.enableArcLabels:N,J=n.arcLabel,K=void 0===J?v.arcLabel:J,Q=n.arcLabelsSkipAngle,Z=void 0===Q?v.arcLabelsSkipAngle:Q,$=n.arcLabelsTextColor,_=void 0===$?v.arcLabelsTextColor:$,ee=n.arcLabelsRadiusOffset,ie=void 0===ee?v.arcLabelsRadiusOffset:ee,re=n.arcLabelsComponent,ne=n.enableArcLinkLabels,te=void 0===ne?v.enableArcLinkLabels:ne,ae=n.arcLinkLabel,oe=void 0===ae?v.arcLinkLabel:ae,se=n.arcLinkLabelsSkipAngle,de=void 0===se?v.arcLinkLabelsSkipAngle:se,le=n.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=n.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=n.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=n.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=n.arcLinkLabelsTextOffset,pe=void 0===be?v.arcLinkLabelsTextOffset:be,Ae=n.arcLinkLabelsTextColor,ke=void 0===Ae?v.arcLinkLabelsTextColor:Ae,Re=n.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,xe=n.arcLinkLabelComponent,Oe=n.defs,Ce=void 0===Oe?v.defs:Oe,Ie=n.fill,Me=void 0===Ie?v.fill:Ie,ye=n.isInteractive,Te=void 0===ye?v.isInteractive:ye,Se=n.onClick,We=n.onMouseEnter,we=n.onMouseMove,je=n.onMouseLeave,Be=n.tooltip,Ve=void 0===Be?v.tooltip:Be,Ee=n.transitionMode,Pe=void 0===Ee?v.transitionMode:Ee,De=n.legends,Ge=void 0===De?v.legends:De,Fe=n.role,qe=void 0===Fe?v.role:Fe,He=i.useDimensions(P,D,G),Xe=He.outerWidth,Ye=He.outerHeight,ze=He.margin,Ne=He.innerWidth,Ue=He.innerHeight,Je=g({data:a,id:s,value:l,valueFormat:c,colors:q}),Ke=h({data:Je,width:Ne,height:Ue,fit:y,innerRadius:S,startAngle:m,endAngle:O,padAngle:I,sortByValue:L,cornerRadius:w,activeInnerRadiusOffset:B,activeOuterRadiusOffset:E}),Qe=Ke.dataWithArc,Ze=Ke.legendData,$e=Ke.arcGenerator,_e=Ke.centerX,ei=Ke.centerY,ii=Ke.radius,ri=Ke.innerRadius,ni=Ke.setActiveId,ti=Ke.toggleSerie,ai=i.bindDefs(Ce,Qe,Me),oi={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};k.includes("arcs")&&(oi.arcs=t.jsx(p,{center:[_e,ei],data:Qe,arcGenerator:$e,borderWidth:X,borderColor:z,isInteractive:Te,onClick:Se,onMouseEnter:We,onMouseMove:we,onMouseLeave:je,setActiveId:ni,tooltip:Ve,transitionMode:Pe},"arcs")),te&&k.includes("arcLinkLabels")&&(oi.arcLinkLabels=t.jsx(r.ArcLinkLabelsLayer,{center:[_e,ei],data:Qe,label:oe,skipAngle:de,offset:ce,diagonalLength:ve,straightLength:ge,strokeWidth:he,textOffset:pe,textColor:ke,linkColor:me,component:xe},"arcLinkLabels")),U&&k.includes("arcLabels")&&(oi.arcLabels=t.jsx(r.ArcLabelsLayer,{center:[_e,ei],data:Qe,label:K,radiusOffset:ie,skipAngle:Z,textColor:_,transitionMode:Pe,component:re},"arcLabels")),Ge.length>0&&k.includes("legends")&&(oi.legends=t.jsx(u,{width:Ne,height:Ue,data:Ze,legends:Ge,toggleSerie:ti},"legends"));var si=b({dataWithArc:Qe,arcGenerator:$e,centerX:_e,centerY:ei,radius:ii,innerRadius:ri});return t.jsx(i.SvgWrapper,{width:Xe,height:Ye,margin:ze,defs:ai,role:qe,children:k.map((function(i,r){return void 0!==oi[i]?oi[i]:"function"==typeof i?t.jsx(e.Fragment,{children:e.createElement(i,si)},r):null}))})},R=function(e){var r=e.isInteractive,n=void 0===r?v.isInteractive:r,a=e.animate,o=void 0===a?v.animate:a,s=e.motionConfig,c=void 0===s?v.motionConfig:s,u=e.theme,f=e.renderWrapper,g=l(e,A);return t.jsx(i.Container,{animate:o,isInteractive:n,motionConfig:c,renderWrapper:f,theme:u,children:t.jsx(k,d({isInteractive:n},g))})},m=["isInteractive","theme","renderWrapper"],x=function(a){var l=a.data,c=a.id,u=void 0===c?v.id:c,f=a.value,L=void 0===f?v.value:f,b=a.valueFormat,p=a.sortByValue,A=void 0===p?v.sortByValue:p,k=a.startAngle,R=void 0===k?v.startAngle:k,m=a.endAngle,x=void 0===m?v.endAngle:m,O=a.padAngle,C=void 0===O?v.padAngle:O,I=a.fit,M=void 0===I?v.fit:I,y=a.innerRadius,T=void 0===y?v.innerRadius:y,S=a.cornerRadius,W=void 0===S?v.cornerRadius:S,w=a.activeInnerRadiusOffset,j=void 0===w?v.activeInnerRadiusOffset:w,B=a.activeOuterRadiusOffset,V=void 0===B?v.activeOuterRadiusOffset:B,E=a.width,P=a.height,D=a.margin,G=a.pixelRatio,F=void 0===G?1:G,q=a.colors,H=void 0===q?v.colors:q,X=a.borderWidth,Y=void 0===X?v.borderWidth:X,z=a.borderColor,N=void 0===z?v.borderColor:z,U=a.enableArcLabels,J=void 0===U?v.enableArcLabels:U,K=a.arcLabel,Q=void 0===K?v.arcLabel:K,Z=a.arcLabelsSkipAngle,$=void 0===Z?v.arcLabelsSkipAngle:Z,_=a.arcLabelsTextColor,ee=void 0===_?v.arcLabelsTextColor:_,ie=a.arcLabelsRadiusOffset,re=void 0===ie?v.arcLabelsRadiusOffset:ie,ne=a.enableArcLinkLabels,te=void 0===ne?v.enableArcLinkLabels:ne,ae=a.arcLinkLabel,oe=void 0===ae?v.arcLinkLabel:ae,se=a.arcLinkLabelsSkipAngle,de=void 0===se?v.arcLinkLabelsSkipAngle:se,le=a.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=a.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=a.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=a.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=a.arcLinkLabelsTextOffset,pe=void 0===be?v.arcLinkLabelsTextOffset:be,Ae=a.arcLinkLabelsTextColor,ke=void 0===Ae?v.arcLinkLabelsTextColor:Ae,Re=a.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,xe=a.isInteractive,Oe=void 0===xe?v.isInteractive:xe,Ce=a.onClick,Ie=a.onMouseMove,Me=a.tooltip,ye=void 0===Me?v.tooltip:Me,Te=a.legends,Se=void 0===Te?v.legends:Te,We=e.useRef(null),we=i.useTheme(),je=i.useDimensions(E,P,D),Be=je.margin,Ve=je.innerWidth,Ee=je.innerHeight,Pe=je.outerWidth,De=je.outerHeight,Ge=g({data:l,id:u,value:L,valueFormat:b,colors:H}),Fe=h({data:Ge,width:Ve,height:Ee,fit:M,innerRadius:T,startAngle:R,endAngle:x,padAngle:C,sortByValue:A,cornerRadius:W,activeInnerRadiusOffset:j,activeOuterRadiusOffset:V}),qe=Fe.dataWithArc,He=Fe.arcGenerator,Xe=Fe.centerX,Ye=Fe.centerY,ze=Fe.radius,Ne=Fe.innerRadius,Ue=Fe.setActiveId,Je=o.useInheritedColor(N,we),Ke=r.useArcLabels({data:qe,label:Q,skipAngle:$,offset:re,textColor:ee}),Qe=r.useArcLinkLabels({data:qe,skipAngle:de,offset:ce,diagonalLength:ve,straightLength:ge,label:oe,linkColor:me,textOffset:pe,textColor:ke});e.useEffect((function(){if(We.current){We.current.width=Pe*F,We.current.height=De*F;var e=We.current.getContext("2d");e.scale(F,F),e.fillStyle=we.background,e.fillRect(0,0,Pe,De),e.save(),e.translate(Be.left,Be.top),He.context(e),e.save(),e.translate(Xe,Ye),qe.forEach((function(i){e.beginPath(),e.fillStyle=i.color,e.strokeStyle=Je(i),e.lineWidth=Y,He(i.arc),e.fill(),Y>0&&e.stroke()})),!0===te&&r.drawCanvasArcLinkLabels(e,Qe,we,he),!0===J&&r.drawCanvasArcLabels(e,Ke,we),e.restore(),Se.forEach((function(i){n.renderLegendToCanvas(e,d({},i,{data:qe,containerWidth:Ve,containerHeight:Ee,theme:we}))}))}}),[We,Ve,Ee,Pe,De,Be.top,Be.left,F,Xe,Ye,He,qe,Je,J,Ke,te,Qe,he,Se,we]);var Ze=e.useMemo((function(){return qe.map((function(e){return d({id:e.id},e.arc)}))}),[qe]),$e=function(e){if(!We.current)return null;var n=i.getRelativeCursor(We.current,e),t=n[0],a=n[1],o=r.findArcUnderCursor(Be.left+Xe,Be.top+Ye,ze,Ne,Ze,t,a);return o?qe.find((function(e){return e.id===o.id})):null},_e=s.useTooltip(),ei=_e.showTooltipFromEvent,ii=_e.hideTooltip,ri=function(i){var r=$e(i);r?(null==Ie||Ie(r,i),Ue(r.id),ei(e.createElement(ye,{datum:r}),i)):(Ue(null),ii())};return t.jsx("canvas",{ref:We,width:Pe*F,height:De*F,style:{width:Pe,height:De,cursor:Oe?"auto":"normal"},onMouseEnter:Oe?ri:void 0,onMouseMove:Oe?ri:void 0,onMouseLeave:Oe?function(){ii()}:void 0,onClick:Oe?function(e){if(Ce){var i=$e(e);i&&Ce(i,e)}}:void 0})},O=function(e){var r=e.isInteractive,n=void 0===r?v.isInteractive:r,a=e.theme,o=e.renderWrapper,s=l(e,m);return t.jsx(i.Container,{isInteractive:n,renderWrapper:o,theme:a,children:t.jsx(x,d({isInteractive:n},s))})};exports.Pie=R,exports.PieCanvas=O,exports.ResponsivePie=function(e){return t.jsx(i.ResponsiveWrapper,{children:function(i){var r=i.width,n=i.height;return t.jsx(R,d({width:r,height:n},e))}})},exports.ResponsivePieCanvas=function(e){return t.jsx(i.ResponsiveWrapper,{children:function(i){var r=i.width,n=i.height;return t.jsx(O,d({width:r,height:n},e))}})},exports.defaultProps=v,exports.useNormalizedData=g,exports.usePie=function(n){var t=n.data,a=n.radius,o=n.innerRadius,s=n.startAngle,l=void 0===s?v.startAngle:s,c=n.endAngle,u=void 0===c?v.endAngle:c,f=n.padAngle,g=void 0===f?v.padAngle:f,h=n.sortByValue,b=void 0===h?v.sortByValue:h,p=n.cornerRadius,A=void 0===p?v.cornerRadius:p,k=n.activeInnerRadiusOffset,R=void 0===k?v.activeInnerRadiusOffset:k,m=n.activeOuterRadiusOffset,x=void 0===m?v.activeOuterRadiusOffset:m,O=e.useState(null),C=O[0],I=O[1],M=e.useState([]),y=M[0],T=M[1],S=L({data:t,startAngle:l,endAngle:u,innerRadius:o,outerRadius:a,padAngle:g,sortByValue:b,activeId:C,activeInnerRadiusOffset:R,activeOuterRadiusOffset:x,hiddenIds:y}),W=e.useCallback((function(e){T((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return d({},S,{arcGenerator:r.useArcGenerator({cornerRadius:A,padAngle:i.degreesToRadians(g)}),setActiveId:I,toggleSerie:W})},exports.usePieArcs=L,exports.usePieFromBox=h,exports.usePieLayerContext=b; | ||
"use strict";var e=require("react"),t=require("@nivo/core"),a=require("@nivo/arcs"),i=require("@nivo/legends"),n=require("react/jsx-runtime"),r=require("d3-shape"),o=require("@nivo/colors"),d=require("@nivo/tooltip");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i])}return e},s.apply(this,arguments)}function l(e,t){if(null==e)return{};var a,i,n={},r=Object.keys(e);for(i=0;i<r.length;i++)a=r[i],t.indexOf(a)>=0||(n[a]=e[a]);return n}var c,u=function(e){var t=e.width,a=e.height,r=e.legends,o=e.data,d=e.toggleSerie;return n.jsx(n.Fragment,{children:r.map((function(e,r){var l;return n.jsx(i.BoxLegendSvg,s({},e,{containerWidth:t,containerHeight:a,data:null!=(l=e.data)?l:o,toggleSerie:e.toggleSerie?d:void 0}),r)}))})},v={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var t=e.datum;return n.jsx(d.BasicTooltip,{id:t.id,value:t.formattedValue,enableChip:!0,color:t.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(c=window.devicePixelRatio)?c:1},f=["points"],g=function(a){var i=a.data,n=a.id,r=void 0===n?v.id:n,d=a.value,l=void 0===d?v.value:d,c=a.valueFormat,u=a.colors,f=void 0===u?v.colors:u,g=t.usePropertyAccessor(r),L=t.usePropertyAccessor(l),h=t.useValueFormatter(c),b=o.useOrdinalColorScale(f,"id");return e.useMemo((function(){return i.map((function(e){var t,a=g(e),i=L(e),n={id:a,label:null!=(t=e.label)?t:a,hidden:!1,value:i,formattedValue:h(i),data:e};return s({},n,{color:b(n)})}))}),[i,g,L,h,b])},L=function(a){var i=a.data,n=a.startAngle,o=a.endAngle,d=a.innerRadius,l=a.outerRadius,c=a.padAngle,u=a.sortByValue,v=a.activeId,f=a.activeInnerRadiusOffset,g=a.activeOuterRadiusOffset,L=a.hiddenIds,h=a.forwardLegendData,b=e.useMemo((function(){var e=r.pie().value((function(e){return e.value})).startAngle(t.degreesToRadians(n)).endAngle(t.degreesToRadians(o)).padAngle(t.degreesToRadians(c));return u||e.sortValues(null),e}),[n,o,c,u]),A=e.useMemo((function(){var e=i.filter((function(e){return!L.includes(e.id)}));return{dataWithArc:b(e).map((function(e){var a=Math.abs(e.endAngle-e.startAngle);return s({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:v===e.data.id?d-f:d,outerRadius:v===e.data.id?l+g:l,thickness:l-d,padAngle:e.padAngle,angle:a,angleDeg:t.radiansToDegrees(a)}})})),legendData:i.map((function(e){return{id:e.id,label:e.label,color:e.color,hidden:L.includes(e.id),data:e}}))}}),[b,i,L,v,d,f,l,g]),p=A.legendData,k=e.useRef(h);return e.useEffect((function(){"function"==typeof k.current&&k.current(p)}),[k,p]),A},h=function(t){var a=t.activeId,i=t.onActiveIdChange,n=t.defaultActiveId,r=void 0===n?null:n,o=void 0!==a,d=e.useState(o?null:r),s=d[0],l=d[1];return{activeId:o?a:s,setActiveId:e.useCallback((function(e){i&&i(e),o||l(e)}),[o,i,l])}},b=function(i){var n=i.data,r=i.width,o=i.height,d=i.innerRadius,c=void 0===d?v.innerRadius:d,u=i.startAngle,g=void 0===u?v.startAngle:u,b=i.endAngle,A=void 0===b?v.endAngle:b,p=i.padAngle,k=void 0===p?v.padAngle:p,R=i.sortByValue,m=void 0===R?v.sortByValue:R,I=i.cornerRadius,x=void 0===I?v.cornerRadius:I,O=i.fit,C=void 0===O?v.fit:O,M=i.activeInnerRadiusOffset,w=void 0===M?v.activeInnerRadiusOffset:M,y=i.activeOuterRadiusOffset,T=void 0===y?v.activeOuterRadiusOffset:y,S=i.activeId,W=i.onActiveIdChange,j=i.defaultActiveId,D=i.forwardLegendData,B=h({activeId:S,onActiveIdChange:W,defaultActiveId:j}),V=B.activeId,E=B.setActiveId,P=e.useState([]),G=P[0],F=P[1],q=e.useMemo((function(){var e,t=Math.min(r,o)/2,i=t*Math.min(c,1),n=r/2,d=o/2;if(C){var s=a.computeArcBoundingBox(n,d,t,g-90,A-90),u=s.points,v=l(s,f),L=Math.min(r/v.width,o/v.height),h={width:v.width*L,height:v.height*L};h.x=(r-h.width)/2,h.y=(o-h.height)/2,n=(n-v.x)/v.width*v.width*L+h.x,d=(d-v.y)/v.height*v.height*L+h.y,e={box:v,ratio:L,points:u},t*=L,i*=L}return{centerX:n,centerY:d,radius:t,innerRadius:i,debug:e}}),[r,o,c,g,A,C]),H=L({data:n,startAngle:g,endAngle:A,innerRadius:q.innerRadius,outerRadius:q.radius,padAngle:k,sortByValue:m,activeId:V,activeInnerRadiusOffset:w,activeOuterRadiusOffset:T,hiddenIds:G,forwardLegendData:D}),X=e.useCallback((function(e){F((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return s({arcGenerator:a.useArcGenerator({cornerRadius:x,padAngle:t.degreesToRadians(k)}),activeId:V,setActiveId:E,toggleSerie:X},H,q)},A=function(t){var a=t.dataWithArc,i=t.arcGenerator,n=t.centerX,r=t.centerY,o=t.radius,d=t.innerRadius;return e.useMemo((function(){return{dataWithArc:a,arcGenerator:i,centerX:n,centerY:r,radius:o,innerRadius:d}}),[a,i,n,r,o,d])},p=function(t){var i=t.center,r=t.data,o=t.arcGenerator,s=t.borderWidth,l=t.borderColor,c=t.isInteractive,u=t.onClick,v=t.onMouseEnter,f=t.onMouseMove,g=t.onMouseLeave,L=t.setActiveId,h=t.tooltip,b=t.transitionMode,A=d.useTooltip(),p=A.showTooltipFromEvent,k=A.hideTooltip,R=e.useMemo((function(){if(c)return function(e,t){null==u||u(e,t)}}),[c,u]),m=e.useMemo((function(){if(c)return function(t,a){p(e.createElement(h,{datum:t}),a),L(t.id),null==v||v(t,a)}}),[c,p,L,v,h]),I=e.useMemo((function(){if(c)return function(t,a){p(e.createElement(h,{datum:t}),a),null==f||f(t,a)}}),[c,p,f,h]),x=e.useMemo((function(){if(c)return function(e,t){k(),L(null),null==g||g(e,t)}}),[c,k,L,g]);return n.jsx(a.ArcsLayer,{center:i,data:r,arcGenerator:o,borderWidth:s,borderColor:l,transitionMode:b,onClick:R,onMouseEnter:m,onMouseMove:I,onMouseLeave:x})},k=["isInteractive","animate","motionConfig","theme","renderWrapper"],R=function(i){var r=i.data,o=i.id,d=void 0===o?v.id:o,s=i.value,l=void 0===s?v.value:s,c=i.valueFormat,f=i.sortByValue,L=void 0===f?v.sortByValue:f,h=i.layers,k=void 0===h?v.layers:h,R=i.startAngle,m=void 0===R?v.startAngle:R,I=i.endAngle,x=void 0===I?v.endAngle:I,O=i.padAngle,C=void 0===O?v.padAngle:O,M=i.fit,w=void 0===M?v.fit:M,y=i.innerRadius,T=void 0===y?v.innerRadius:y,S=i.cornerRadius,W=void 0===S?v.cornerRadius:S,j=i.activeInnerRadiusOffset,D=void 0===j?v.activeInnerRadiusOffset:j,B=i.activeOuterRadiusOffset,V=void 0===B?v.activeOuterRadiusOffset:B,E=i.width,P=i.height,G=i.margin,F=i.colors,q=void 0===F?v.colors:F,H=i.borderWidth,X=void 0===H?v.borderWidth:H,Y=i.borderColor,z=void 0===Y?v.borderColor:Y,N=i.enableArcLabels,U=void 0===N?v.enableArcLabels:N,J=i.arcLabel,K=void 0===J?v.arcLabel:J,Q=i.arcLabelsSkipAngle,Z=void 0===Q?v.arcLabelsSkipAngle:Q,$=i.arcLabelsTextColor,_=void 0===$?v.arcLabelsTextColor:$,ee=i.arcLabelsRadiusOffset,te=void 0===ee?v.arcLabelsRadiusOffset:ee,ae=i.arcLabelsComponent,ie=i.enableArcLinkLabels,ne=void 0===ie?v.enableArcLinkLabels:ie,re=i.arcLinkLabel,oe=void 0===re?v.arcLinkLabel:re,de=i.arcLinkLabelsSkipAngle,se=void 0===de?v.arcLinkLabelsSkipAngle:de,le=i.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=i.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=i.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=i.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=i.arcLinkLabelsTextOffset,Ae=void 0===be?v.arcLinkLabelsTextOffset:be,pe=i.arcLinkLabelsTextColor,ke=void 0===pe?v.arcLinkLabelsTextColor:pe,Re=i.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,Ie=i.arcLinkLabelComponent,xe=i.defs,Oe=void 0===xe?v.defs:xe,Ce=i.fill,Me=void 0===Ce?v.fill:Ce,we=i.isInteractive,ye=void 0===we?v.isInteractive:we,Te=i.onClick,Se=i.onMouseEnter,We=i.onMouseMove,je=i.onMouseLeave,De=i.tooltip,Be=void 0===De?v.tooltip:De,Ve=i.activeId,Ee=i.onActiveIdChange,Pe=i.defaultActiveId,Ge=i.transitionMode,Fe=void 0===Ge?v.transitionMode:Ge,qe=i.legends,He=void 0===qe?v.legends:qe,Xe=i.forwardLegendData,Ye=i.role,ze=void 0===Ye?v.role:Ye,Ne=t.useDimensions(E,P,G),Ue=Ne.outerWidth,Je=Ne.outerHeight,Ke=Ne.margin,Qe=Ne.innerWidth,Ze=Ne.innerHeight,$e=g({data:r,id:d,value:l,valueFormat:c,colors:q}),_e=b({data:$e,width:Qe,height:Ze,fit:w,innerRadius:T,startAngle:m,endAngle:x,padAngle:C,sortByValue:L,cornerRadius:W,activeInnerRadiusOffset:D,activeOuterRadiusOffset:V,activeId:Ve,onActiveIdChange:Ee,defaultActiveId:Pe,forwardLegendData:Xe}),et=_e.dataWithArc,tt=_e.legendData,at=_e.arcGenerator,it=_e.centerX,nt=_e.centerY,rt=_e.radius,ot=_e.innerRadius,dt=_e.setActiveId,st=_e.toggleSerie,lt=t.bindDefs(Oe,et,Me),ct={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};k.includes("arcs")&&(ct.arcs=n.jsx(p,{center:[it,nt],data:et,arcGenerator:at,borderWidth:X,borderColor:z,isInteractive:ye,onClick:Te,onMouseEnter:Se,onMouseMove:We,onMouseLeave:je,setActiveId:dt,tooltip:Be,transitionMode:Fe},"arcs")),ne&&k.includes("arcLinkLabels")&&(ct.arcLinkLabels=n.jsx(a.ArcLinkLabelsLayer,{center:[it,nt],data:et,label:oe,skipAngle:se,offset:ce,diagonalLength:ve,straightLength:ge,strokeWidth:he,textOffset:Ae,textColor:ke,linkColor:me,component:Ie},"arcLinkLabels")),U&&k.includes("arcLabels")&&(ct.arcLabels=n.jsx(a.ArcLabelsLayer,{center:[it,nt],data:et,label:K,radiusOffset:te,skipAngle:Z,textColor:_,transitionMode:Fe,component:ae},"arcLabels")),He.length>0&&k.includes("legends")&&(ct.legends=n.jsx(u,{width:Qe,height:Ze,data:tt,legends:He,toggleSerie:st},"legends"));var ut=A({dataWithArc:et,arcGenerator:at,centerX:it,centerY:nt,radius:rt,innerRadius:ot});return n.jsx(t.SvgWrapper,{width:Ue,height:Je,margin:Ke,defs:lt,role:ze,children:k.map((function(t,a){return void 0!==ct[t]?ct[t]:"function"==typeof t?n.jsx(e.Fragment,{children:e.createElement(t,ut)},a):null}))})},m=function(e){var a=e.isInteractive,i=void 0===a?v.isInteractive:a,r=e.animate,o=void 0===r?v.animate:r,d=e.motionConfig,c=void 0===d?v.motionConfig:d,u=e.theme,f=e.renderWrapper,g=l(e,k);return n.jsx(t.Container,{animate:o,isInteractive:i,motionConfig:c,renderWrapper:f,theme:u,children:n.jsx(R,s({isInteractive:i},g))})},I=["isInteractive","theme","renderWrapper"],x=function(r){var l=r.data,c=r.id,u=void 0===c?v.id:c,f=r.value,L=void 0===f?v.value:f,h=r.valueFormat,A=r.sortByValue,p=void 0===A?v.sortByValue:A,k=r.startAngle,R=void 0===k?v.startAngle:k,m=r.endAngle,I=void 0===m?v.endAngle:m,x=r.padAngle,O=void 0===x?v.padAngle:x,C=r.fit,M=void 0===C?v.fit:C,w=r.innerRadius,y=void 0===w?v.innerRadius:w,T=r.cornerRadius,S=void 0===T?v.cornerRadius:T,W=r.activeInnerRadiusOffset,j=void 0===W?v.activeInnerRadiusOffset:W,D=r.activeOuterRadiusOffset,B=void 0===D?v.activeOuterRadiusOffset:D,V=r.width,E=r.height,P=r.margin,G=r.pixelRatio,F=void 0===G?v.pixelRatio:G,q=r.colors,H=void 0===q?v.colors:q,X=r.borderWidth,Y=void 0===X?v.borderWidth:X,z=r.borderColor,N=void 0===z?v.borderColor:z,U=r.enableArcLabels,J=void 0===U?v.enableArcLabels:U,K=r.arcLabel,Q=void 0===K?v.arcLabel:K,Z=r.arcLabelsSkipAngle,$=void 0===Z?v.arcLabelsSkipAngle:Z,_=r.arcLabelsTextColor,ee=void 0===_?v.arcLabelsTextColor:_,te=r.arcLabelsRadiusOffset,ae=void 0===te?v.arcLabelsRadiusOffset:te,ie=r.enableArcLinkLabels,ne=void 0===ie?v.enableArcLinkLabels:ie,re=r.arcLinkLabel,oe=void 0===re?v.arcLinkLabel:re,de=r.arcLinkLabelsSkipAngle,se=void 0===de?v.arcLinkLabelsSkipAngle:de,le=r.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=r.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=r.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=r.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=r.arcLinkLabelsTextOffset,Ae=void 0===be?v.arcLinkLabelsTextOffset:be,pe=r.arcLinkLabelsTextColor,ke=void 0===pe?v.arcLinkLabelsTextColor:pe,Re=r.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,Ie=r.isInteractive,xe=void 0===Ie?v.isInteractive:Ie,Oe=r.onClick,Ce=r.onMouseMove,Me=r.tooltip,we=void 0===Me?v.tooltip:Me,ye=r.activeId,Te=r.onActiveIdChange,Se=r.defaultActiveId,We=r.legends,je=void 0===We?v.legends:We,De=r.forwardLegendData,Be=e.useRef(null),Ve=t.useTheme(),Ee=t.useDimensions(V,E,P),Pe=Ee.margin,Ge=Ee.innerWidth,Fe=Ee.innerHeight,qe=Ee.outerWidth,He=Ee.outerHeight,Xe=g({data:l,id:u,value:L,valueFormat:h,colors:H}),Ye=b({data:Xe,width:Ge,height:Fe,fit:M,innerRadius:y,startAngle:R,endAngle:I,padAngle:O,sortByValue:p,cornerRadius:S,activeInnerRadiusOffset:j,activeOuterRadiusOffset:B,activeId:ye,onActiveIdChange:Te,defaultActiveId:Se,forwardLegendData:De}),ze=Ye.dataWithArc,Ne=Ye.arcGenerator,Ue=Ye.centerX,Je=Ye.centerY,Ke=Ye.radius,Qe=Ye.innerRadius,Ze=Ye.setActiveId,$e=o.useInheritedColor(N,Ve),_e=a.useArcLabels({data:ze,label:Q,skipAngle:$,offset:ae,textColor:ee}),et=a.useArcLinkLabels({data:ze,skipAngle:se,offset:ce,diagonalLength:ve,straightLength:ge,label:oe,linkColor:me,textOffset:Ae,textColor:ke});e.useEffect((function(){if(Be.current){Be.current.width=qe*F,Be.current.height=He*F;var e=Be.current.getContext("2d");e.scale(F,F),e.fillStyle=Ve.background,e.fillRect(0,0,qe,He),e.save(),e.translate(Pe.left,Pe.top),Ne.context(e),e.save(),e.translate(Ue,Je),ze.forEach((function(t){e.beginPath(),e.fillStyle=t.color,e.strokeStyle=$e(t),e.lineWidth=Y,Ne(t.arc),e.fill(),Y>0&&e.stroke()})),!0===ne&&a.drawCanvasArcLinkLabels(e,et,Ve,he),!0===J&&a.drawCanvasArcLabels(e,_e,Ve),e.restore(),je.forEach((function(t){i.renderLegendToCanvas(e,s({},t,{data:ze,containerWidth:Ge,containerHeight:Fe,theme:Ve}))}))}}),[Be,Ge,Fe,qe,He,Pe.top,Pe.left,F,Ue,Je,Ne,ze,Y,$e,J,_e,ne,et,he,je,Ve]);var tt=e.useMemo((function(){return ze.map((function(e){return s({id:e.id},e.arc)}))}),[ze]),at=function(e){if(!Be.current)return null;var i=t.getRelativeCursor(Be.current,e),n=i[0],r=i[1],o=a.findArcUnderCursor(Pe.left+Ue,Pe.top+Je,Ke,Qe,tt,n,r);return o?ze.find((function(e){return e.id===o.id})):null},it=d.useTooltip(),nt=it.showTooltipFromEvent,rt=it.hideTooltip,ot=function(t){var a=at(t);a?(null==Ce||Ce(a,t),Ze(a.id),nt(e.createElement(we,{datum:a}),t)):(Ze(null),rt())};return n.jsx("canvas",{ref:Be,width:qe*F,height:He*F,style:{width:qe,height:He,cursor:xe?"auto":"normal"},onMouseEnter:xe?ot:void 0,onMouseMove:xe?ot:void 0,onMouseLeave:xe?function(){rt()}:void 0,onClick:xe?function(e){if(Oe){var t=at(e);t&&Oe(t,e)}}:void 0})},O=function(e){var a=e.isInteractive,i=void 0===a?v.isInteractive:a,r=e.theme,o=e.renderWrapper,d=l(e,I);return n.jsx(t.Container,{isInteractive:i,renderWrapper:o,theme:r,children:n.jsx(x,s({isInteractive:i},d))})};exports.Pie=m,exports.PieCanvas=O,exports.ResponsivePie=function(e){return n.jsx(t.ResponsiveWrapper,{children:function(t){var a=t.width,i=t.height;return n.jsx(m,s({width:a,height:i},e))}})},exports.ResponsivePieCanvas=function(e){return n.jsx(t.ResponsiveWrapper,{children:function(t){var a=t.width,i=t.height;return n.jsx(O,s({width:a,height:i},e))}})},exports.defaultProps=v,exports.useNormalizedData=g,exports.usePie=function(i){var n=i.data,r=i.radius,o=i.innerRadius,d=i.startAngle,l=void 0===d?v.startAngle:d,c=i.endAngle,u=void 0===c?v.endAngle:c,f=i.padAngle,g=void 0===f?v.padAngle:f,b=i.sortByValue,A=void 0===b?v.sortByValue:b,p=i.cornerRadius,k=void 0===p?v.cornerRadius:p,R=i.activeInnerRadiusOffset,m=void 0===R?v.activeInnerRadiusOffset:R,I=i.activeOuterRadiusOffset,x=void 0===I?v.activeOuterRadiusOffset:I,O=i.activeId,C=i.onActiveIdChange,M=i.defaultActiveId,w=i.forwardLegendData,y=h({activeId:O,onActiveIdChange:C,defaultActiveId:M}),T=y.activeId,S=y.setActiveId,W=e.useState([]),j=W[0],D=W[1],B=L({data:n,startAngle:l,endAngle:u,innerRadius:o,outerRadius:r,padAngle:g,sortByValue:A,activeId:T,activeInnerRadiusOffset:m,activeOuterRadiusOffset:x,hiddenIds:j,forwardLegendData:w}),V=e.useCallback((function(e){D((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return s({},B,{arcGenerator:a.useArcGenerator({cornerRadius:k,padAngle:t.degreesToRadians(g)}),setActiveId:S,toggleSerie:V})},exports.usePieArcs=L,exports.usePieFromBox=b,exports.usePieLayerContext=A; | ||
//# sourceMappingURL=nivo-pie.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("react"),i=require("@nivo/core"),r=require("@nivo/arcs"),n=require("@nivo/legends"),t=require("react/jsx-runtime"),a=require("d3-shape"),o=require("@nivo/colors"),s=require("@nivo/tooltip");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},d.apply(this,arguments)}function l(e,i){if(null==e)return{};var r,n,t={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],i.indexOf(r)>=0||(t[r]=e[r]);return t}var c,u=function(e){var i=e.width,r=e.height,a=e.legends,o=e.data,s=e.toggleSerie;return t.jsx(t.Fragment,{children:a.map((function(e,a){var l;return t.jsx(n.BoxLegendSvg,d({},e,{containerWidth:i,containerHeight:r,data:null!=(l=e.data)?l:o,toggleSerie:e.toggleSerie?s:void 0}),a)}))})},v={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var i=e.datum;return t.jsx(s.BasicTooltip,{id:i.id,value:i.formattedValue,enableChip:!0,color:i.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(c=window.devicePixelRatio)?c:1},f=["points"],g=function(r){var n=r.data,t=r.id,a=void 0===t?v.id:t,s=r.value,l=void 0===s?v.value:s,c=r.valueFormat,u=r.colors,f=void 0===u?v.colors:u,g=i.usePropertyAccessor(a),L=i.usePropertyAccessor(l),h=i.useValueFormatter(c),b=o.useOrdinalColorScale(f,"id");return e.useMemo((function(){return n.map((function(e){var i,r=g(e),n=L(e),t={id:r,label:null!=(i=e.label)?i:r,hidden:!1,value:n,formattedValue:h(n),data:e};return d({},t,{color:b(t)})}))}),[n,g,L,h,b])},L=function(r){var n=r.data,t=r.startAngle,o=r.endAngle,s=r.innerRadius,l=r.outerRadius,c=r.padAngle,u=r.sortByValue,v=r.activeId,f=r.activeInnerRadiusOffset,g=r.activeOuterRadiusOffset,L=r.hiddenIds,h=e.useMemo((function(){var e=a.pie().value((function(e){return e.value})).startAngle(i.degreesToRadians(t)).endAngle(i.degreesToRadians(o)).padAngle(i.degreesToRadians(c));return u||e.sortValues(null),e}),[t,o,c,u]);return e.useMemo((function(){var e=n.filter((function(e){return!L.includes(e.id)}));return{dataWithArc:h(e).map((function(e){var r=Math.abs(e.endAngle-e.startAngle);return d({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:v===e.data.id?s-f:s,outerRadius:v===e.data.id?l+g:l,thickness:l-s,padAngle:e.padAngle,angle:r,angleDeg:i.radiansToDegrees(r)}})})),legendData:n.map((function(e){return d({},e,{hidden:L.includes(e.id)})}))}}),[h,n,L,v,s,f,l,g])},h=function(n){var t=n.data,a=n.width,o=n.height,s=n.innerRadius,c=void 0===s?v.innerRadius:s,u=n.startAngle,g=void 0===u?v.startAngle:u,h=n.endAngle,b=void 0===h?v.endAngle:h,p=n.padAngle,A=void 0===p?v.padAngle:p,k=n.sortByValue,R=void 0===k?v.sortByValue:k,m=n.cornerRadius,x=void 0===m?v.cornerRadius:m,O=n.fit,C=void 0===O?v.fit:O,I=n.activeInnerRadiusOffset,M=void 0===I?v.activeInnerRadiusOffset:I,y=n.activeOuterRadiusOffset,T=void 0===y?v.activeOuterRadiusOffset:y,S=e.useState(null),W=S[0],w=S[1],j=e.useState([]),B=j[0],V=j[1],E=e.useMemo((function(){var e,i=Math.min(a,o)/2,n=i*Math.min(c,1),t=a/2,s=o/2;if(C){var d=r.computeArcBoundingBox(t,s,i,g-90,b-90),u=d.points,v=l(d,f),L=Math.min(a/v.width,o/v.height),h={width:v.width*L,height:v.height*L};h.x=(a-h.width)/2,h.y=(o-h.height)/2,t=(t-v.x)/v.width*v.width*L+h.x,s=(s-v.y)/v.height*v.height*L+h.y,e={box:v,ratio:L,points:u},i*=L,n*=L}return{centerX:t,centerY:s,radius:i,innerRadius:n,debug:e}}),[a,o,c,g,b,C,x]),P=L({data:t,startAngle:g,endAngle:b,innerRadius:E.innerRadius,outerRadius:E.radius,padAngle:A,sortByValue:R,activeId:W,activeInnerRadiusOffset:M,activeOuterRadiusOffset:T,hiddenIds:B}),D=e.useCallback((function(e){V((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return d({arcGenerator:r.useArcGenerator({cornerRadius:x,padAngle:i.degreesToRadians(A)}),setActiveId:w,toggleSerie:D},P,E)},b=function(i){var r=i.dataWithArc,n=i.arcGenerator,t=i.centerX,a=i.centerY,o=i.radius,s=i.innerRadius;return e.useMemo((function(){return{dataWithArc:r,arcGenerator:n,centerX:t,centerY:a,radius:o,innerRadius:s}}),[r,n,t,a,o,s])},p=function(i){var n=i.center,a=i.data,o=i.arcGenerator,d=i.borderWidth,l=i.borderColor,c=i.isInteractive,u=i.onClick,v=i.onMouseEnter,f=i.onMouseMove,g=i.onMouseLeave,L=i.setActiveId,h=i.tooltip,b=i.transitionMode,p=s.useTooltip(),A=p.showTooltipFromEvent,k=p.hideTooltip,R=e.useMemo((function(){if(c)return function(e,i){null==u||u(e,i)}}),[c,u]),m=e.useMemo((function(){if(c)return function(i,r){A(e.createElement(h,{datum:i}),r),L(i.id),null==v||v(i,r)}}),[c,A,L,v,h]),x=e.useMemo((function(){if(c)return function(i,r){A(e.createElement(h,{datum:i}),r),null==f||f(i,r)}}),[c,A,f,h]),O=e.useMemo((function(){if(c)return function(e,i){k(),L(null),null==g||g(e,i)}}),[c,k,L,g]);return t.jsx(r.ArcsLayer,{center:n,data:a,arcGenerator:o,borderWidth:d,borderColor:l,transitionMode:b,onClick:R,onMouseEnter:m,onMouseMove:x,onMouseLeave:O})},A=["isInteractive","animate","motionConfig","theme","renderWrapper"],k=function(n){var a=n.data,o=n.id,s=void 0===o?v.id:o,d=n.value,l=void 0===d?v.value:d,c=n.valueFormat,f=n.sortByValue,L=void 0===f?v.sortByValue:f,A=n.layers,k=void 0===A?v.layers:A,R=n.startAngle,m=void 0===R?v.startAngle:R,x=n.endAngle,O=void 0===x?v.endAngle:x,C=n.padAngle,I=void 0===C?v.padAngle:C,M=n.fit,y=void 0===M?v.fit:M,T=n.innerRadius,S=void 0===T?v.innerRadius:T,W=n.cornerRadius,w=void 0===W?v.cornerRadius:W,j=n.activeInnerRadiusOffset,B=void 0===j?v.activeInnerRadiusOffset:j,V=n.activeOuterRadiusOffset,E=void 0===V?v.activeOuterRadiusOffset:V,P=n.width,D=n.height,G=n.margin,F=n.colors,q=void 0===F?v.colors:F,H=n.borderWidth,X=void 0===H?v.borderWidth:H,Y=n.borderColor,z=void 0===Y?v.borderColor:Y,N=n.enableArcLabels,U=void 0===N?v.enableArcLabels:N,J=n.arcLabel,K=void 0===J?v.arcLabel:J,Q=n.arcLabelsSkipAngle,Z=void 0===Q?v.arcLabelsSkipAngle:Q,$=n.arcLabelsTextColor,_=void 0===$?v.arcLabelsTextColor:$,ee=n.arcLabelsRadiusOffset,ie=void 0===ee?v.arcLabelsRadiusOffset:ee,re=n.arcLabelsComponent,ne=n.enableArcLinkLabels,te=void 0===ne?v.enableArcLinkLabels:ne,ae=n.arcLinkLabel,oe=void 0===ae?v.arcLinkLabel:ae,se=n.arcLinkLabelsSkipAngle,de=void 0===se?v.arcLinkLabelsSkipAngle:se,le=n.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=n.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=n.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=n.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=n.arcLinkLabelsTextOffset,pe=void 0===be?v.arcLinkLabelsTextOffset:be,Ae=n.arcLinkLabelsTextColor,ke=void 0===Ae?v.arcLinkLabelsTextColor:Ae,Re=n.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,xe=n.arcLinkLabelComponent,Oe=n.defs,Ce=void 0===Oe?v.defs:Oe,Ie=n.fill,Me=void 0===Ie?v.fill:Ie,ye=n.isInteractive,Te=void 0===ye?v.isInteractive:ye,Se=n.onClick,We=n.onMouseEnter,we=n.onMouseMove,je=n.onMouseLeave,Be=n.tooltip,Ve=void 0===Be?v.tooltip:Be,Ee=n.transitionMode,Pe=void 0===Ee?v.transitionMode:Ee,De=n.legends,Ge=void 0===De?v.legends:De,Fe=n.role,qe=void 0===Fe?v.role:Fe,He=i.useDimensions(P,D,G),Xe=He.outerWidth,Ye=He.outerHeight,ze=He.margin,Ne=He.innerWidth,Ue=He.innerHeight,Je=g({data:a,id:s,value:l,valueFormat:c,colors:q}),Ke=h({data:Je,width:Ne,height:Ue,fit:y,innerRadius:S,startAngle:m,endAngle:O,padAngle:I,sortByValue:L,cornerRadius:w,activeInnerRadiusOffset:B,activeOuterRadiusOffset:E}),Qe=Ke.dataWithArc,Ze=Ke.legendData,$e=Ke.arcGenerator,_e=Ke.centerX,ei=Ke.centerY,ii=Ke.radius,ri=Ke.innerRadius,ni=Ke.setActiveId,ti=Ke.toggleSerie,ai=i.bindDefs(Ce,Qe,Me),oi={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};k.includes("arcs")&&(oi.arcs=t.jsx(p,{center:[_e,ei],data:Qe,arcGenerator:$e,borderWidth:X,borderColor:z,isInteractive:Te,onClick:Se,onMouseEnter:We,onMouseMove:we,onMouseLeave:je,setActiveId:ni,tooltip:Ve,transitionMode:Pe},"arcs")),te&&k.includes("arcLinkLabels")&&(oi.arcLinkLabels=t.jsx(r.ArcLinkLabelsLayer,{center:[_e,ei],data:Qe,label:oe,skipAngle:de,offset:ce,diagonalLength:ve,straightLength:ge,strokeWidth:he,textOffset:pe,textColor:ke,linkColor:me,component:xe},"arcLinkLabels")),U&&k.includes("arcLabels")&&(oi.arcLabels=t.jsx(r.ArcLabelsLayer,{center:[_e,ei],data:Qe,label:K,radiusOffset:ie,skipAngle:Z,textColor:_,transitionMode:Pe,component:re},"arcLabels")),Ge.length>0&&k.includes("legends")&&(oi.legends=t.jsx(u,{width:Ne,height:Ue,data:Ze,legends:Ge,toggleSerie:ti},"legends"));var si=b({dataWithArc:Qe,arcGenerator:$e,centerX:_e,centerY:ei,radius:ii,innerRadius:ri});return t.jsx(i.SvgWrapper,{width:Xe,height:Ye,margin:ze,defs:ai,role:qe,children:k.map((function(i,r){return void 0!==oi[i]?oi[i]:"function"==typeof i?t.jsx(e.Fragment,{children:e.createElement(i,si)},r):null}))})},R=function(e){var r=e.isInteractive,n=void 0===r?v.isInteractive:r,a=e.animate,o=void 0===a?v.animate:a,s=e.motionConfig,c=void 0===s?v.motionConfig:s,u=e.theme,f=e.renderWrapper,g=l(e,A);return t.jsx(i.Container,{animate:o,isInteractive:n,motionConfig:c,renderWrapper:f,theme:u,children:t.jsx(k,d({isInteractive:n},g))})},m=["isInteractive","theme","renderWrapper"],x=function(a){var l=a.data,c=a.id,u=void 0===c?v.id:c,f=a.value,L=void 0===f?v.value:f,b=a.valueFormat,p=a.sortByValue,A=void 0===p?v.sortByValue:p,k=a.startAngle,R=void 0===k?v.startAngle:k,m=a.endAngle,x=void 0===m?v.endAngle:m,O=a.padAngle,C=void 0===O?v.padAngle:O,I=a.fit,M=void 0===I?v.fit:I,y=a.innerRadius,T=void 0===y?v.innerRadius:y,S=a.cornerRadius,W=void 0===S?v.cornerRadius:S,w=a.activeInnerRadiusOffset,j=void 0===w?v.activeInnerRadiusOffset:w,B=a.activeOuterRadiusOffset,V=void 0===B?v.activeOuterRadiusOffset:B,E=a.width,P=a.height,D=a.margin,G=a.pixelRatio,F=void 0===G?1:G,q=a.colors,H=void 0===q?v.colors:q,X=a.borderWidth,Y=void 0===X?v.borderWidth:X,z=a.borderColor,N=void 0===z?v.borderColor:z,U=a.enableArcLabels,J=void 0===U?v.enableArcLabels:U,K=a.arcLabel,Q=void 0===K?v.arcLabel:K,Z=a.arcLabelsSkipAngle,$=void 0===Z?v.arcLabelsSkipAngle:Z,_=a.arcLabelsTextColor,ee=void 0===_?v.arcLabelsTextColor:_,ie=a.arcLabelsRadiusOffset,re=void 0===ie?v.arcLabelsRadiusOffset:ie,ne=a.enableArcLinkLabels,te=void 0===ne?v.enableArcLinkLabels:ne,ae=a.arcLinkLabel,oe=void 0===ae?v.arcLinkLabel:ae,se=a.arcLinkLabelsSkipAngle,de=void 0===se?v.arcLinkLabelsSkipAngle:se,le=a.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=a.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=a.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=a.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=a.arcLinkLabelsTextOffset,pe=void 0===be?v.arcLinkLabelsTextOffset:be,Ae=a.arcLinkLabelsTextColor,ke=void 0===Ae?v.arcLinkLabelsTextColor:Ae,Re=a.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,xe=a.isInteractive,Oe=void 0===xe?v.isInteractive:xe,Ce=a.onClick,Ie=a.onMouseMove,Me=a.tooltip,ye=void 0===Me?v.tooltip:Me,Te=a.legends,Se=void 0===Te?v.legends:Te,We=e.useRef(null),we=i.useTheme(),je=i.useDimensions(E,P,D),Be=je.margin,Ve=je.innerWidth,Ee=je.innerHeight,Pe=je.outerWidth,De=je.outerHeight,Ge=g({data:l,id:u,value:L,valueFormat:b,colors:H}),Fe=h({data:Ge,width:Ve,height:Ee,fit:M,innerRadius:T,startAngle:R,endAngle:x,padAngle:C,sortByValue:A,cornerRadius:W,activeInnerRadiusOffset:j,activeOuterRadiusOffset:V}),qe=Fe.dataWithArc,He=Fe.arcGenerator,Xe=Fe.centerX,Ye=Fe.centerY,ze=Fe.radius,Ne=Fe.innerRadius,Ue=Fe.setActiveId,Je=o.useInheritedColor(N,we),Ke=r.useArcLabels({data:qe,label:Q,skipAngle:$,offset:re,textColor:ee}),Qe=r.useArcLinkLabels({data:qe,skipAngle:de,offset:ce,diagonalLength:ve,straightLength:ge,label:oe,linkColor:me,textOffset:pe,textColor:ke});e.useEffect((function(){if(We.current){We.current.width=Pe*F,We.current.height=De*F;var e=We.current.getContext("2d");e.scale(F,F),e.fillStyle=we.background,e.fillRect(0,0,Pe,De),e.save(),e.translate(Be.left,Be.top),He.context(e),e.save(),e.translate(Xe,Ye),qe.forEach((function(i){e.beginPath(),e.fillStyle=i.color,e.strokeStyle=Je(i),e.lineWidth=Y,He(i.arc),e.fill(),Y>0&&e.stroke()})),!0===te&&r.drawCanvasArcLinkLabels(e,Qe,we,he),!0===J&&r.drawCanvasArcLabels(e,Ke,we),e.restore(),Se.forEach((function(i){n.renderLegendToCanvas(e,d({},i,{data:qe,containerWidth:Ve,containerHeight:Ee,theme:we}))}))}}),[We,Ve,Ee,Pe,De,Be.top,Be.left,F,Xe,Ye,He,qe,Je,J,Ke,te,Qe,he,Se,we]);var Ze=e.useMemo((function(){return qe.map((function(e){return d({id:e.id},e.arc)}))}),[qe]),$e=function(e){if(!We.current)return null;var n=i.getRelativeCursor(We.current,e),t=n[0],a=n[1],o=r.findArcUnderCursor(Be.left+Xe,Be.top+Ye,ze,Ne,Ze,t,a);return o?qe.find((function(e){return e.id===o.id})):null},_e=s.useTooltip(),ei=_e.showTooltipFromEvent,ii=_e.hideTooltip,ri=function(i){var r=$e(i);r?(null==Ie||Ie(r,i),Ue(r.id),ei(e.createElement(ye,{datum:r}),i)):(Ue(null),ii())};return t.jsx("canvas",{ref:We,width:Pe*F,height:De*F,style:{width:Pe,height:De,cursor:Oe?"auto":"normal"},onMouseEnter:Oe?ri:void 0,onMouseMove:Oe?ri:void 0,onMouseLeave:Oe?function(){ii()}:void 0,onClick:Oe?function(e){if(Ce){var i=$e(e);i&&Ce(i,e)}}:void 0})},O=function(e){var r=e.isInteractive,n=void 0===r?v.isInteractive:r,a=e.theme,o=e.renderWrapper,s=l(e,m);return t.jsx(i.Container,{isInteractive:n,renderWrapper:o,theme:a,children:t.jsx(x,d({isInteractive:n},s))})};exports.Pie=R,exports.PieCanvas=O,exports.ResponsivePie=function(e){return t.jsx(i.ResponsiveWrapper,{children:function(i){var r=i.width,n=i.height;return t.jsx(R,d({width:r,height:n},e))}})},exports.ResponsivePieCanvas=function(e){return t.jsx(i.ResponsiveWrapper,{children:function(i){var r=i.width,n=i.height;return t.jsx(O,d({width:r,height:n},e))}})},exports.defaultProps=v,exports.useNormalizedData=g,exports.usePie=function(n){var t=n.data,a=n.radius,o=n.innerRadius,s=n.startAngle,l=void 0===s?v.startAngle:s,c=n.endAngle,u=void 0===c?v.endAngle:c,f=n.padAngle,g=void 0===f?v.padAngle:f,h=n.sortByValue,b=void 0===h?v.sortByValue:h,p=n.cornerRadius,A=void 0===p?v.cornerRadius:p,k=n.activeInnerRadiusOffset,R=void 0===k?v.activeInnerRadiusOffset:k,m=n.activeOuterRadiusOffset,x=void 0===m?v.activeOuterRadiusOffset:m,O=e.useState(null),C=O[0],I=O[1],M=e.useState([]),y=M[0],T=M[1],S=L({data:t,startAngle:l,endAngle:u,innerRadius:o,outerRadius:a,padAngle:g,sortByValue:b,activeId:C,activeInnerRadiusOffset:R,activeOuterRadiusOffset:x,hiddenIds:y}),W=e.useCallback((function(e){T((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return d({},S,{arcGenerator:r.useArcGenerator({cornerRadius:A,padAngle:i.degreesToRadians(g)}),setActiveId:I,toggleSerie:W})},exports.usePieArcs=L,exports.usePieFromBox=h,exports.usePieLayerContext=b; | ||
"use strict";var e=require("react"),t=require("@nivo/core"),a=require("@nivo/arcs"),i=require("@nivo/legends"),n=require("react/jsx-runtime"),r=require("d3-shape"),o=require("@nivo/colors"),d=require("@nivo/tooltip");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var i in a)Object.prototype.hasOwnProperty.call(a,i)&&(e[i]=a[i])}return e},s.apply(this,arguments)}function l(e,t){if(null==e)return{};var a,i,n={},r=Object.keys(e);for(i=0;i<r.length;i++)a=r[i],t.indexOf(a)>=0||(n[a]=e[a]);return n}var c,u=function(e){var t=e.width,a=e.height,r=e.legends,o=e.data,d=e.toggleSerie;return n.jsx(n.Fragment,{children:r.map((function(e,r){var l;return n.jsx(i.BoxLegendSvg,s({},e,{containerWidth:t,containerHeight:a,data:null!=(l=e.data)?l:o,toggleSerie:e.toggleSerie?d:void 0}),r)}))})},v={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var t=e.datum;return n.jsx(d.BasicTooltip,{id:t.id,value:t.formattedValue,enableChip:!0,color:t.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(c=window.devicePixelRatio)?c:1},f=["points"],g=function(a){var i=a.data,n=a.id,r=void 0===n?v.id:n,d=a.value,l=void 0===d?v.value:d,c=a.valueFormat,u=a.colors,f=void 0===u?v.colors:u,g=t.usePropertyAccessor(r),L=t.usePropertyAccessor(l),h=t.useValueFormatter(c),b=o.useOrdinalColorScale(f,"id");return e.useMemo((function(){return i.map((function(e){var t,a=g(e),i=L(e),n={id:a,label:null!=(t=e.label)?t:a,hidden:!1,value:i,formattedValue:h(i),data:e};return s({},n,{color:b(n)})}))}),[i,g,L,h,b])},L=function(a){var i=a.data,n=a.startAngle,o=a.endAngle,d=a.innerRadius,l=a.outerRadius,c=a.padAngle,u=a.sortByValue,v=a.activeId,f=a.activeInnerRadiusOffset,g=a.activeOuterRadiusOffset,L=a.hiddenIds,h=a.forwardLegendData,b=e.useMemo((function(){var e=r.pie().value((function(e){return e.value})).startAngle(t.degreesToRadians(n)).endAngle(t.degreesToRadians(o)).padAngle(t.degreesToRadians(c));return u||e.sortValues(null),e}),[n,o,c,u]),A=e.useMemo((function(){var e=i.filter((function(e){return!L.includes(e.id)}));return{dataWithArc:b(e).map((function(e){var a=Math.abs(e.endAngle-e.startAngle);return s({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:v===e.data.id?d-f:d,outerRadius:v===e.data.id?l+g:l,thickness:l-d,padAngle:e.padAngle,angle:a,angleDeg:t.radiansToDegrees(a)}})})),legendData:i.map((function(e){return{id:e.id,label:e.label,color:e.color,hidden:L.includes(e.id),data:e}}))}}),[b,i,L,v,d,f,l,g]),p=A.legendData,k=e.useRef(h);return e.useEffect((function(){"function"==typeof k.current&&k.current(p)}),[k,p]),A},h=function(t){var a=t.activeId,i=t.onActiveIdChange,n=t.defaultActiveId,r=void 0===n?null:n,o=void 0!==a,d=e.useState(o?null:r),s=d[0],l=d[1];return{activeId:o?a:s,setActiveId:e.useCallback((function(e){i&&i(e),o||l(e)}),[o,i,l])}},b=function(i){var n=i.data,r=i.width,o=i.height,d=i.innerRadius,c=void 0===d?v.innerRadius:d,u=i.startAngle,g=void 0===u?v.startAngle:u,b=i.endAngle,A=void 0===b?v.endAngle:b,p=i.padAngle,k=void 0===p?v.padAngle:p,R=i.sortByValue,m=void 0===R?v.sortByValue:R,I=i.cornerRadius,x=void 0===I?v.cornerRadius:I,O=i.fit,C=void 0===O?v.fit:O,M=i.activeInnerRadiusOffset,w=void 0===M?v.activeInnerRadiusOffset:M,y=i.activeOuterRadiusOffset,T=void 0===y?v.activeOuterRadiusOffset:y,S=i.activeId,W=i.onActiveIdChange,j=i.defaultActiveId,D=i.forwardLegendData,B=h({activeId:S,onActiveIdChange:W,defaultActiveId:j}),V=B.activeId,E=B.setActiveId,P=e.useState([]),G=P[0],F=P[1],q=e.useMemo((function(){var e,t=Math.min(r,o)/2,i=t*Math.min(c,1),n=r/2,d=o/2;if(C){var s=a.computeArcBoundingBox(n,d,t,g-90,A-90),u=s.points,v=l(s,f),L=Math.min(r/v.width,o/v.height),h={width:v.width*L,height:v.height*L};h.x=(r-h.width)/2,h.y=(o-h.height)/2,n=(n-v.x)/v.width*v.width*L+h.x,d=(d-v.y)/v.height*v.height*L+h.y,e={box:v,ratio:L,points:u},t*=L,i*=L}return{centerX:n,centerY:d,radius:t,innerRadius:i,debug:e}}),[r,o,c,g,A,C]),H=L({data:n,startAngle:g,endAngle:A,innerRadius:q.innerRadius,outerRadius:q.radius,padAngle:k,sortByValue:m,activeId:V,activeInnerRadiusOffset:w,activeOuterRadiusOffset:T,hiddenIds:G,forwardLegendData:D}),X=e.useCallback((function(e){F((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return s({arcGenerator:a.useArcGenerator({cornerRadius:x,padAngle:t.degreesToRadians(k)}),activeId:V,setActiveId:E,toggleSerie:X},H,q)},A=function(t){var a=t.dataWithArc,i=t.arcGenerator,n=t.centerX,r=t.centerY,o=t.radius,d=t.innerRadius;return e.useMemo((function(){return{dataWithArc:a,arcGenerator:i,centerX:n,centerY:r,radius:o,innerRadius:d}}),[a,i,n,r,o,d])},p=function(t){var i=t.center,r=t.data,o=t.arcGenerator,s=t.borderWidth,l=t.borderColor,c=t.isInteractive,u=t.onClick,v=t.onMouseEnter,f=t.onMouseMove,g=t.onMouseLeave,L=t.setActiveId,h=t.tooltip,b=t.transitionMode,A=d.useTooltip(),p=A.showTooltipFromEvent,k=A.hideTooltip,R=e.useMemo((function(){if(c)return function(e,t){null==u||u(e,t)}}),[c,u]),m=e.useMemo((function(){if(c)return function(t,a){p(e.createElement(h,{datum:t}),a),L(t.id),null==v||v(t,a)}}),[c,p,L,v,h]),I=e.useMemo((function(){if(c)return function(t,a){p(e.createElement(h,{datum:t}),a),null==f||f(t,a)}}),[c,p,f,h]),x=e.useMemo((function(){if(c)return function(e,t){k(),L(null),null==g||g(e,t)}}),[c,k,L,g]);return n.jsx(a.ArcsLayer,{center:i,data:r,arcGenerator:o,borderWidth:s,borderColor:l,transitionMode:b,onClick:R,onMouseEnter:m,onMouseMove:I,onMouseLeave:x})},k=["isInteractive","animate","motionConfig","theme","renderWrapper"],R=function(i){var r=i.data,o=i.id,d=void 0===o?v.id:o,s=i.value,l=void 0===s?v.value:s,c=i.valueFormat,f=i.sortByValue,L=void 0===f?v.sortByValue:f,h=i.layers,k=void 0===h?v.layers:h,R=i.startAngle,m=void 0===R?v.startAngle:R,I=i.endAngle,x=void 0===I?v.endAngle:I,O=i.padAngle,C=void 0===O?v.padAngle:O,M=i.fit,w=void 0===M?v.fit:M,y=i.innerRadius,T=void 0===y?v.innerRadius:y,S=i.cornerRadius,W=void 0===S?v.cornerRadius:S,j=i.activeInnerRadiusOffset,D=void 0===j?v.activeInnerRadiusOffset:j,B=i.activeOuterRadiusOffset,V=void 0===B?v.activeOuterRadiusOffset:B,E=i.width,P=i.height,G=i.margin,F=i.colors,q=void 0===F?v.colors:F,H=i.borderWidth,X=void 0===H?v.borderWidth:H,Y=i.borderColor,z=void 0===Y?v.borderColor:Y,N=i.enableArcLabels,U=void 0===N?v.enableArcLabels:N,J=i.arcLabel,K=void 0===J?v.arcLabel:J,Q=i.arcLabelsSkipAngle,Z=void 0===Q?v.arcLabelsSkipAngle:Q,$=i.arcLabelsTextColor,_=void 0===$?v.arcLabelsTextColor:$,ee=i.arcLabelsRadiusOffset,te=void 0===ee?v.arcLabelsRadiusOffset:ee,ae=i.arcLabelsComponent,ie=i.enableArcLinkLabels,ne=void 0===ie?v.enableArcLinkLabels:ie,re=i.arcLinkLabel,oe=void 0===re?v.arcLinkLabel:re,de=i.arcLinkLabelsSkipAngle,se=void 0===de?v.arcLinkLabelsSkipAngle:de,le=i.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=i.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=i.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=i.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=i.arcLinkLabelsTextOffset,Ae=void 0===be?v.arcLinkLabelsTextOffset:be,pe=i.arcLinkLabelsTextColor,ke=void 0===pe?v.arcLinkLabelsTextColor:pe,Re=i.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,Ie=i.arcLinkLabelComponent,xe=i.defs,Oe=void 0===xe?v.defs:xe,Ce=i.fill,Me=void 0===Ce?v.fill:Ce,we=i.isInteractive,ye=void 0===we?v.isInteractive:we,Te=i.onClick,Se=i.onMouseEnter,We=i.onMouseMove,je=i.onMouseLeave,De=i.tooltip,Be=void 0===De?v.tooltip:De,Ve=i.activeId,Ee=i.onActiveIdChange,Pe=i.defaultActiveId,Ge=i.transitionMode,Fe=void 0===Ge?v.transitionMode:Ge,qe=i.legends,He=void 0===qe?v.legends:qe,Xe=i.forwardLegendData,Ye=i.role,ze=void 0===Ye?v.role:Ye,Ne=t.useDimensions(E,P,G),Ue=Ne.outerWidth,Je=Ne.outerHeight,Ke=Ne.margin,Qe=Ne.innerWidth,Ze=Ne.innerHeight,$e=g({data:r,id:d,value:l,valueFormat:c,colors:q}),_e=b({data:$e,width:Qe,height:Ze,fit:w,innerRadius:T,startAngle:m,endAngle:x,padAngle:C,sortByValue:L,cornerRadius:W,activeInnerRadiusOffset:D,activeOuterRadiusOffset:V,activeId:Ve,onActiveIdChange:Ee,defaultActiveId:Pe,forwardLegendData:Xe}),et=_e.dataWithArc,tt=_e.legendData,at=_e.arcGenerator,it=_e.centerX,nt=_e.centerY,rt=_e.radius,ot=_e.innerRadius,dt=_e.setActiveId,st=_e.toggleSerie,lt=t.bindDefs(Oe,et,Me),ct={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};k.includes("arcs")&&(ct.arcs=n.jsx(p,{center:[it,nt],data:et,arcGenerator:at,borderWidth:X,borderColor:z,isInteractive:ye,onClick:Te,onMouseEnter:Se,onMouseMove:We,onMouseLeave:je,setActiveId:dt,tooltip:Be,transitionMode:Fe},"arcs")),ne&&k.includes("arcLinkLabels")&&(ct.arcLinkLabels=n.jsx(a.ArcLinkLabelsLayer,{center:[it,nt],data:et,label:oe,skipAngle:se,offset:ce,diagonalLength:ve,straightLength:ge,strokeWidth:he,textOffset:Ae,textColor:ke,linkColor:me,component:Ie},"arcLinkLabels")),U&&k.includes("arcLabels")&&(ct.arcLabels=n.jsx(a.ArcLabelsLayer,{center:[it,nt],data:et,label:K,radiusOffset:te,skipAngle:Z,textColor:_,transitionMode:Fe,component:ae},"arcLabels")),He.length>0&&k.includes("legends")&&(ct.legends=n.jsx(u,{width:Qe,height:Ze,data:tt,legends:He,toggleSerie:st},"legends"));var ut=A({dataWithArc:et,arcGenerator:at,centerX:it,centerY:nt,radius:rt,innerRadius:ot});return n.jsx(t.SvgWrapper,{width:Ue,height:Je,margin:Ke,defs:lt,role:ze,children:k.map((function(t,a){return void 0!==ct[t]?ct[t]:"function"==typeof t?n.jsx(e.Fragment,{children:e.createElement(t,ut)},a):null}))})},m=function(e){var a=e.isInteractive,i=void 0===a?v.isInteractive:a,r=e.animate,o=void 0===r?v.animate:r,d=e.motionConfig,c=void 0===d?v.motionConfig:d,u=e.theme,f=e.renderWrapper,g=l(e,k);return n.jsx(t.Container,{animate:o,isInteractive:i,motionConfig:c,renderWrapper:f,theme:u,children:n.jsx(R,s({isInteractive:i},g))})},I=["isInteractive","theme","renderWrapper"],x=function(r){var l=r.data,c=r.id,u=void 0===c?v.id:c,f=r.value,L=void 0===f?v.value:f,h=r.valueFormat,A=r.sortByValue,p=void 0===A?v.sortByValue:A,k=r.startAngle,R=void 0===k?v.startAngle:k,m=r.endAngle,I=void 0===m?v.endAngle:m,x=r.padAngle,O=void 0===x?v.padAngle:x,C=r.fit,M=void 0===C?v.fit:C,w=r.innerRadius,y=void 0===w?v.innerRadius:w,T=r.cornerRadius,S=void 0===T?v.cornerRadius:T,W=r.activeInnerRadiusOffset,j=void 0===W?v.activeInnerRadiusOffset:W,D=r.activeOuterRadiusOffset,B=void 0===D?v.activeOuterRadiusOffset:D,V=r.width,E=r.height,P=r.margin,G=r.pixelRatio,F=void 0===G?v.pixelRatio:G,q=r.colors,H=void 0===q?v.colors:q,X=r.borderWidth,Y=void 0===X?v.borderWidth:X,z=r.borderColor,N=void 0===z?v.borderColor:z,U=r.enableArcLabels,J=void 0===U?v.enableArcLabels:U,K=r.arcLabel,Q=void 0===K?v.arcLabel:K,Z=r.arcLabelsSkipAngle,$=void 0===Z?v.arcLabelsSkipAngle:Z,_=r.arcLabelsTextColor,ee=void 0===_?v.arcLabelsTextColor:_,te=r.arcLabelsRadiusOffset,ae=void 0===te?v.arcLabelsRadiusOffset:te,ie=r.enableArcLinkLabels,ne=void 0===ie?v.enableArcLinkLabels:ie,re=r.arcLinkLabel,oe=void 0===re?v.arcLinkLabel:re,de=r.arcLinkLabelsSkipAngle,se=void 0===de?v.arcLinkLabelsSkipAngle:de,le=r.arcLinkLabelsOffset,ce=void 0===le?v.arcLinkLabelsOffset:le,ue=r.arcLinkLabelsDiagonalLength,ve=void 0===ue?v.arcLinkLabelsDiagonalLength:ue,fe=r.arcLinkLabelsStraightLength,ge=void 0===fe?v.arcLinkLabelsStraightLength:fe,Le=r.arcLinkLabelsThickness,he=void 0===Le?v.arcLinkLabelsThickness:Le,be=r.arcLinkLabelsTextOffset,Ae=void 0===be?v.arcLinkLabelsTextOffset:be,pe=r.arcLinkLabelsTextColor,ke=void 0===pe?v.arcLinkLabelsTextColor:pe,Re=r.arcLinkLabelsColor,me=void 0===Re?v.arcLinkLabelsColor:Re,Ie=r.isInteractive,xe=void 0===Ie?v.isInteractive:Ie,Oe=r.onClick,Ce=r.onMouseMove,Me=r.tooltip,we=void 0===Me?v.tooltip:Me,ye=r.activeId,Te=r.onActiveIdChange,Se=r.defaultActiveId,We=r.legends,je=void 0===We?v.legends:We,De=r.forwardLegendData,Be=e.useRef(null),Ve=t.useTheme(),Ee=t.useDimensions(V,E,P),Pe=Ee.margin,Ge=Ee.innerWidth,Fe=Ee.innerHeight,qe=Ee.outerWidth,He=Ee.outerHeight,Xe=g({data:l,id:u,value:L,valueFormat:h,colors:H}),Ye=b({data:Xe,width:Ge,height:Fe,fit:M,innerRadius:y,startAngle:R,endAngle:I,padAngle:O,sortByValue:p,cornerRadius:S,activeInnerRadiusOffset:j,activeOuterRadiusOffset:B,activeId:ye,onActiveIdChange:Te,defaultActiveId:Se,forwardLegendData:De}),ze=Ye.dataWithArc,Ne=Ye.arcGenerator,Ue=Ye.centerX,Je=Ye.centerY,Ke=Ye.radius,Qe=Ye.innerRadius,Ze=Ye.setActiveId,$e=o.useInheritedColor(N,Ve),_e=a.useArcLabels({data:ze,label:Q,skipAngle:$,offset:ae,textColor:ee}),et=a.useArcLinkLabels({data:ze,skipAngle:se,offset:ce,diagonalLength:ve,straightLength:ge,label:oe,linkColor:me,textOffset:Ae,textColor:ke});e.useEffect((function(){if(Be.current){Be.current.width=qe*F,Be.current.height=He*F;var e=Be.current.getContext("2d");e.scale(F,F),e.fillStyle=Ve.background,e.fillRect(0,0,qe,He),e.save(),e.translate(Pe.left,Pe.top),Ne.context(e),e.save(),e.translate(Ue,Je),ze.forEach((function(t){e.beginPath(),e.fillStyle=t.color,e.strokeStyle=$e(t),e.lineWidth=Y,Ne(t.arc),e.fill(),Y>0&&e.stroke()})),!0===ne&&a.drawCanvasArcLinkLabels(e,et,Ve,he),!0===J&&a.drawCanvasArcLabels(e,_e,Ve),e.restore(),je.forEach((function(t){i.renderLegendToCanvas(e,s({},t,{data:ze,containerWidth:Ge,containerHeight:Fe,theme:Ve}))}))}}),[Be,Ge,Fe,qe,He,Pe.top,Pe.left,F,Ue,Je,Ne,ze,Y,$e,J,_e,ne,et,he,je,Ve]);var tt=e.useMemo((function(){return ze.map((function(e){return s({id:e.id},e.arc)}))}),[ze]),at=function(e){if(!Be.current)return null;var i=t.getRelativeCursor(Be.current,e),n=i[0],r=i[1],o=a.findArcUnderCursor(Pe.left+Ue,Pe.top+Je,Ke,Qe,tt,n,r);return o?ze.find((function(e){return e.id===o.id})):null},it=d.useTooltip(),nt=it.showTooltipFromEvent,rt=it.hideTooltip,ot=function(t){var a=at(t);a?(null==Ce||Ce(a,t),Ze(a.id),nt(e.createElement(we,{datum:a}),t)):(Ze(null),rt())};return n.jsx("canvas",{ref:Be,width:qe*F,height:He*F,style:{width:qe,height:He,cursor:xe?"auto":"normal"},onMouseEnter:xe?ot:void 0,onMouseMove:xe?ot:void 0,onMouseLeave:xe?function(){rt()}:void 0,onClick:xe?function(e){if(Oe){var t=at(e);t&&Oe(t,e)}}:void 0})},O=function(e){var a=e.isInteractive,i=void 0===a?v.isInteractive:a,r=e.theme,o=e.renderWrapper,d=l(e,I);return n.jsx(t.Container,{isInteractive:i,renderWrapper:o,theme:r,children:n.jsx(x,s({isInteractive:i},d))})};exports.Pie=m,exports.PieCanvas=O,exports.ResponsivePie=function(e){return n.jsx(t.ResponsiveWrapper,{children:function(t){var a=t.width,i=t.height;return n.jsx(m,s({width:a,height:i},e))}})},exports.ResponsivePieCanvas=function(e){return n.jsx(t.ResponsiveWrapper,{children:function(t){var a=t.width,i=t.height;return n.jsx(O,s({width:a,height:i},e))}})},exports.defaultProps=v,exports.useNormalizedData=g,exports.usePie=function(i){var n=i.data,r=i.radius,o=i.innerRadius,d=i.startAngle,l=void 0===d?v.startAngle:d,c=i.endAngle,u=void 0===c?v.endAngle:c,f=i.padAngle,g=void 0===f?v.padAngle:f,b=i.sortByValue,A=void 0===b?v.sortByValue:b,p=i.cornerRadius,k=void 0===p?v.cornerRadius:p,R=i.activeInnerRadiusOffset,m=void 0===R?v.activeInnerRadiusOffset:R,I=i.activeOuterRadiusOffset,x=void 0===I?v.activeOuterRadiusOffset:I,O=i.activeId,C=i.onActiveIdChange,M=i.defaultActiveId,w=i.forwardLegendData,y=h({activeId:O,onActiveIdChange:C,defaultActiveId:M}),T=y.activeId,S=y.setActiveId,W=e.useState([]),j=W[0],D=W[1],B=L({data:n,startAngle:l,endAngle:u,innerRadius:o,outerRadius:r,padAngle:g,sortByValue:A,activeId:T,activeInnerRadiusOffset:m,activeOuterRadiusOffset:x,hiddenIds:j,forwardLegendData:w}),V=e.useCallback((function(e){D((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return s({},B,{arcGenerator:a.useArcGenerator({cornerRadius:k,padAngle:t.degreesToRadians(g)}),setActiveId:S,toggleSerie:V})},exports.usePieArcs=L,exports.usePieFromBox=b,exports.usePieLayerContext=A; | ||
//# sourceMappingURL=nivo-pie.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
import{useMemo as e,useState as i,useCallback as n,createElement as t,Fragment as r,useRef as a,useEffect as o}from"react";import{usePropertyAccessor as d,useValueFormatter as l,degreesToRadians as s,radiansToDegrees as c,Container as u,useDimensions as v,bindDefs as f,SvgWrapper as g,ResponsiveWrapper as L,useTheme as h,getRelativeCursor as b}from"@nivo/core";import{useArcGenerator as p,computeArcBoundingBox as k,ArcsLayer as A,ArcLinkLabelsLayer as R,ArcLabelsLayer as m,useArcLabels as O,useArcLinkLabels as C,drawCanvasArcLinkLabels as I,drawCanvasArcLabels as x,findArcUnderCursor as M}from"@nivo/arcs";import{BoxLegendSvg as y,renderLegendToCanvas as w}from"@nivo/legends";import{jsx as W,Fragment as S}from"react/jsx-runtime";import{pie as T}from"d3-shape";import{useOrdinalColorScale as V,useInheritedColor as B}from"@nivo/colors";import{BasicTooltip as G,useTooltip as E}from"@nivo/tooltip";function D(){return D=Object.assign?Object.assign.bind():function(e){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},D.apply(this,arguments)}function F(e,i){if(null==e)return{};var n,t,r={},a=Object.keys(e);for(t=0;t<a.length;t++)n=a[t],i.indexOf(n)>=0||(r[n]=e[n]);return r}var H,X=function(e){var i=e.width,n=e.height,t=e.legends,r=e.data,a=e.toggleSerie;return W(S,{children:t.map((function(e,t){var o;return W(y,D({},e,{containerWidth:i,containerHeight:n,data:null!=(o=e.data)?o:r,toggleSerie:e.toggleSerie?a:void 0}),t)}))})},Y={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var i=e.datum;return W(G,{id:i.id,value:i.formattedValue,enableChip:!0,color:i.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(H=window.devicePixelRatio)?H:1},j=["points"],P=function(i){var n=i.data,t=i.id,r=void 0===t?Y.id:t,a=i.value,o=void 0===a?Y.value:a,s=i.valueFormat,c=i.colors,u=void 0===c?Y.colors:c,v=d(r),f=d(o),g=l(s),L=V(u,"id");return e((function(){return n.map((function(e){var i,n=v(e),t=f(e),r={id:n,label:null!=(i=e.label)?i:n,hidden:!1,value:t,formattedValue:g(t),data:e};return D({},r,{color:L(r)})}))}),[n,v,f,g,L])},q=function(i){var n=i.data,t=i.startAngle,r=i.endAngle,a=i.innerRadius,o=i.outerRadius,d=i.padAngle,l=i.sortByValue,u=i.activeId,v=i.activeInnerRadiusOffset,f=i.activeOuterRadiusOffset,g=i.hiddenIds,L=e((function(){var e=T().value((function(e){return e.value})).startAngle(s(t)).endAngle(s(r)).padAngle(s(d));return l||e.sortValues(null),e}),[t,r,d,l]);return e((function(){var e=n.filter((function(e){return!g.includes(e.id)}));return{dataWithArc:L(e).map((function(e){var i=Math.abs(e.endAngle-e.startAngle);return D({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:u===e.data.id?a-v:a,outerRadius:u===e.data.id?o+f:o,thickness:o-a,padAngle:e.padAngle,angle:i,angleDeg:c(i)}})})),legendData:n.map((function(e){return D({},e,{hidden:g.includes(e.id)})}))}}),[L,n,g,u,a,v,o,f])},z=function(e){var t=e.data,r=e.radius,a=e.innerRadius,o=e.startAngle,d=void 0===o?Y.startAngle:o,l=e.endAngle,c=void 0===l?Y.endAngle:l,u=e.padAngle,v=void 0===u?Y.padAngle:u,f=e.sortByValue,g=void 0===f?Y.sortByValue:f,L=e.cornerRadius,h=void 0===L?Y.cornerRadius:L,b=e.activeInnerRadiusOffset,k=void 0===b?Y.activeInnerRadiusOffset:b,A=e.activeOuterRadiusOffset,R=void 0===A?Y.activeOuterRadiusOffset:A,m=i(null),O=m[0],C=m[1],I=i([]),x=I[0],M=I[1],y=q({data:t,startAngle:d,endAngle:c,innerRadius:a,outerRadius:r,padAngle:v,sortByValue:g,activeId:O,activeInnerRadiusOffset:k,activeOuterRadiusOffset:R,hiddenIds:x}),w=n((function(e){M((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return D({},y,{arcGenerator:p({cornerRadius:h,padAngle:s(v)}),setActiveId:C,toggleSerie:w})},J=function(t){var r=t.data,a=t.width,o=t.height,d=t.innerRadius,l=void 0===d?Y.innerRadius:d,c=t.startAngle,u=void 0===c?Y.startAngle:c,v=t.endAngle,f=void 0===v?Y.endAngle:v,g=t.padAngle,L=void 0===g?Y.padAngle:g,h=t.sortByValue,b=void 0===h?Y.sortByValue:h,A=t.cornerRadius,R=void 0===A?Y.cornerRadius:A,m=t.fit,O=void 0===m?Y.fit:m,C=t.activeInnerRadiusOffset,I=void 0===C?Y.activeInnerRadiusOffset:C,x=t.activeOuterRadiusOffset,M=void 0===x?Y.activeOuterRadiusOffset:x,y=i(null),w=y[0],W=y[1],S=i([]),T=S[0],V=S[1],B=e((function(){var e,i=Math.min(a,o)/2,n=i*Math.min(l,1),t=a/2,r=o/2;if(O){var d=k(t,r,i,u-90,f-90),s=d.points,c=F(d,j),v=Math.min(a/c.width,o/c.height),g={width:c.width*v,height:c.height*v};g.x=(a-g.width)/2,g.y=(o-g.height)/2,t=(t-c.x)/c.width*c.width*v+g.x,r=(r-c.y)/c.height*c.height*v+g.y,e={box:c,ratio:v,points:s},i*=v,n*=v}return{centerX:t,centerY:r,radius:i,innerRadius:n,debug:e}}),[a,o,l,u,f,O,R]),G=q({data:r,startAngle:u,endAngle:f,innerRadius:B.innerRadius,outerRadius:B.radius,padAngle:L,sortByValue:b,activeId:w,activeInnerRadiusOffset:I,activeOuterRadiusOffset:M,hiddenIds:T}),E=n((function(e){V((function(i){return i.indexOf(e)>-1?i.filter((function(i){return i!==e})):[].concat(i,[e])}))}),[]);return D({arcGenerator:p({cornerRadius:R,padAngle:s(L)}),setActiveId:W,toggleSerie:E},G,B)},K=function(i){var n=i.dataWithArc,t=i.arcGenerator,r=i.centerX,a=i.centerY,o=i.radius,d=i.innerRadius;return e((function(){return{dataWithArc:n,arcGenerator:t,centerX:r,centerY:a,radius:o,innerRadius:d}}),[n,t,r,a,o,d])},N=function(i){var n=i.center,r=i.data,a=i.arcGenerator,o=i.borderWidth,d=i.borderColor,l=i.isInteractive,s=i.onClick,c=i.onMouseEnter,u=i.onMouseMove,v=i.onMouseLeave,f=i.setActiveId,g=i.tooltip,L=i.transitionMode,h=E(),b=h.showTooltipFromEvent,p=h.hideTooltip,k=e((function(){if(l)return function(e,i){null==s||s(e,i)}}),[l,s]),R=e((function(){if(l)return function(e,i){b(t(g,{datum:e}),i),f(e.id),null==c||c(e,i)}}),[l,b,f,c,g]),m=e((function(){if(l)return function(e,i){b(t(g,{datum:e}),i),null==u||u(e,i)}}),[l,b,u,g]),O=e((function(){if(l)return function(e,i){p(),f(null),null==v||v(e,i)}}),[l,p,f,v]);return W(A,{center:n,data:r,arcGenerator:a,borderWidth:o,borderColor:d,transitionMode:L,onClick:k,onMouseEnter:R,onMouseMove:m,onMouseLeave:O})},Q=["isInteractive","animate","motionConfig","theme","renderWrapper"],U=function(e){var i=e.data,n=e.id,a=void 0===n?Y.id:n,o=e.value,d=void 0===o?Y.value:o,l=e.valueFormat,s=e.sortByValue,c=void 0===s?Y.sortByValue:s,u=e.layers,L=void 0===u?Y.layers:u,h=e.startAngle,b=void 0===h?Y.startAngle:h,p=e.endAngle,k=void 0===p?Y.endAngle:p,A=e.padAngle,O=void 0===A?Y.padAngle:A,C=e.fit,I=void 0===C?Y.fit:C,x=e.innerRadius,M=void 0===x?Y.innerRadius:x,y=e.cornerRadius,w=void 0===y?Y.cornerRadius:y,S=e.activeInnerRadiusOffset,T=void 0===S?Y.activeInnerRadiusOffset:S,V=e.activeOuterRadiusOffset,B=void 0===V?Y.activeOuterRadiusOffset:V,G=e.width,E=e.height,D=e.margin,F=e.colors,H=void 0===F?Y.colors:F,j=e.borderWidth,q=void 0===j?Y.borderWidth:j,z=e.borderColor,Q=void 0===z?Y.borderColor:z,U=e.enableArcLabels,Z=void 0===U?Y.enableArcLabels:U,$=e.arcLabel,_=void 0===$?Y.arcLabel:$,ee=e.arcLabelsSkipAngle,ie=void 0===ee?Y.arcLabelsSkipAngle:ee,ne=e.arcLabelsTextColor,te=void 0===ne?Y.arcLabelsTextColor:ne,re=e.arcLabelsRadiusOffset,ae=void 0===re?Y.arcLabelsRadiusOffset:re,oe=e.arcLabelsComponent,de=e.enableArcLinkLabels,le=void 0===de?Y.enableArcLinkLabels:de,se=e.arcLinkLabel,ce=void 0===se?Y.arcLinkLabel:se,ue=e.arcLinkLabelsSkipAngle,ve=void 0===ue?Y.arcLinkLabelsSkipAngle:ue,fe=e.arcLinkLabelsOffset,ge=void 0===fe?Y.arcLinkLabelsOffset:fe,Le=e.arcLinkLabelsDiagonalLength,he=void 0===Le?Y.arcLinkLabelsDiagonalLength:Le,be=e.arcLinkLabelsStraightLength,pe=void 0===be?Y.arcLinkLabelsStraightLength:be,ke=e.arcLinkLabelsThickness,Ae=void 0===ke?Y.arcLinkLabelsThickness:ke,Re=e.arcLinkLabelsTextOffset,me=void 0===Re?Y.arcLinkLabelsTextOffset:Re,Oe=e.arcLinkLabelsTextColor,Ce=void 0===Oe?Y.arcLinkLabelsTextColor:Oe,Ie=e.arcLinkLabelsColor,xe=void 0===Ie?Y.arcLinkLabelsColor:Ie,Me=e.arcLinkLabelComponent,ye=e.defs,we=void 0===ye?Y.defs:ye,We=e.fill,Se=void 0===We?Y.fill:We,Te=e.isInteractive,Ve=void 0===Te?Y.isInteractive:Te,Be=e.onClick,Ge=e.onMouseEnter,Ee=e.onMouseMove,De=e.onMouseLeave,Fe=e.tooltip,He=void 0===Fe?Y.tooltip:Fe,Xe=e.transitionMode,Ye=void 0===Xe?Y.transitionMode:Xe,je=e.legends,Pe=void 0===je?Y.legends:je,qe=e.role,ze=void 0===qe?Y.role:qe,Je=v(G,E,D),Ke=Je.outerWidth,Ne=Je.outerHeight,Qe=Je.margin,Ue=Je.innerWidth,Ze=Je.innerHeight,$e=P({data:i,id:a,value:d,valueFormat:l,colors:H}),_e=J({data:$e,width:Ue,height:Ze,fit:I,innerRadius:M,startAngle:b,endAngle:k,padAngle:O,sortByValue:c,cornerRadius:w,activeInnerRadiusOffset:T,activeOuterRadiusOffset:B}),ei=_e.dataWithArc,ii=_e.legendData,ni=_e.arcGenerator,ti=_e.centerX,ri=_e.centerY,ai=_e.radius,oi=_e.innerRadius,di=_e.setActiveId,li=_e.toggleSerie,si=f(we,ei,Se),ci={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};L.includes("arcs")&&(ci.arcs=W(N,{center:[ti,ri],data:ei,arcGenerator:ni,borderWidth:q,borderColor:Q,isInteractive:Ve,onClick:Be,onMouseEnter:Ge,onMouseMove:Ee,onMouseLeave:De,setActiveId:di,tooltip:He,transitionMode:Ye},"arcs")),le&&L.includes("arcLinkLabels")&&(ci.arcLinkLabels=W(R,{center:[ti,ri],data:ei,label:ce,skipAngle:ve,offset:ge,diagonalLength:he,straightLength:pe,strokeWidth:Ae,textOffset:me,textColor:Ce,linkColor:xe,component:Me},"arcLinkLabels")),Z&&L.includes("arcLabels")&&(ci.arcLabels=W(m,{center:[ti,ri],data:ei,label:_,radiusOffset:ae,skipAngle:ie,textColor:te,transitionMode:Ye,component:oe},"arcLabels")),Pe.length>0&&L.includes("legends")&&(ci.legends=W(X,{width:Ue,height:Ze,data:ii,legends:Pe,toggleSerie:li},"legends"));var ui=K({dataWithArc:ei,arcGenerator:ni,centerX:ti,centerY:ri,radius:ai,innerRadius:oi});return W(g,{width:Ke,height:Ne,margin:Qe,defs:si,role:ze,children:L.map((function(e,i){return void 0!==ci[e]?ci[e]:"function"==typeof e?W(r,{children:t(e,ui)},i):null}))})},Z=function(e){var i=e.isInteractive,n=void 0===i?Y.isInteractive:i,t=e.animate,r=void 0===t?Y.animate:t,a=e.motionConfig,o=void 0===a?Y.motionConfig:a,d=e.theme,l=e.renderWrapper,s=F(e,Q);return W(u,{animate:r,isInteractive:n,motionConfig:o,renderWrapper:l,theme:d,children:W(U,D({isInteractive:n},s))})},$=function(e){return W(L,{children:function(i){var n=i.width,t=i.height;return W(Z,D({width:n,height:t},e))}})},_=["isInteractive","theme","renderWrapper"],ee=function(i){var n=i.data,r=i.id,d=void 0===r?Y.id:r,l=i.value,s=void 0===l?Y.value:l,c=i.valueFormat,u=i.sortByValue,f=void 0===u?Y.sortByValue:u,g=i.startAngle,L=void 0===g?Y.startAngle:g,p=i.endAngle,k=void 0===p?Y.endAngle:p,A=i.padAngle,R=void 0===A?Y.padAngle:A,m=i.fit,y=void 0===m?Y.fit:m,S=i.innerRadius,T=void 0===S?Y.innerRadius:S,V=i.cornerRadius,G=void 0===V?Y.cornerRadius:V,F=i.activeInnerRadiusOffset,H=void 0===F?Y.activeInnerRadiusOffset:F,X=i.activeOuterRadiusOffset,j=void 0===X?Y.activeOuterRadiusOffset:X,q=i.width,z=i.height,K=i.margin,N=i.pixelRatio,Q=void 0===N?1:N,U=i.colors,Z=void 0===U?Y.colors:U,$=i.borderWidth,_=void 0===$?Y.borderWidth:$,ee=i.borderColor,ie=void 0===ee?Y.borderColor:ee,ne=i.enableArcLabels,te=void 0===ne?Y.enableArcLabels:ne,re=i.arcLabel,ae=void 0===re?Y.arcLabel:re,oe=i.arcLabelsSkipAngle,de=void 0===oe?Y.arcLabelsSkipAngle:oe,le=i.arcLabelsTextColor,se=void 0===le?Y.arcLabelsTextColor:le,ce=i.arcLabelsRadiusOffset,ue=void 0===ce?Y.arcLabelsRadiusOffset:ce,ve=i.enableArcLinkLabels,fe=void 0===ve?Y.enableArcLinkLabels:ve,ge=i.arcLinkLabel,Le=void 0===ge?Y.arcLinkLabel:ge,he=i.arcLinkLabelsSkipAngle,be=void 0===he?Y.arcLinkLabelsSkipAngle:he,pe=i.arcLinkLabelsOffset,ke=void 0===pe?Y.arcLinkLabelsOffset:pe,Ae=i.arcLinkLabelsDiagonalLength,Re=void 0===Ae?Y.arcLinkLabelsDiagonalLength:Ae,me=i.arcLinkLabelsStraightLength,Oe=void 0===me?Y.arcLinkLabelsStraightLength:me,Ce=i.arcLinkLabelsThickness,Ie=void 0===Ce?Y.arcLinkLabelsThickness:Ce,xe=i.arcLinkLabelsTextOffset,Me=void 0===xe?Y.arcLinkLabelsTextOffset:xe,ye=i.arcLinkLabelsTextColor,we=void 0===ye?Y.arcLinkLabelsTextColor:ye,We=i.arcLinkLabelsColor,Se=void 0===We?Y.arcLinkLabelsColor:We,Te=i.isInteractive,Ve=void 0===Te?Y.isInteractive:Te,Be=i.onClick,Ge=i.onMouseMove,Ee=i.tooltip,De=void 0===Ee?Y.tooltip:Ee,Fe=i.legends,He=void 0===Fe?Y.legends:Fe,Xe=a(null),Ye=h(),je=v(q,z,K),Pe=je.margin,qe=je.innerWidth,ze=je.innerHeight,Je=je.outerWidth,Ke=je.outerHeight,Ne=P({data:n,id:d,value:s,valueFormat:c,colors:Z}),Qe=J({data:Ne,width:qe,height:ze,fit:y,innerRadius:T,startAngle:L,endAngle:k,padAngle:R,sortByValue:f,cornerRadius:G,activeInnerRadiusOffset:H,activeOuterRadiusOffset:j}),Ue=Qe.dataWithArc,Ze=Qe.arcGenerator,$e=Qe.centerX,_e=Qe.centerY,ei=Qe.radius,ii=Qe.innerRadius,ni=Qe.setActiveId,ti=B(ie,Ye),ri=O({data:Ue,label:ae,skipAngle:de,offset:ue,textColor:se}),ai=C({data:Ue,skipAngle:be,offset:ke,diagonalLength:Re,straightLength:Oe,label:Le,linkColor:Se,textOffset:Me,textColor:we});o((function(){if(Xe.current){Xe.current.width=Je*Q,Xe.current.height=Ke*Q;var e=Xe.current.getContext("2d");e.scale(Q,Q),e.fillStyle=Ye.background,e.fillRect(0,0,Je,Ke),e.save(),e.translate(Pe.left,Pe.top),Ze.context(e),e.save(),e.translate($e,_e),Ue.forEach((function(i){e.beginPath(),e.fillStyle=i.color,e.strokeStyle=ti(i),e.lineWidth=_,Ze(i.arc),e.fill(),_>0&&e.stroke()})),!0===fe&&I(e,ai,Ye,Ie),!0===te&&x(e,ri,Ye),e.restore(),He.forEach((function(i){w(e,D({},i,{data:Ue,containerWidth:qe,containerHeight:ze,theme:Ye}))}))}}),[Xe,qe,ze,Je,Ke,Pe.top,Pe.left,Q,$e,_e,Ze,Ue,ti,te,ri,fe,ai,Ie,He,Ye]);var oi=e((function(){return Ue.map((function(e){return D({id:e.id},e.arc)}))}),[Ue]),di=function(e){if(!Xe.current)return null;var i=b(Xe.current,e),n=i[0],t=i[1],r=M(Pe.left+$e,Pe.top+_e,ei,ii,oi,n,t);return r?Ue.find((function(e){return e.id===r.id})):null},li=E(),si=li.showTooltipFromEvent,ci=li.hideTooltip,ui=function(e){var i=di(e);i?(null==Ge||Ge(i,e),ni(i.id),si(t(De,{datum:i}),e)):(ni(null),ci())};return W("canvas",{ref:Xe,width:Je*Q,height:Ke*Q,style:{width:Je,height:Ke,cursor:Ve?"auto":"normal"},onMouseEnter:Ve?ui:void 0,onMouseMove:Ve?ui:void 0,onMouseLeave:Ve?function(){ci()}:void 0,onClick:Ve?function(e){if(Be){var i=di(e);i&&Be(i,e)}}:void 0})},ie=function(e){var i=e.isInteractive,n=void 0===i?Y.isInteractive:i,t=e.theme,r=e.renderWrapper,a=F(e,_);return W(u,{isInteractive:n,renderWrapper:r,theme:t,children:W(ee,D({isInteractive:n},a))})},ne=function(e){return W(L,{children:function(i){var n=i.width,t=i.height;return W(ie,D({width:n,height:t},e))}})};export{Z as Pie,ie as PieCanvas,$ as ResponsivePie,ne as ResponsivePieCanvas,Y as defaultProps,P as useNormalizedData,z as usePie,q as usePieArcs,J as usePieFromBox,K as usePieLayerContext}; | ||
import{useMemo as e,useRef as t,useEffect as i,useState as n,useCallback as a,createElement as r,Fragment as o}from"react";import{usePropertyAccessor as d,useValueFormatter as l,degreesToRadians as s,radiansToDegrees as c,Container as u,useDimensions as v,bindDefs as f,SvgWrapper as g,ResponsiveWrapper as L,useTheme as h,getRelativeCursor as b}from"@nivo/core";import{useArcGenerator as A,computeArcBoundingBox as p,ArcsLayer as k,ArcLinkLabelsLayer as I,ArcLabelsLayer as R,useArcLabels as m,useArcLinkLabels as O,drawCanvasArcLinkLabels as C,drawCanvasArcLabels as x,findArcUnderCursor as w}from"@nivo/arcs";import{BoxLegendSvg as M,renderLegendToCanvas as y}from"@nivo/legends";import{jsx as W,Fragment as S}from"react/jsx-runtime";import{pie as T}from"d3-shape";import{useOrdinalColorScale as D,useInheritedColor as V}from"@nivo/colors";import{BasicTooltip as B,useTooltip as G}from"@nivo/tooltip";function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},E.apply(this,arguments)}function F(e,t){if(null==e)return{};var i,n,a={},r=Object.keys(e);for(n=0;n<r.length;n++)i=r[n],t.indexOf(i)>=0||(a[i]=e[i]);return a}var H,X=function(e){var t=e.width,i=e.height,n=e.legends,a=e.data,r=e.toggleSerie;return W(S,{children:n.map((function(e,n){var o;return W(M,E({},e,{containerWidth:t,containerHeight:i,data:null!=(o=e.data)?o:a,toggleSerie:e.toggleSerie?r:void 0}),n)}))})},Y={id:"id",value:"value",sortByValue:!1,innerRadius:0,padAngle:0,cornerRadius:0,layers:["arcs","arcLinkLabels","arcLabels","legends"],startAngle:0,endAngle:360,fit:!0,activeInnerRadiusOffset:0,activeOuterRadiusOffset:0,borderWidth:0,borderColor:{from:"color",modifiers:[["darker",1]]},enableArcLabels:!0,arcLabel:"formattedValue",arcLabelsSkipAngle:0,arcLabelsRadiusOffset:.5,arcLabelsTextColor:{theme:"labels.text.fill"},enableArcLinkLabels:!0,arcLinkLabel:"id",arcLinkLabelsSkipAngle:0,arcLinkLabelsOffset:0,arcLinkLabelsDiagonalLength:16,arcLinkLabelsStraightLength:24,arcLinkLabelsThickness:1,arcLinkLabelsTextOffset:6,arcLinkLabelsTextColor:{theme:"labels.text.fill"},arcLinkLabelsColor:{theme:"axis.ticks.line.stroke"},colors:{scheme:"nivo"},defs:[],fill:[],isInteractive:!0,animate:!0,motionConfig:"gentle",transitionMode:"innerRadius",tooltip:function(e){var t=e.datum;return W(B,{id:t.id,value:t.formattedValue,enableChip:!0,color:t.color})},legends:[],role:"img",pixelRatio:"undefined"!=typeof window&&null!=(H=window.devicePixelRatio)?H:1},j=["points"],P=function(t){var i=t.data,n=t.id,a=void 0===n?Y.id:n,r=t.value,o=void 0===r?Y.value:r,s=t.valueFormat,c=t.colors,u=void 0===c?Y.colors:c,v=d(a),f=d(o),g=l(s),L=D(u,"id");return e((function(){return i.map((function(e){var t,i=v(e),n=f(e),a={id:i,label:null!=(t=e.label)?t:i,hidden:!1,value:n,formattedValue:g(n),data:e};return E({},a,{color:L(a)})}))}),[i,v,f,g,L])},q=function(n){var a=n.data,r=n.startAngle,o=n.endAngle,d=n.innerRadius,l=n.outerRadius,u=n.padAngle,v=n.sortByValue,f=n.activeId,g=n.activeInnerRadiusOffset,L=n.activeOuterRadiusOffset,h=n.hiddenIds,b=n.forwardLegendData,A=e((function(){var e=T().value((function(e){return e.value})).startAngle(s(r)).endAngle(s(o)).padAngle(s(u));return v||e.sortValues(null),e}),[r,o,u,v]),p=e((function(){var e=a.filter((function(e){return!h.includes(e.id)}));return{dataWithArc:A(e).map((function(e){var t=Math.abs(e.endAngle-e.startAngle);return E({},e.data,{arc:{index:e.index,startAngle:e.startAngle,endAngle:e.endAngle,innerRadius:f===e.data.id?d-g:d,outerRadius:f===e.data.id?l+L:l,thickness:l-d,padAngle:e.padAngle,angle:t,angleDeg:c(t)}})})),legendData:a.map((function(e){return{id:e.id,label:e.label,color:e.color,hidden:h.includes(e.id),data:e}}))}}),[A,a,h,f,d,g,l,L]),k=p.legendData,I=t(b);return i((function(){"function"==typeof I.current&&I.current(k)}),[I,k]),p},z=function(e){var t=e.activeId,i=e.onActiveIdChange,r=e.defaultActiveId,o=void 0!==t,d=n(o?null:void 0===r?null:r),l=d[0],s=d[1];return{activeId:o?t:l,setActiveId:a((function(e){i&&i(e),o||s(e)}),[o,i,s])}},J=function(e){var t=e.data,i=e.radius,r=e.innerRadius,o=e.startAngle,d=void 0===o?Y.startAngle:o,l=e.endAngle,c=void 0===l?Y.endAngle:l,u=e.padAngle,v=void 0===u?Y.padAngle:u,f=e.sortByValue,g=void 0===f?Y.sortByValue:f,L=e.cornerRadius,h=void 0===L?Y.cornerRadius:L,b=e.activeInnerRadiusOffset,p=void 0===b?Y.activeInnerRadiusOffset:b,k=e.activeOuterRadiusOffset,I=void 0===k?Y.activeOuterRadiusOffset:k,R=e.activeId,m=e.onActiveIdChange,O=e.defaultActiveId,C=e.forwardLegendData,x=z({activeId:R,onActiveIdChange:m,defaultActiveId:O}),w=x.activeId,M=x.setActiveId,y=n([]),W=y[0],S=y[1],T=q({data:t,startAngle:d,endAngle:c,innerRadius:r,outerRadius:i,padAngle:v,sortByValue:g,activeId:w,activeInnerRadiusOffset:p,activeOuterRadiusOffset:I,hiddenIds:W,forwardLegendData:C}),D=a((function(e){S((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return E({},T,{arcGenerator:A({cornerRadius:h,padAngle:s(v)}),setActiveId:M,toggleSerie:D})},K=function(t){var i=t.data,r=t.width,o=t.height,d=t.innerRadius,l=void 0===d?Y.innerRadius:d,c=t.startAngle,u=void 0===c?Y.startAngle:c,v=t.endAngle,f=void 0===v?Y.endAngle:v,g=t.padAngle,L=void 0===g?Y.padAngle:g,h=t.sortByValue,b=void 0===h?Y.sortByValue:h,k=t.cornerRadius,I=void 0===k?Y.cornerRadius:k,R=t.fit,m=void 0===R?Y.fit:R,O=t.activeInnerRadiusOffset,C=void 0===O?Y.activeInnerRadiusOffset:O,x=t.activeOuterRadiusOffset,w=void 0===x?Y.activeOuterRadiusOffset:x,M=t.activeId,y=t.onActiveIdChange,W=t.defaultActiveId,S=t.forwardLegendData,T=z({activeId:M,onActiveIdChange:y,defaultActiveId:W}),D=T.activeId,V=T.setActiveId,B=n([]),G=B[0],H=B[1],X=e((function(){var e,t=Math.min(r,o)/2,i=t*Math.min(l,1),n=r/2,a=o/2;if(m){var d=p(n,a,t,u-90,f-90),s=d.points,c=F(d,j),v=Math.min(r/c.width,o/c.height),g={width:c.width*v,height:c.height*v};g.x=(r-g.width)/2,g.y=(o-g.height)/2,n=(n-c.x)/c.width*c.width*v+g.x,a=(a-c.y)/c.height*c.height*v+g.y,e={box:c,ratio:v,points:s},t*=v,i*=v}return{centerX:n,centerY:a,radius:t,innerRadius:i,debug:e}}),[r,o,l,u,f,m]),P=q({data:i,startAngle:u,endAngle:f,innerRadius:X.innerRadius,outerRadius:X.radius,padAngle:L,sortByValue:b,activeId:D,activeInnerRadiusOffset:C,activeOuterRadiusOffset:w,hiddenIds:G,forwardLegendData:S}),J=a((function(e){H((function(t){return t.indexOf(e)>-1?t.filter((function(t){return t!==e})):[].concat(t,[e])}))}),[]);return E({arcGenerator:A({cornerRadius:I,padAngle:s(L)}),activeId:D,setActiveId:V,toggleSerie:J},P,X)},N=function(t){var i=t.dataWithArc,n=t.arcGenerator,a=t.centerX,r=t.centerY,o=t.radius,d=t.innerRadius;return e((function(){return{dataWithArc:i,arcGenerator:n,centerX:a,centerY:r,radius:o,innerRadius:d}}),[i,n,a,r,o,d])},Q=function(t){var i=t.center,n=t.data,a=t.arcGenerator,o=t.borderWidth,d=t.borderColor,l=t.isInteractive,s=t.onClick,c=t.onMouseEnter,u=t.onMouseMove,v=t.onMouseLeave,f=t.setActiveId,g=t.tooltip,L=t.transitionMode,h=G(),b=h.showTooltipFromEvent,A=h.hideTooltip,p=e((function(){if(l)return function(e,t){null==s||s(e,t)}}),[l,s]),I=e((function(){if(l)return function(e,t){b(r(g,{datum:e}),t),f(e.id),null==c||c(e,t)}}),[l,b,f,c,g]),R=e((function(){if(l)return function(e,t){b(r(g,{datum:e}),t),null==u||u(e,t)}}),[l,b,u,g]),m=e((function(){if(l)return function(e,t){A(),f(null),null==v||v(e,t)}}),[l,A,f,v]);return W(k,{center:i,data:n,arcGenerator:a,borderWidth:o,borderColor:d,transitionMode:L,onClick:p,onMouseEnter:I,onMouseMove:R,onMouseLeave:m})},U=["isInteractive","animate","motionConfig","theme","renderWrapper"],Z=function(e){var t=e.data,i=e.id,n=void 0===i?Y.id:i,a=e.value,d=void 0===a?Y.value:a,l=e.valueFormat,s=e.sortByValue,c=void 0===s?Y.sortByValue:s,u=e.layers,L=void 0===u?Y.layers:u,h=e.startAngle,b=void 0===h?Y.startAngle:h,A=e.endAngle,p=void 0===A?Y.endAngle:A,k=e.padAngle,m=void 0===k?Y.padAngle:k,O=e.fit,C=void 0===O?Y.fit:O,x=e.innerRadius,w=void 0===x?Y.innerRadius:x,M=e.cornerRadius,y=void 0===M?Y.cornerRadius:M,S=e.activeInnerRadiusOffset,T=void 0===S?Y.activeInnerRadiusOffset:S,D=e.activeOuterRadiusOffset,V=void 0===D?Y.activeOuterRadiusOffset:D,B=e.width,G=e.height,E=e.margin,F=e.colors,H=void 0===F?Y.colors:F,j=e.borderWidth,q=void 0===j?Y.borderWidth:j,z=e.borderColor,J=void 0===z?Y.borderColor:z,U=e.enableArcLabels,Z=void 0===U?Y.enableArcLabels:U,$=e.arcLabel,_=void 0===$?Y.arcLabel:$,ee=e.arcLabelsSkipAngle,te=void 0===ee?Y.arcLabelsSkipAngle:ee,ie=e.arcLabelsTextColor,ne=void 0===ie?Y.arcLabelsTextColor:ie,ae=e.arcLabelsRadiusOffset,re=void 0===ae?Y.arcLabelsRadiusOffset:ae,oe=e.arcLabelsComponent,de=e.enableArcLinkLabels,le=void 0===de?Y.enableArcLinkLabels:de,se=e.arcLinkLabel,ce=void 0===se?Y.arcLinkLabel:se,ue=e.arcLinkLabelsSkipAngle,ve=void 0===ue?Y.arcLinkLabelsSkipAngle:ue,fe=e.arcLinkLabelsOffset,ge=void 0===fe?Y.arcLinkLabelsOffset:fe,Le=e.arcLinkLabelsDiagonalLength,he=void 0===Le?Y.arcLinkLabelsDiagonalLength:Le,be=e.arcLinkLabelsStraightLength,Ae=void 0===be?Y.arcLinkLabelsStraightLength:be,pe=e.arcLinkLabelsThickness,ke=void 0===pe?Y.arcLinkLabelsThickness:pe,Ie=e.arcLinkLabelsTextOffset,Re=void 0===Ie?Y.arcLinkLabelsTextOffset:Ie,me=e.arcLinkLabelsTextColor,Oe=void 0===me?Y.arcLinkLabelsTextColor:me,Ce=e.arcLinkLabelsColor,xe=void 0===Ce?Y.arcLinkLabelsColor:Ce,we=e.arcLinkLabelComponent,Me=e.defs,ye=void 0===Me?Y.defs:Me,We=e.fill,Se=void 0===We?Y.fill:We,Te=e.isInteractive,De=void 0===Te?Y.isInteractive:Te,Ve=e.onClick,Be=e.onMouseEnter,Ge=e.onMouseMove,Ee=e.onMouseLeave,Fe=e.tooltip,He=void 0===Fe?Y.tooltip:Fe,Xe=e.activeId,Ye=e.onActiveIdChange,je=e.defaultActiveId,Pe=e.transitionMode,qe=void 0===Pe?Y.transitionMode:Pe,ze=e.legends,Je=void 0===ze?Y.legends:ze,Ke=e.forwardLegendData,Ne=e.role,Qe=void 0===Ne?Y.role:Ne,Ue=v(B,G,E),Ze=Ue.outerWidth,$e=Ue.outerHeight,_e=Ue.margin,et=Ue.innerWidth,tt=Ue.innerHeight,it=P({data:t,id:n,value:d,valueFormat:l,colors:H}),nt=K({data:it,width:et,height:tt,fit:C,innerRadius:w,startAngle:b,endAngle:p,padAngle:m,sortByValue:c,cornerRadius:y,activeInnerRadiusOffset:T,activeOuterRadiusOffset:V,activeId:Xe,onActiveIdChange:Ye,defaultActiveId:je,forwardLegendData:Ke}),at=nt.dataWithArc,rt=nt.legendData,ot=nt.arcGenerator,dt=nt.centerX,lt=nt.centerY,st=nt.radius,ct=nt.innerRadius,ut=nt.setActiveId,vt=nt.toggleSerie,ft=f(ye,at,Se),gt={arcs:null,arcLinkLabels:null,arcLabels:null,legends:null};L.includes("arcs")&&(gt.arcs=W(Q,{center:[dt,lt],data:at,arcGenerator:ot,borderWidth:q,borderColor:J,isInteractive:De,onClick:Ve,onMouseEnter:Be,onMouseMove:Ge,onMouseLeave:Ee,setActiveId:ut,tooltip:He,transitionMode:qe},"arcs")),le&&L.includes("arcLinkLabels")&&(gt.arcLinkLabels=W(I,{center:[dt,lt],data:at,label:ce,skipAngle:ve,offset:ge,diagonalLength:he,straightLength:Ae,strokeWidth:ke,textOffset:Re,textColor:Oe,linkColor:xe,component:we},"arcLinkLabels")),Z&&L.includes("arcLabels")&&(gt.arcLabels=W(R,{center:[dt,lt],data:at,label:_,radiusOffset:re,skipAngle:te,textColor:ne,transitionMode:qe,component:oe},"arcLabels")),Je.length>0&&L.includes("legends")&&(gt.legends=W(X,{width:et,height:tt,data:rt,legends:Je,toggleSerie:vt},"legends"));var Lt=N({dataWithArc:at,arcGenerator:ot,centerX:dt,centerY:lt,radius:st,innerRadius:ct});return W(g,{width:Ze,height:$e,margin:_e,defs:ft,role:Qe,children:L.map((function(e,t){return void 0!==gt[e]?gt[e]:"function"==typeof e?W(o,{children:r(e,Lt)},t):null}))})},$=function(e){var t=e.isInteractive,i=void 0===t?Y.isInteractive:t,n=e.animate,a=void 0===n?Y.animate:n,r=e.motionConfig,o=void 0===r?Y.motionConfig:r,d=e.theme,l=e.renderWrapper,s=F(e,U);return W(u,{animate:a,isInteractive:i,motionConfig:o,renderWrapper:l,theme:d,children:W(Z,E({isInteractive:i},s))})},_=function(e){return W(L,{children:function(t){var i=t.width,n=t.height;return W($,E({width:i,height:n},e))}})},ee=["isInteractive","theme","renderWrapper"],te=function(n){var a=n.data,o=n.id,d=void 0===o?Y.id:o,l=n.value,s=void 0===l?Y.value:l,c=n.valueFormat,u=n.sortByValue,f=void 0===u?Y.sortByValue:u,g=n.startAngle,L=void 0===g?Y.startAngle:g,A=n.endAngle,p=void 0===A?Y.endAngle:A,k=n.padAngle,I=void 0===k?Y.padAngle:k,R=n.fit,M=void 0===R?Y.fit:R,S=n.innerRadius,T=void 0===S?Y.innerRadius:S,D=n.cornerRadius,B=void 0===D?Y.cornerRadius:D,F=n.activeInnerRadiusOffset,H=void 0===F?Y.activeInnerRadiusOffset:F,X=n.activeOuterRadiusOffset,j=void 0===X?Y.activeOuterRadiusOffset:X,q=n.width,z=n.height,J=n.margin,N=n.pixelRatio,Q=void 0===N?Y.pixelRatio:N,U=n.colors,Z=void 0===U?Y.colors:U,$=n.borderWidth,_=void 0===$?Y.borderWidth:$,ee=n.borderColor,te=void 0===ee?Y.borderColor:ee,ie=n.enableArcLabels,ne=void 0===ie?Y.enableArcLabels:ie,ae=n.arcLabel,re=void 0===ae?Y.arcLabel:ae,oe=n.arcLabelsSkipAngle,de=void 0===oe?Y.arcLabelsSkipAngle:oe,le=n.arcLabelsTextColor,se=void 0===le?Y.arcLabelsTextColor:le,ce=n.arcLabelsRadiusOffset,ue=void 0===ce?Y.arcLabelsRadiusOffset:ce,ve=n.enableArcLinkLabels,fe=void 0===ve?Y.enableArcLinkLabels:ve,ge=n.arcLinkLabel,Le=void 0===ge?Y.arcLinkLabel:ge,he=n.arcLinkLabelsSkipAngle,be=void 0===he?Y.arcLinkLabelsSkipAngle:he,Ae=n.arcLinkLabelsOffset,pe=void 0===Ae?Y.arcLinkLabelsOffset:Ae,ke=n.arcLinkLabelsDiagonalLength,Ie=void 0===ke?Y.arcLinkLabelsDiagonalLength:ke,Re=n.arcLinkLabelsStraightLength,me=void 0===Re?Y.arcLinkLabelsStraightLength:Re,Oe=n.arcLinkLabelsThickness,Ce=void 0===Oe?Y.arcLinkLabelsThickness:Oe,xe=n.arcLinkLabelsTextOffset,we=void 0===xe?Y.arcLinkLabelsTextOffset:xe,Me=n.arcLinkLabelsTextColor,ye=void 0===Me?Y.arcLinkLabelsTextColor:Me,We=n.arcLinkLabelsColor,Se=void 0===We?Y.arcLinkLabelsColor:We,Te=n.isInteractive,De=void 0===Te?Y.isInteractive:Te,Ve=n.onClick,Be=n.onMouseMove,Ge=n.tooltip,Ee=void 0===Ge?Y.tooltip:Ge,Fe=n.activeId,He=n.onActiveIdChange,Xe=n.defaultActiveId,Ye=n.legends,je=void 0===Ye?Y.legends:Ye,Pe=n.forwardLegendData,qe=t(null),ze=h(),Je=v(q,z,J),Ke=Je.margin,Ne=Je.innerWidth,Qe=Je.innerHeight,Ue=Je.outerWidth,Ze=Je.outerHeight,$e=P({data:a,id:d,value:s,valueFormat:c,colors:Z}),_e=K({data:$e,width:Ne,height:Qe,fit:M,innerRadius:T,startAngle:L,endAngle:p,padAngle:I,sortByValue:f,cornerRadius:B,activeInnerRadiusOffset:H,activeOuterRadiusOffset:j,activeId:Fe,onActiveIdChange:He,defaultActiveId:Xe,forwardLegendData:Pe}),et=_e.dataWithArc,tt=_e.arcGenerator,it=_e.centerX,nt=_e.centerY,at=_e.radius,rt=_e.innerRadius,ot=_e.setActiveId,dt=V(te,ze),lt=m({data:et,label:re,skipAngle:de,offset:ue,textColor:se}),st=O({data:et,skipAngle:be,offset:pe,diagonalLength:Ie,straightLength:me,label:Le,linkColor:Se,textOffset:we,textColor:ye});i((function(){if(qe.current){qe.current.width=Ue*Q,qe.current.height=Ze*Q;var e=qe.current.getContext("2d");e.scale(Q,Q),e.fillStyle=ze.background,e.fillRect(0,0,Ue,Ze),e.save(),e.translate(Ke.left,Ke.top),tt.context(e),e.save(),e.translate(it,nt),et.forEach((function(t){e.beginPath(),e.fillStyle=t.color,e.strokeStyle=dt(t),e.lineWidth=_,tt(t.arc),e.fill(),_>0&&e.stroke()})),!0===fe&&C(e,st,ze,Ce),!0===ne&&x(e,lt,ze),e.restore(),je.forEach((function(t){y(e,E({},t,{data:et,containerWidth:Ne,containerHeight:Qe,theme:ze}))}))}}),[qe,Ne,Qe,Ue,Ze,Ke.top,Ke.left,Q,it,nt,tt,et,_,dt,ne,lt,fe,st,Ce,je,ze]);var ct=e((function(){return et.map((function(e){return E({id:e.id},e.arc)}))}),[et]),ut=function(e){if(!qe.current)return null;var t=b(qe.current,e),i=t[0],n=t[1],a=w(Ke.left+it,Ke.top+nt,at,rt,ct,i,n);return a?et.find((function(e){return e.id===a.id})):null},vt=G(),ft=vt.showTooltipFromEvent,gt=vt.hideTooltip,Lt=function(e){var t=ut(e);t?(null==Be||Be(t,e),ot(t.id),ft(r(Ee,{datum:t}),e)):(ot(null),gt())};return W("canvas",{ref:qe,width:Ue*Q,height:Ze*Q,style:{width:Ue,height:Ze,cursor:De?"auto":"normal"},onMouseEnter:De?Lt:void 0,onMouseMove:De?Lt:void 0,onMouseLeave:De?function(){gt()}:void 0,onClick:De?function(e){if(Ve){var t=ut(e);t&&Ve(t,e)}}:void 0})},ie=function(e){var t=e.isInteractive,i=void 0===t?Y.isInteractive:t,n=e.theme,a=e.renderWrapper,r=F(e,ee);return W(u,{isInteractive:i,renderWrapper:a,theme:n,children:W(te,E({isInteractive:i},r))})},ne=function(e){return W(L,{children:function(t){var i=t.width,n=t.height;return W(ie,E({width:i,height:n},e))}})};export{$ as Pie,ie as PieCanvas,_ as ResponsivePie,ne as ResponsivePieCanvas,Y as defaultProps,P as useNormalizedData,J as usePie,q as usePieArcs,K as usePieFromBox,N as usePieLayerContext}; | ||
//# sourceMappingURL=nivo-pie.es.js.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { ArcGenerator } from '@nivo/arcs'; | ||
@@ -2,0 +3,0 @@ import { ComputedDatum, CompletePieSvgProps } from './types'; |
@@ -1,2 +0,2 @@ | ||
import { MayHaveLabel, CompletePieSvgProps, ComputedDatum, DatumId, PieCustomLayerProps } from './types'; | ||
import { MayHaveLabel, CompletePieSvgProps, ComputedDatum, DatumId, PieCustomLayerProps, LegendDatum, CommonPieProps } from './types'; | ||
/** | ||
@@ -7,3 +7,3 @@ * Format data so that we get a consistent data structure. | ||
export declare const useNormalizedData: <RawDatum extends MayHaveLabel>({ data, id, value, valueFormat, colors, }: Pick<CompletePieSvgProps<RawDatum>, "id" | "value" | "valueFormat" | "colors"> & { | ||
data: RawDatum[]; | ||
data: readonly RawDatum[]; | ||
}) => Omit<ComputedDatum<RawDatum>, "fill" | "arc">[]; | ||
@@ -13,3 +13,3 @@ /** | ||
*/ | ||
export declare const usePieArcs: <RawDatum>({ data, startAngle, endAngle, innerRadius, outerRadius, padAngle, sortByValue, activeId, activeInnerRadiusOffset, activeOuterRadiusOffset, hiddenIds, }: { | ||
export declare const usePieArcs: <RawDatum>({ data, startAngle, endAngle, innerRadius, outerRadius, padAngle, sortByValue, activeId, activeInnerRadiusOffset, activeOuterRadiusOffset, hiddenIds, forwardLegendData, }: { | ||
data: Omit<ComputedDatum<RawDatum>, "fill" | "arc">[]; | ||
@@ -26,5 +26,6 @@ startAngle: number; | ||
hiddenIds: DatumId[]; | ||
forwardLegendData?: ((data: LegendDatum<RawDatum>[]) => void) | undefined; | ||
}) => { | ||
dataWithArc: Omit<ComputedDatum<RawDatum>, "fill">[]; | ||
legendData: Omit<ComputedDatum<RawDatum>, "fill" | "arc">[]; | ||
legendData: LegendDatum<RawDatum>[]; | ||
}; | ||
@@ -35,3 +36,3 @@ /** | ||
*/ | ||
export declare const usePie: <RawDatum>({ data, radius, innerRadius, startAngle, endAngle, padAngle, sortByValue, cornerRadius, activeInnerRadiusOffset, activeOuterRadiusOffset, }: Pick<Partial<CompletePieSvgProps<RawDatum>>, "startAngle" | "endAngle" | "sortByValue" | "padAngle" | "cornerRadius" | "activeInnerRadiusOffset" | "activeOuterRadiusOffset"> & { | ||
export declare const usePie: <RawDatum>({ data, radius, innerRadius, startAngle, endAngle, padAngle, sortByValue, cornerRadius, activeInnerRadiusOffset, activeOuterRadiusOffset, activeId: activeIdFromProps, onActiveIdChange, defaultActiveId, forwardLegendData, }: Pick<Partial<CompletePieSvgProps<RawDatum>>, "sortByValue" | "padAngle" | "cornerRadius" | "startAngle" | "endAngle" | "activeInnerRadiusOffset" | "activeOuterRadiusOffset" | "activeId" | "onActiveIdChange" | "defaultActiveId" | "forwardLegendData"> & { | ||
data: Omit<ComputedDatum<RawDatum>, "arc">[]; | ||
@@ -42,6 +43,6 @@ radius: number; | ||
arcGenerator: import("@nivo/arcs").ArcGenerator; | ||
setActiveId: import("react").Dispatch<import("react").SetStateAction<DatumId | null>>; | ||
setActiveId: (id: DatumId | null) => void; | ||
toggleSerie: (id: DatumId) => void; | ||
dataWithArc: Omit<ComputedDatum<RawDatum>, "fill">[]; | ||
legendData: Omit<ComputedDatum<RawDatum>, "fill" | "arc">[]; | ||
legendData: LegendDatum<RawDatum>[]; | ||
}; | ||
@@ -56,3 +57,3 @@ /** | ||
*/ | ||
export declare const usePieFromBox: <RawDatum>({ data, width, height, innerRadius: innerRadiusRatio, startAngle, endAngle, padAngle, sortByValue, cornerRadius, fit, activeInnerRadiusOffset, activeOuterRadiusOffset, }: Pick<CompletePieSvgProps<RawDatum>, "startAngle" | "endAngle" | "innerRadius" | "width" | "height" | "sortByValue" | "padAngle" | "cornerRadius" | "fit" | "activeInnerRadiusOffset" | "activeOuterRadiusOffset"> & { | ||
export declare const usePieFromBox: <RawDatum>({ data, width, height, innerRadius: innerRadiusRatio, startAngle, endAngle, padAngle, sortByValue, cornerRadius, fit, activeInnerRadiusOffset, activeOuterRadiusOffset, activeId: activeIdFromProps, onActiveIdChange, defaultActiveId, forwardLegendData, }: Pick<CompletePieSvgProps<RawDatum>, "height" | "width" | "sortByValue" | "innerRadius" | "padAngle" | "cornerRadius" | "startAngle" | "endAngle" | "fit" | "activeInnerRadiusOffset" | "activeOuterRadiusOffset"> & Pick<Partial<CompletePieSvgProps<RawDatum>>, "activeId" | "onActiveIdChange" | "defaultActiveId" | "forwardLegendData"> & { | ||
data: Omit<ComputedDatum<RawDatum>, "arc">[]; | ||
@@ -75,5 +76,6 @@ }) => { | ||
dataWithArc: Omit<ComputedDatum<RawDatum>, "fill">[]; | ||
legendData: Omit<ComputedDatum<RawDatum>, "fill" | "arc">[]; | ||
legendData: LegendDatum<RawDatum>[]; | ||
arcGenerator: import("@nivo/arcs").ArcGenerator; | ||
setActiveId: import("react").Dispatch<import("react").SetStateAction<string | number | null>>; | ||
activeId: DatumId | null; | ||
setActiveId: (id: DatumId | null) => void; | ||
toggleSerie: (id: DatumId) => void; | ||
@@ -80,0 +82,0 @@ }; |
@@ -1,2 +0,3 @@ | ||
import { CompletePieSvgProps, ComputedDatum, DatumId } from './types'; | ||
/// <reference types="react" /> | ||
import { CompletePieSvgProps, DatumId, LegendDatum } from './types'; | ||
interface PieLegendsProps<RawDatum> { | ||
@@ -6,7 +7,7 @@ width: number; | ||
legends: CompletePieSvgProps<RawDatum>['legends']; | ||
data: Omit<ComputedDatum<RawDatum>, 'arc'>[]; | ||
data: LegendDatum<RawDatum>[]; | ||
toggleSerie: (id: DatumId) => void; | ||
} | ||
declare const PieLegends: <RawDatum>({ width, height, legends, data, toggleSerie, }: PieLegendsProps<RawDatum>) => JSX.Element; | ||
export default PieLegends; | ||
export declare const PieLegends: <RawDatum>({ width, height, legends, data, toggleSerie, }: PieLegendsProps<RawDatum>) => JSX.Element; | ||
export {}; | ||
//# sourceMappingURL=PieLegends.d.ts.map |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { ComputedDatum } from './types'; | ||
@@ -2,0 +3,0 @@ export declare const PieTooltip: <RawDatum>({ datum }: { |
@@ -0,1 +1,2 @@ | ||
/// <reference types="react" /> | ||
import { OrdinalColorScaleConfig } from '@nivo/colors'; | ||
@@ -2,0 +3,0 @@ export declare const defaultProps: { |
@@ -0,3 +1,4 @@ | ||
/// <reference types="react" /> | ||
import { PieSvgProps, MayHaveLabel } from './types'; | ||
export declare const ResponsivePie: <RawDatum extends MayHaveLabel>(props: Omit<PieSvgProps<RawDatum>, "width" | "height">) => JSX.Element; | ||
export declare const ResponsivePie: <RawDatum extends MayHaveLabel>(props: Omit<PieSvgProps<RawDatum>, "height" | "width">) => JSX.Element; | ||
//# sourceMappingURL=ResponsivePie.d.ts.map |
@@ -0,3 +1,4 @@ | ||
/// <reference types="react" /> | ||
import { PieCanvasProps, MayHaveLabel } from './types'; | ||
export declare const ResponsivePieCanvas: <RawDatum extends MayHaveLabel>(props: Omit<PieCanvasProps<RawDatum>, "width" | "height">) => JSX.Element; | ||
export declare const ResponsivePieCanvas: <RawDatum extends MayHaveLabel>(props: Omit<PieCanvasProps<RawDatum>, "height" | "width">) => JSX.Element; | ||
//# sourceMappingURL=ResponsivePieCanvas.d.ts.map |
@@ -11,3 +11,3 @@ import * as React from 'react'; | ||
} | ||
export interface MayHaveLabel { | ||
export interface MayHaveLabel extends Object { | ||
label?: string | number; | ||
@@ -34,3 +34,3 @@ } | ||
export interface DataProps<RawDatum> { | ||
data: RawDatum[]; | ||
data: readonly RawDatum[]; | ||
} | ||
@@ -43,3 +43,3 @@ export interface PieTooltipProps<RawDatum> { | ||
export interface PieCustomLayerProps<RawDatum> { | ||
dataWithArc: ComputedDatum<RawDatum>[]; | ||
dataWithArc: readonly ComputedDatum<RawDatum>[]; | ||
centerX: number; | ||
@@ -75,3 +75,7 @@ centerY: number; | ||
tooltip: React.FC<PieTooltipProps<RawDatum>>; | ||
legends: LegendProps[]; | ||
activeId: DatumId | null; | ||
onActiveIdChange: (id: DatumId | null) => void; | ||
defaultActiveId: DatumId | null; | ||
legends: readonly LegendProps[]; | ||
forwardLegendData: (data: LegendDatum<RawDatum>[]) => void; | ||
role: string; | ||
@@ -89,4 +93,11 @@ renderWrapper: boolean; | ||
}; | ||
export interface LegendDatum<RawDatum> { | ||
id: ComputedDatum<RawDatum>['id']; | ||
label: ComputedDatum<RawDatum>['label']; | ||
color: string; | ||
hidden: boolean; | ||
data: Omit<ComputedDatum<RawDatum>, 'fill' | 'arc'>; | ||
} | ||
export type PieSvgProps<RawDatum> = DataProps<RawDatum> & Dimensions & Partial<CommonPieProps<RawDatum>> & SvgDefsAndFill<ComputedDatum<RawDatum>> & PieHandlers<RawDatum, SVGPathElement> & { | ||
layers?: PieLayer<RawDatum>[]; | ||
layers?: readonly PieLayer<RawDatum>[]; | ||
animate?: boolean; | ||
@@ -97,3 +108,3 @@ motionConfig?: MotionProps['motionConfig']; | ||
export type CompletePieSvgProps<RawDatum> = DataProps<RawDatum> & Dimensions & CommonPieProps<RawDatum> & SvgDefsAndFill<ComputedDatum<RawDatum>> & PieHandlers<RawDatum, SVGPathElement> & { | ||
layers: PieLayer<RawDatum>[]; | ||
layers: readonly PieLayer<RawDatum>[]; | ||
animate: boolean; | ||
@@ -100,0 +111,0 @@ motionConfig: MotionProps['motionConfig']; |
{ | ||
"name": "@nivo/pie", | ||
"version": "0.83.1", | ||
"version": "0.84.0", | ||
"license": "MIT", | ||
@@ -32,7 +32,7 @@ "author": { | ||
"dependencies": { | ||
"@nivo/arcs": "0.83.1", | ||
"@nivo/colors": "0.83.1", | ||
"@nivo/core": "0.83.1", | ||
"@nivo/legends": "0.83.1", | ||
"@nivo/tooltip": "0.83.1", | ||
"@nivo/arcs": "0.84.0", | ||
"@nivo/colors": "0.84.0", | ||
"@nivo/core": "0.84.0", | ||
"@nivo/legends": "0.84.0", | ||
"@nivo/tooltip": "0.84.0", | ||
"@types/d3-shape": "^2.0.0", | ||
@@ -47,3 +47,3 @@ "d3-shape": "^1.3.5" | ||
}, | ||
"gitHead": "64f4a7d3a7e0c6525d1129648a44f2502c41fb4d" | ||
"gitHead": "71f3496361eb33c10380d12d3abb200813d9429b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200044
500
+ Added@nivo/arcs@0.84.0(transitive)
+ Added@nivo/colors@0.84.0(transitive)
+ Added@nivo/core@0.84.0(transitive)
+ Added@nivo/legends@0.84.0(transitive)
+ Added@nivo/recompose@0.84.0(transitive)
+ Added@nivo/tooltip@0.84.0(transitive)
- Removed@nivo/arcs@0.83.1(transitive)
- Removed@nivo/colors@0.83.1(transitive)
- Removed@nivo/core@0.83.1(transitive)
- Removed@nivo/legends@0.83.1(transitive)
- Removed@nivo/recompose@0.83.0(transitive)
- Removed@nivo/tooltip@0.83.1(transitive)
Updated@nivo/arcs@0.84.0
Updated@nivo/colors@0.84.0
Updated@nivo/core@0.84.0
Updated@nivo/legends@0.84.0
Updated@nivo/tooltip@0.84.0