@evergis/charts
Advanced tools
Comparing version 1.0.11 to 1.0.14
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=t(e),n=require("d3"),r=t(require("react-dom/server")),l=require("styled-components"),i=t(l);function o(){const[t,a]=e.useState(null);return[e.useCallback(t=>a(t),[]),t]}const s=(t,a)=>{const n=e.useMemo(()=>a?function(t,e){let a=!1;return function(){a||(t(...arguments),a=!0,setTimeout((function(){a=!1}),44))}}(a):void 0,[a]);e.useEffect(()=>(n&&"number"!=typeof t&&window.addEventListener("resize",n),()=>n&&window.removeEventListener("resize",n)),[t,n])};function c(){return(c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t}).apply(this,arguments)}function d(t,e){if(null==t)return{};var a,n,r={},l=Object.keys(t);for(n=0;n<l.length;n++)e.indexOf(a=l[n])>=0||(r[a]=t[a]);return r}function u(t,e){return e||(e=t.slice(0)),t.raw=e,t}const p=(t,e,a)=>(n.select(t).select("svg").remove(),n.select(t).append("svg").attr("width",e).attr("height",a));function h(){const t=u(["\n position: absolute;\n"]);return h=function(){return t},t}const m=t=>{let{anchor:e,index:a,translateX:n,translateY:r}=t;return 0===a&&"middle"===e?"translate(calc(-50% + "+n+"px), calc(-100% + "+r+"px))":"middle"===e?"translate(calc(-50% + "+n+"px), calc("+r+"px))":"start"===e?"translate(calc("+n+"px), calc(-50% + "+r+"px))":"end"===e?"translate(calc(-100% + "+n+"px), calc(-50% + "+r+"px))":"translate("+n+"px, "+r+"px)"},f=i.div.attrs(t=>({style:{transform:m(t)}}))(h());function b(){const t=u(["\n margin-left: 4px;\n font-size: 10px;\n color: rgba(255, 255, 255, 0.54);\n"]);return b=function(){return t},t}function g(){const t=u(["\n ","\n"]);return g=function(){return t},t}function x(){const t=u(["\n display: flex;\n align-items: center;\n padding: 2px 4px;\n border-radius: 4px;\n color: rgb(255, 255, 255);\n background-color: rgb(144, 197, 61);\n margin-left: 8px;\n"]);return x=function(){return t},t}function y(){const t=u(["\n position: absolute;\n top: 50%;\n right: 0;\n transform: translate(calc(100% + 6px), -50%);\n"]);return y=function(){return t},t}function C(){const t=u(["\n text-align: center;\n max-width: 120px;\n"]);return C=function(){return t},t}function L(){const t=u(["\n display: flex;\n align-items: center;\n font-size: 12px;\n"]);return L=function(){return t},t}const v=i.div(L()),M=i.div(C()),A=l.css(y()),T=i.div(x()),S=i(T)(g(),A),k=i.div(b());function G(){const t=u(["\n position: relative;\n width: 100%;\n box-sizing: border-box;\n"]);return G=function(){return t},t}const N=i.div(G());function w(){const t=u(["\n ."," {\n path,\n line,\n circle {\n fill: none;\n stroke-width: 1px;\n stroke: rgba(149, 149, 149, 0.18);\n }\n }\n ."," {\n font-size: 12px;\n fill-opacity: 0.56;\n }\n ."," {\n fill-opacity: 0.06;\n stroke-width: 2px;\n fill: rgb(144, 197, 61);\n stroke: rgb(144, 197, 61);\n }\n ."," {\n fill: rgb(144, 197, 61);\n }\n"]);return w=function(){return t},t}const E={radar:"radar",radarAxis:"radarAxis",radarAxisTextGlobal:"radarAxisTextGlobal",radarAxisText:"radarAxisText",radarPolygon:"radarPolygon",radarLabel:"radarLabel",radarLabelName:"radarLabelName",radarLabelBadge:"radarLabelBadge",radarLabelBadgePrefix:"radarLabelBadgePrefix",radarCircle:"radarCircle"},Y=i(N)(w(),E.radarAxis,E.radarAxisText,E.radarPolygon,E.radarCircle),P=(t,e)=>{const{data:l,curve:i,polar:o,formatValue:s,badgePrefix:d,labelOffset:u,circleRadius:h,svgElements:m,renderLabel:b,customize:g}=e;if(null!==t&&l.length){const x=10,y="number"==typeof e.bleedLength?e.bleedLength:x,{width:C}=t.getBoundingClientRect(),L=e.width||C,A=400,G=e.height||A,N=e.minValue||Math.min(0,n.min(l,t=>n.min(t.map(t=>{let{value:e}=t;return e})))),w=(e.maxValue||Math.max(0,n.max(l,t=>n.max(t.map(t=>{let{value:e}=t;return e})))))-N,Y=e.paddingY||0,P=Math.min((L-2*(e.paddingX||0)-2*y)/2,(G-2*Y-2*y)/2),I=n.scaleLinear().range([0,P]).domain([0,w]),R=4,D=e.levels||R,X=2*Math.PI/l[0].length,B=n.lineRadial().curve(n.curveLinearClosed).radius(t=>{let{value:e}=t;return I(e)}).angle((t,e)=>e*X),O=n.lineRadial().curve(i||n.curveLinearClosed).radius(t=>{let{value:e}=t;return I(e)}).angle((t,e)=>e*X),j=p(t,L,G),F=j.append("g"),V=n.range(1,D+1).reverse(),z=t=>-t*P/D,W=t=>w*t/D,U=F.append("g").attr("class",E.radarAxis).selectAll().data([l[0]]).enter(),_=F.append("g").attr("class",E.radar),q=U.selectAll().data(l[0].map(t=>{let{name:e}=t;return e})).enter();let H=0;o?V.forEach(t=>{const e=U.append("circle").attr("cx",0).attr("cy",0).attr("r",()=>P/D*t).node().getBoundingClientRect().height;H=Math.max(H,e)}):V.map(W).forEach(t=>{const e=U.append("path").attr("d",()=>B(Array.from({length:l[0].length},()=>({value:t})))).node().getBoundingClientRect().height;H=Math.max(H,e)});const Z=I(w)+y;q.append("line").attr("x1",0).attr("y1",0).attr("x2",(t,e)=>Math.round(Z*Math.cos(X*e-Math.PI/2))).attr("y2",(t,e)=>Math.round(Z*Math.sin(X*e-Math.PI/2))),l.forEach(t=>{_.append("path").attr("class",E.radarPolygon).attr("d",()=>O(t.map(t=>c({},t,{value:t.value-N}))))}),F.append("g").attr("class",E.radarAxisTextGlobal).selectAll("text").data(V).enter().append("text").attr("class",E.radarAxisText).attr("x","4").attr("y",z).attr("dy",0).attr("dominant-baseline","central").text(t=>W(t)+N),h&&l.forEach(t=>{const e=F.append("g").attr("class",E.radarCircle);t.forEach((t,a)=>{let{value:n}=t;e.append("circle").attr("cx",Math.round(I(n)*Math.cos(X*a-Math.PI/2))).attr("cy",Math.round(I(n*Math.sin(X*a-Math.PI/2)))).attr("r",h)})});const J=8,K=G-y-Y,Q=L/2,$=K/2+(K-H)/2,tt=y+(u||J);if(F.attr("transform","translate("+Q+","+$+")"),(t=>{let{node:e,dataLength:l,radiusScale:i,maxValue:o,angleSlice:s,radius:c,xOffset:d,yOffset:u,translateX:p,translateY:h,renderLabel:m}=t;const b=n.select(e);b.selectAll(".d3-chart-label").remove();const g=t=>o/c*t,x=t=>i((o+g(u||0))*Math.sin(s*t-Math.PI/2));Array.from({length:l},(t,e)=>{return{x:Math.ceil((a=e,i(o+g(d||0))*Math.cos(s*a-Math.PI/2))),y:Math.ceil(x(e))};var a}).forEach((t,e)=>{let{x:n,y:i}=t;const o=((t,e)=>{const a=((t,e)=>360/e*t)(t,e),n=180;return[0,n].includes(a)?"middle":a<n?"start":"end"})(e,l),s=r.renderToString(a.createElement(f,{anchor:o,translateX:p||0,translateY:h||0,index:e,style:{left:n,top:i}},"function"==typeof m?m(o,e):m));b.append("div").attr("class","d3-chart-label").html(s)})})({node:t,maxValue:w,translateX:Q,translateY:$,dataLength:l[0].length,angleSlice:X,radius:P,radiusScale:I,xOffset:tt,yOffset:tt,renderLabel:(t,e)=>{const n="middle"===t?S:T,r=l[0][e].name,i=l[0][e].value;return"function"==typeof b?b({name:r,value:i}):a.createElement(v,{className:E.radarLabel},a.createElement(M,{className:E.radarLabelName},r),1===l.length&&a.createElement(n,{className:E.radarLabelBadge},"function"==typeof s?s(i):i,d&&a.createElement(k,{className:E.radarLabelBadgePrefix},d)))}}),m){const t=r.renderToString(m);j.append("g").html(t)}"function"==typeof g&&g(j)}},I=t=>{const{className:n,style:r}=t,[l,i]=o();return e.useEffect(()=>{i&&P(i,t)},[i,t]),s(t.width,()=>P(i,t)),a.createElement("div",{className:n,style:r},a.createElement(Y,{ref:l}))};function R(t){return t*(Math.PI/180)}function D(){const t=u(["\n ."," {\n fill: #4a4a4a;\n }\n ."," {\n position: absolute;\n max-width: 128px;\n }\n ."," {\n stroke: #000;\n }\n"]);return D=function(){return t},t}I.defaultProps={height:400,data:[],curve:n.curveLinearClosed};const X={pieSlice:"pieSlice",pieSliceLabel:"pieSliceLabel",pieSliceLabelValue:"pieSliceLabelValue",pieSliceLabelName:"pieSliceLabelName",pieRadialLabel:"pieRadialLabel",pieRadialLink:"pieRadialLink"},B=i(N)(D(),X.pieSliceLabel,X.pieRadialLabel,X.pieRadialLink),O=t=>t.startAngle+(t.endAngle-t.startAngle)/2<Math.PI?1:-1,j=t=>t.startAngle+(t.endAngle-t.startAngle)/2<Math.PI?"start":"end",F=(t,e)=>{const{data:a,padAngle:l,onClick:i,outerRadius:o,startAngle:s,endAngle:c,cornerRadius:d,margin:u,enableSlicesLabels:h,formatSliceLabel:m,slicesLabelsSkipAngle:f,enableSlicesLabelsName:b,formatSliceLabelName:g,borderWidth:x,borderColor:y,enableRadialLabels:C,backgroundColor:L,radialLabelsLinkHorizontalLength:v,radialLabelsTextXOffset:M,formatRadialLabel:A,radialLabelYOffset:T,svgElements:S,formatSliceTitle:k,radialAngleXOffset:G}=e;if(null!==t&&a.length){const N=u?u.top:0,w=u?u.right:0,E=u?u.bottom:0,Y=u?u.left:0,{width:P}=t.getBoundingClientRect(),I=e.width||P,D=240,B=e.height||D,F=(Math.min(I,B)-2*(x||0)-(I>B?N+E:w+Y))/2,V=p(t,I,B),z=V.append("g").attr("transform","translate("+((I-(Y+w))/2+Y)+","+((B-(E+N))/2+N)+")"),W=45,U=100,_=360,q=n.pie().startAngle(-R(s||0)).endAngle(R(c||_)).padAngle(l?Math.max(Math.min(l/U,W),0):0).sort(null).value(t=>{let{value:e}=t;return e})(a),H=.95,Z=n.arc().cornerRadius(d||0).innerRadius(F).outerRadius(F*Math.min(Math.max(o||0,0),H));if("string"==typeof L&&z.append("path").attr("fill",L).attr("d",()=>Z({startAngle:R(0),endAngle:R(_)})),z.selectAll("allSlices").data(q).enter().append("path").attr("d",Z).attr("class",X.pieSlice).attr("fill",t=>{let{index:e}=t;return a[e].color||""}).attr("stroke",y||"").attr("stroke-width",x||0).attr("style","function"==typeof i?"cursor: pointer":"").on("click",(t,e)=>"function"==typeof i&&i(a[e.index])).append("svg:title").text(t=>"function"==typeof k?k(t):(a[t.index].name||"")+" ("+(t=>{if(null==t)return"";let e="";const a=String(t).split("."),n=a[0];let r=n.length%3;for(let t=0;t<n.length;t++)t===r&&(e+=" ",r+=3),e+=n[t];return a[1]?[e.trim(),a[1]].join(","):e.trim()})(parseFloat(a[t.index].value.toFixed(2)))+")"),h){const t=z.selectAll("allSlices").data(q).enter().append("text").attr("class",X.pieSliceLabel).attr("text-anchor","middle").attr("dominant-baseline","central").attr("transform",t=>"translate("+Z.centroid(t)+")");t.append("tspan").attr("class",X.pieSliceLabelValue).text(t=>{const e=180*(t.endAngle-t.startAngle)/Math.PI;if(!f||e>f)return"function"==typeof m?m(t):t.value}),b&&t.append("tspan").attr("class",X.pieSliceLabelName).text(t=>"function"==typeof g?g(t):t.data.name).attr("x","0").attr("dy","1.2em")}if((t=>{let{arc:e,enableRadialLabels:a,global:l,node:i,radius:o,dataReady:s,radialLabelsLinkHorizontalLength:c,formatRadialLabel:d,radialLabelsTextXOffset:u,translateX:p,translateY:h,radialLabelYOffset:m,radialAngleXOffset:f}=t;const b=n.select(i);if(b.selectAll("."+X.pieRadialLabel).remove(),a){const t=4,a=n.arc().innerRadius(o).outerRadius(o);l.selectAll("allPolylines").data(s).enter().append("polyline").attr("class",X.pieRadialLink).style("fill","none").attr("points",n=>{const r=O(n),l=e.centroid(n),i=a.centroid(n),s=a.centroid(n),d=[(o+(c||t))*r,s[1]];return[[l[0],l[1]],[i[0]+(f||0)*r,i[1]-(m||0)*n.index],[d[0],d[1]-(m||0)*n.index]]});const i=e=>{const n=a.centroid(e);return[(o+(c||t))*O(e),n[1]]},g=4;b.selectAll("allLabels").data(s).enter().append("div").html(t=>r.renderToString("function"==typeof d?d(t):t.data.name)).attr("class",X.pieRadialLabel).style("transform",t=>(t=>{let{anchor:e,index:a,translateX:n,translateY:r}=t;return 0===a&&"middle"===e?"translate(calc(-50% + "+n+"px), calc(-100% + "+r+"px))":"middle"===e?"translate(calc(-50% + "+n+"px), calc("+r+"px))":"start"===e?"translate(calc("+n+"px), calc(-50% + "+r+"px))":"end"===e?"translate(calc(-100% + "+n+"px), calc(-50% + "+r+"px))":"translate("+n+"px, "+r+"px)"})({anchor:j(t),index:t.index,translateX:p,translateY:h-(m||0)*t.index})).style("left",t=>i(t)[0]-("start"===j(t)?-(u||g):u||g)+"px").style("top",t=>i(t)[1]+"px").style("text-align",j)}})({arc:Z,enableRadialLabels:C,global:z,radius:F,node:t,dataReady:q,translateX:(I-(Y-w))/2,translateY:(B+(N-E))/2,radialLabelsLinkHorizontalLength:v,radialLabelsTextXOffset:M,formatRadialLabel:A,radialLabelYOffset:T,radialAngleXOffset:G}),S){const t=r.renderToString(S);V.append("g").html(t)}}},V=t=>{const{className:n,style:r,children:l}=t,[i,c]=o();return e.useEffect(()=>{c&&F(c,t)},[c,t]),s(t.width,()=>F(c,t)),a.createElement("div",{className:n,style:r},a.createElement(B,{ref:i},l))};V.defaultProps={data:[],startAngle:0,endAngle:360,slicesLabelsSkipAngle:0,radialLabelYOffset:16,radialAngleXOffset:8};const z={legendContainer:"d3-legend-container",legendTitle:"d3-legend-title",legendTick:"d3-legend-tick",legendTickLine:"d3-legend-tick-line",legendTickText:"d3-legend-tick-text"};function W(t,e){void 0===e&&(e=256);const a=document.createElement("canvas");a.width=e,a.height=1;const n=a.getContext("2d");for(let a=0;a<e;++a)n.fillStyle=t(a/(e-1)),n.fillRect(a,0,1,1);return a}const U={tickSize:6,height:44,width:320,marginTop:18,marginBottom:16,ticksDivier:64,titleMarginBottom:6};function _(){const t=u(["\n ."," {\n display: flex;\n margin-bottom: 16px;\n }\n ."," {\n display: inline-flex;\n align-items: flex-end;\n height: ",";\n margin-bottom: 4px;\n font-weight: bold;\n }\n ."," {\n height: ",";\n margin-bottom: 4px;\n position: relative;\n display: flex;\n }\n ."," {\n font-size: 14px;\n bottom: 0;\n position: absolute;\n }\n ."," {\n display: flex;\n flex-direction: column;\n margin-right: 10px;\n }\n ."," {\n font-size: 12px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n }\n ."," {\n position: relative;\n }\n ."," {\n position: absolute;\n }\n"]);return _=function(){return t},t}const q=c({calendarChart:"calendarChart",calendarYear:"calendarYear",calendarAxis:"calendarAxis",calendarBody:"calendarBody",calendarHeader:"calendarHeader",calendarYearTitle:"calendarYearTitle",calendarWeekDay:"calendarWeekDay",calendarMonth:"calendarMonth",calendarDays:"calendarDays",calendarDay:"calendarDay"},z),H=i(N)(_(),q.calendarYear,q.calendarYearTitle,"20px",q.calendarHeader,"20px",q.calendarMonth,q.calendarAxis,q.calendarWeekDay,q.calendarDays,q.calendarDay),Z=t=>{const{className:r,style:l,children:i,data:s,startSunday:d,weekdays:u,cellOffset:p,cellSize:h,interpolator:m,monthSpacing:f,colorRange:b,legendProps:g}=t,[x,y]=o();return e.useEffect(()=>{y&&((t,e)=>{const{data:a,startSunday:r,weekdays:l,interpolator:i,monthSpacing:o,onEachDay:s,colorRange:d,legendProps:u}=e;if(null!==t&&a.length){const p=n.group(a,t=>t.date.getUTCFullYear()),h="number"==typeof e.cellOffset?e.cellOffset:0,m=7,f=18,b=e.cellSize||f,g=t=>r?t:(t+(m-1))%m,x=l||["вс","пн","вт","ср","чт","пт","сб"],y=6,C=t=>r?x[t]:t===y?x[0]:x[t+1],L=n.utcFormat("%x"),v=r?n.utcSunday:n.utcMonday,M=(t,e)=>v.count(n.utcYear(t),e),A=t=>t.getUTCMonth()*(o||0),T=n.utcFormat("%b"),S=n.max(a.map(t=>{let{value:e}=t;return e})),k=n.min(a.map(t=>{let{value:e}=t;return e})),G=d?n.scaleLinear().domain([k,S]).range(d):n.scaleSequential(i||n.interpolateGreens).domain([k,+S]);let N=0;p.forEach((t,e)=>{const a=new Date(e,1),r=n.max(t.map(t=>t.date)),l=r.getUTCMonth()-a.getUTCMonth(),i=M(a,r)+1;N=Math.max(N,i*(b+h)+(o||0)*l)}),n.select(t).select("."+q.calendarChart).remove();const w=n.select(t).append("div").attr("class",q.calendarChart),E=w.selectAll("div").data(p).join("div").attr("class",q.calendarYear),Y=E.append("div").attr("class",q.calendarAxis);Y.append("div").attr("class",q.calendarYearTitle).text(t=>{let[e]=t;return e}),Y.selectAll("span").data(n.range(m)).join("div").attr("class",q.calendarWeekDay).style("height",b+"px").style("margin-bottom",h+"px").text(C);const P=E.append("div").attr("class",q.calendarBody);if(P.append("div").attr("class",q.calendarHeader).selectAll("div").data(t=>{let[e,a]=t;return n.utcMonths(n.utcMonth(new Date(a[0].date.getUTCFullYear(),1,1)),n.utcMonth(new Date(a[0].date.getUTCFullYear(),12,31)))}).join("div").attr("class",q.calendarMonth).style("left",t=>M(t,v.ceil(t))*(b+h)+A(t)+"px").text(T),P.append("div").attr("class",q.calendarDays).style("height",(b+h)*m+"px").style("width",N+"px").selectAll("div").data(t=>{let[,e]=t;return e}).join("div").each((t,e,a)=>{if("function"==typeof s){const n=a[e],r=G(t.value);s(t,n,r)}}).attr("class",q.calendarDay).style("width",b+"px").style("height",b+"px").style("left",t=>M(t.date,t.date)*(b+h)+A(t.date)+"px").style("top",t=>g(t.date.getUTCDay())*(b+h)+"px").style("background-color",t=>G(t.value)).attr("title",t=>L(t.date)+" - "+t.value),"object"==typeof u){const t=(t=>{let{color:e,title:a,tickSize:r=U.tickSize,width:l=U.width,height:i=U.height+r,marginTop:o=U.marginTop,marginRight:s=0,marginBottom:c=U.marginBottom+r,marginLeft:d=0,ticks:u=U.width/U.ticksDivier,tickFormat:p,tickValues:h,titleMarginBottom:m}=t;const f=n.create("svg").attr("width",l).attr("height",i).attr("viewBox",[0,0,l,i]).style("overflow","visible").style("display","block");let b;if(e.interpolate){const t=Math.min(e.domain().length,e.range().length);b=e.copy().rangeRound(n.quantize(n.interpolate(d,l-s),t)),f.append("image").attr("x",d).attr("y",o).attr("class",z.legendContainer).attr("width",l-d-s).attr("height",i-o-c).attr("preserveAspectRatio","none").attr("xlink:href",W(e.copy().domain(n.quantize(n.interpolate(0,1),t))).toDataURL())}else if(e.interpolator&&(b=Object.assign(e.copy().interpolator(n.interpolateRound(d,l-s)),{range:()=>[d,l-s]}),f.append("image").attr("x",d).attr("y",o).attr("width",l-d-s).attr("height",i-o-c).attr("preserveAspectRatio","none").attr("xlink:href",W(e.interpolator()).toDataURL()),!b.ticks)){if(void 0===h){const t=Math.round(u+1);h=n.range(t).map(a=>n.quantile(e.domain(),a/(t-1)))}"function"!=typeof p&&(p=n.format(void 0===p?",f":p))}return f.append("g").attr("transform","translate(0,"+(i-c)+")").call(n.axisBottom(b).ticks(u,"string"==typeof p?p:void 0).tickFormat("function"==typeof p?p:void 0).tickSize(r).tickValues(h)).call(t=>{const e=t.selectAll(".tick");return e.selectAll(".tick line").attr("y1",o+c-i).attr("class",z.legendTickLine),e.selectAll(".tick text").attr("class",z.legendTickText),e.attr("class",z.legendTick),e}).call(t=>t.select(".domain").remove()).call(t=>t.append("text").attr("x",d).attr("class",z.legendTitle).attr("y",o+c-i-(m||U.titleMarginBottom)).attr("fill","currentColor").attr("text-anchor","start").attr("font-weight","bold").text(a)),f})(c({color:G},u)),e=w.node(),a=t.node();e.appendChild(a)}}})(y,t)},[y,s,d,u,p,h,m,f,b,g]),a.createElement(H,{ref:x,className:r,style:l},i)};function J(t){let e;const a=t.node();return e=a instanceof SVGGraphicsElement?a.getBBox():a.getBoundingClientRect(),e}function K(){}function Q(){const t=u(["\n .",",\n ."," {\n shape-rendering: crispEdges;\n }\n ."," {\n fill: none;\n stroke: steelblue;\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n ."," {\n mix-blend-mode: multiply;\n }\n ."," {\n fill-opacity: 0.24;\n }\n ."," {\n shape-rendering: crispEdges;\n }\n .",",\n .",",\n ."," {\n stroke: rgba(149, 149, 149, 0.24);\n }\n .",",\n ."," {\n transition: opacity linear 200ms;\n pointer-events: none;\n stroke-width: 1px;\n }\n ."," {\n stroke: #fff;\n stroke-width: 2px;\n }\n ."," {\n shape-rendering: crispEdges;\n }\n ."," {\n fill: none;\n pointer-events: all;\n }\n ."," {\n transition: opacity linear 200ms;\n z-index: 1;\n ."," {\n white-space: nowrap;\n justify-content: flex-start;\n align-items: center;\n pointer-events: none;\n }\n ."," {\n margin: 0 0 0 10px;\n }\n }\n"]);return Q=function(){return t},t}Z.defaultProps={data:[]};const $={lineChartYScaleGlobal:"lineChartYScaleGlobal",lineChartXScaleGlobal:"lineChartXScaleGlobal",lineChartLinesGlobal:"lineChartLinesGlobal",lineChartLine:"lineChartLine",lineChartAreasGlobal:"lineChartAreasGlobal",lineChartArea:"lineChartArea",lineChartDotsGlobalContainer:"lineChartDotsGlobalContainer",lineChartDotsGlobal:"lineChartDotsGlobal",lineChartDot:"lineChartDot",lineChartGridGlobal:"lineChartGridGlobal",lineChartGridLineX:"lineChartGridLineX",lineChartGridLineY:"lineChartGridLineY",lineChartLabelContainer:"lineChartLabelContainer",lineChartLabelFlex:"lineChartLabelFlex",lineChartLabel:"lineChartLabel",lineChartMouseGlobal:"lineChartMouseGlobal",lineChartMouseLine:"lineChartMouseLine",lineChartMouseRect:"lineChartMouseRect",lineChartMouseCircle:"lineChartMouseCircle",lineChartMouseLabelContainer:"lineChartMouseLabelContainer",lineChartMouseLabel:"lineChartMouseLabel"},tt=i(N)(Q(),$.lineChartYScaleGlobal,$.lineChartXScaleGlobal,$.lineChartLinesGlobal,$.lineChartLine,$.lineChartArea,$.lineChartGridGlobal,$.lineChartGridLineX,$.lineChartGridLineY,$.lineChartMouseLine,$.lineChartMouseLine,$.lineChartMouseCircle,$.lineChartDot,$.lineChartMouseLine,$.lineChartMouseRect,$.lineChartMouseLabel,$.lineChartLabelFlex,$.lineChartLabel);function et(){const t=u(["\n margin-bottom: 4px;\n"]);return et=function(){return t},t}function at(){const t=u(["\n width: 0;\n height: 0;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n font-size: 12px;\n"]);return at=function(){return t},t}const nt=i.div(at()),rt=i.div(et()),lt=(t,e)=>{const{data:l,labels:i,margin:o,customYAxisSelection:s,customXAxisSelection:u,customYAxis:h,customXAxis:m,curve:f,dotRadius:b,yAxisPadding:g,xAxisPadding:x,drawGridY:y,drawGridX:C,eachDot:L,withLabels:v,formatLabel:M,eachLabel:A,stacked:T,dynamicTooltipEnable:S,dynamicCircleRadius:k,formatDynamicTooltip:G,renderTooltip:N,stackedTooltip:w,stackedTooltipIndex:E,tooltipLineTop:Y,customize:P}=e;if(null!==t&&l.length){const I=T?(t=>{const e={};return t.map((t,a)=>(e[a]={},a>0?c({},t,{values:t.values.map((t,n)=>{const r=e[a-1][n];return e[a][n]=Number(("number"!=typeof r?0:Math.abs(r))+("number"!=typeof t?0:Math.abs(t))),e[a][n]})}):(t.values.forEach((t,n)=>{e[a][n]=Number(t)}),t)))})(l):l,R=o?o.top:0,D=o?o.right:0,X=o?o.bottom:0,B=o?o.left:0,{width:O}=t.getBoundingClientRect(),j=e.width||O,F=e.height||0,V="number"==typeof e.min?e.min:n.min(I,t=>{let{values:e}=t;return n.min(e)}),z="number"==typeof e.max?e.max:n.max(I,t=>{let{values:e}=t;return n.max(e)}),W=p(t,j,F||0),U=n.scaleLinear().domain([V||0,z||0]).range([F-R-X-(x||0),R]).nice(),_=8,q=n.axisLeft(U).ticks(_),H=q.tickArguments()[0];h&&h(q);const Z=W.append("g").attr("class",$.lineChartYScaleGlobal).call(q).call("function"==typeof s?s:K),{width:Q}=J(Z);Z.attr("transform","translate("+(B+Q)+", 0)");const tt=i&&i.length?i.length-1:I.reduce((t,e)=>{let{values:a}=e;return Math.max(t,a.length)},0)-1,et=n.scaleLinear().domain([0,tt]).range([B+Q+(g||0),j-D]),at=n.axisBottom(et).tickFormat(t=>i&&i.length>0?i[t]:0).ticks(tt);if(m&&m(at),(t=>{let{svg:e,yScale:a,xScale:n,yTicksCount:r,lastIndex:l,drawGridX:i,drawGridY:o}=t;if(!o&&!i)return;const s=e.append("g").attr("class",$.lineChartGridGlobal),c=a.ticks(r);i&&s.append("g").selectAll("line").data(c).join("line").attr("class",$.lineChartGridLineX).attr("x1",()=>n(0)).attr("x2",()=>n(l)).attr("y1",t=>Math.round(a(t))).attr("y2",t=>Math.round(a(t))),o&&s.append("g").selectAll("line").data(Array.from({length:l+1},(t,e)=>e)).join("line").attr("class",$.lineChartGridLineY).attr("x1",(t,e)=>Math.round(n(e))).attr("x2",(t,e)=>Math.round(n(e))).attr("y1",()=>Math.round(a(c[0]))).attr("y2",()=>Math.round(a(c[c.length-1])))})({svg:W,yScale:U,xScale:et,yTicksCount:H,lastIndex:tt,drawGridY:y,drawGridX:C}),Array.isArray(i)&&i.length>0){const t=W.append("g").call("function"==typeof u?u:K).attr("class",$.lineChartXScaleGlobal).call(at),{height:e}=J(t);t.attr("transform","translate(0, "+(F-Math.ceil(e)-X)+")")}const lt=n.line().defined(t=>null!==t).x((t,e)=>et(e)).y(t=>U(t)).curve(f||n.curveLinear);if(W.append("g").attr("class",$.lineChartLinesGlobal).selectAll("path").data(I).join("path").attr("class",$.lineChartLine).attr("d",t=>lt(t.values)).attr("stroke",t=>{let{stroke:e}=t;return e||"steelblue"}),I.some(t=>{let{fill:e}=t;return e})){let t=-2;const e=n.area().x((t,e)=>et(e)).y0((e,a)=>(0===a&&(t+=1),U(T&&t>-1?"number"!=typeof I[t].values[a]?0:I[t].values[a]:V))).y1(t=>U(t)).curve(f||n.curveLinear);W.append("g").attr("class",$.lineChartAreasGlobal).selectAll("path").data(I).join("path").attr("class",$.lineChartArea).attr("d",t=>e(t.values)).attr("fill",t=>{let{fill:e}=t;return e||"none"})}if(b){const t=W.append("g").attr("class",$.lineChartDotsGlobalContainer);I.forEach(e=>{let{values:a}=e;t.append("g").attr("class",$.lineChartDotsGlobal).selectAll("circle").data(a).join("circle").each("function"==typeof L?L:K).attr("class",$.lineChartDot).attr("cx",(t,e)=>et(e)).attr("cy",t=>U(t)).attr("r",b)})}n.select(t).select(".d3-chart-label").remove(),v&&(t=>{let{node:e,data:l,yScale:i,xScale:o,formatLabel:s,eachLabel:c}=t;const d=n.select(e).append("div").attr("class","d3-chart-label");l.forEach(t=>{let{values:e}=t;d.append("div").selectAll("div").data(e).join("div").attr("class",$.lineChartLabelContainer).style("position","absolute").style("left",(t,e)=>o(e)+"px").style("top",t=>i(t)+"px").html((t,e,l)=>{const i=n.format(",");return r.renderToString(a.createElement(nt,{className:$.lineChartLabelFlex},a.createElement(rt,{className:$.lineChartLabel},"function"==typeof s?s(t,e,l):i(t))))}).each("function"==typeof c?c:K)})})({node:t,eachLabel:A,data:I,yScale:U,xScale:et,formatLabel:M}),S&&(t=>{let{svg:e,node:l,data:i,xScale:o,yScale:s,dynamicCircleRadius:u,formatDynamicTooltip:p,renderTooltip:h,stackedTooltipIndex:m,stackedTooltip:f,tooltipLineTop:b}=t;n.select(l).select("."+$.lineChartMouseLabelContainer).remove();const g="number"==typeof m?[i[m]]:f?[i[0]]:i,[x,y]=o.range(),[C,L]=s.range(),v=e.append("g").attr("class",$.lineChartMouseGlobal),M=v.append("rect").attr("width",y-x).attr("height",Math.abs(C-L)).attr("class",$.lineChartMouseRect).attr("transform","translate("+x+", "+L+")"),A=v.append("path").attr("class",$.lineChartMouseLine).style("opacity","0"),T=e.selectAll("."+$.lineChartLine).nodes(),S=v.selectAll("circle").data(i).join("circle").attr("class",$.lineChartMouseCircle).attr("r",u).attr("fill",t=>{let{stroke:e}=t;return e||"none"}).attr("stroke",t=>{let{stroke:e}=t;return e||"none"}).style("opacity","0"),k=n.select(l).append("div").attr("class",$.lineChartMouseLabelContainer).selectAll("div").data(g).join("div").attr("class",$.lineChartMouseLabel).style("opacity","0").style("position","absolute").html(()=>r.renderToString(a.createElement(nt,{className:$.lineChartLabelFlex},a.createElement(rt,{className:$.lineChartLabel}))));let G=!1;const N=t=>{G=Boolean(t);const e=G?"1":"0";A.style("opacity",e),S.style("opacity",e),k.style("opacity",e)};M.on("mouseover",()=>N(!0)),M.on("mouseout",()=>N()),M.on("touchmove mousemove",t=>{const[e]=n.pointer(t,M),[u]=n.pointer(t,l),g=e-(e-u),x=o.invert(g),y={};T.forEach((t,e)=>{let a={x:0,y:0},n=0,r=t.getTotalLength(),l=null;for(;l=Math.floor((n+r)/2),a=t.getPointAtLength(l),l!==r&&l!==n||a.x===g;)if(a.x>g)r=l;else{if(!(a.x<g))break;n=l}y[e]=a}),S.attr("transform",(t,e)=>"translate("+g+","+y[e].y+")");const v=n.format(","),w=i.map((t,e)=>{let{values:a}=t;return c({},d(t,["values"]),{value:a[Math.floor(x)],invertValue:s.invert(y[e].y)})}),E=1===w.length&&(null==(Y=w[0].value)||Number.isNaN(Y));var Y;E&&G?N():G||E||N(!0);const P=Object.keys(y).reduce((t,e,a)=>0===a?t:y[t].y>y[e].y?e:t,"0"),I=k.style("left",g+"px").style("top",(t,e)=>{const a="number"==typeof m?m:f?P:e;return(y[a]&&y[a].y)+"px"}).select("."+$.lineChartLabel);"function"==typeof h?k.html((t,e)=>r.renderToString(a.createElement(nt,{className:$.lineChartLabelFlex},h(w,{indexX:Math.round(x),indexY:e})))):I.text((t,e)=>{const a=w[e].invertValue;return"function"==typeof p?p(a,w[e].value):v(a)}),A.attr("d",()=>{let t="M"+g+","+C;return t+=" "+g+","+(b?L:y[P].y),t})})})({tooltipLineTop:Y,stackedTooltip:w,renderTooltip:N,stackedTooltipIndex:E,formatDynamicTooltip:G,node:t,svg:W,data:I,xScale:et,yScale:U,dynamicCircleRadius:k}),"function"==typeof P&&P({svg:W,yScale:U,xScale:et})}},it=t=>{const{className:n,style:r,children:l}=t,[i,c]=o();return e.useEffect(()=>{c&<(c,t)},[c,t]),s(t.width,()=>lt(c,t)),a.createElement("div",{className:n,style:r},a.createElement(tt,{ref:i},l))};it.defaultProps={data:[],labels:[],height:240,yAxisPadding:10,xAxisPadding:20,margin:{top:10,right:10,bottom:10,left:0},dynamicCircleRadius:4};const ot={barChartLinesGlobal:"barChartLinesGlobal",barChartLine:"barChartLine",barChartAreasGlobal:"barChartAreasGlobal",barChartArea:"barChartArea"};function st(){const t=u(["\n line {\n stroke-width: 1px;\n shape-rendering: crispEdges;\n }\n .",",\n ."," {\n stroke: rgba(48, 69, 79, 0.06);\n }\n ."," {\n }\n ."," {\n fill: none;\n pointer-events: all;\n }\n ."," {\n z-index: 1;\n }\n ."," {\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n ."," {\n shape-rendering: auto;\n }\n ."," {\n fill-opacity: 0.24;\n }\n ."," {\n margin-bottom: 4px;\n :last-of-type {\n margin-bottom: 0;\n }\n }\n"]);return st=function(){return t},t}const ct=c({barChartBarGlobal:"barChartBarGlobal",barChartYScaleGlobal:"barChartYScaleGlobal",barChartYAxis:"barChartYAxis",barChartXAxis:"barChartXAxis",barChartGridGlobal:"barChartGridGlobal",barChartGridLineX:"barChartGridLineX",barChartGridLineXZero:"barChartGridLineXZero",barChartGridLineYZero:"barChartGridLineYZero",barChartGridLineY:"barChartGridLineY"},{barChartMouseRect:"barChartMouseRect",barChartMouseContainer:"barChartMouseContainer",barChartTooltipFlex:"barChartTooltipFlex",barChartMouseTooltip:"barChartMouseTooltip",barChartTooltip:"barChartTooltip",barChartTooltipItem:"barChartTooltipItem",barChartTooltipColFlex:"barChartTooltipColFlex",barChartTooltipGroupName:"barChartTooltipGroupName",barChartColorBox:"barChartColorBox",barChartColorLine:"barChartColorLine",barChartTooltipName:"barChartTooltipName",barChartTooltipValue:"barChartTooltipValue"},{barChartLabelContainer:"barChartLabelContainer",barChartLabelFlex:"barChartLabelFlex",barChartLabel:"barChartLabel"},ot),dt=i(N)(st(),ct.barChartGridLineX,ct.barChartGridLineY,ct.barChartMouseRect,ct.barChartMouseRect,ct.barChartMouseTooltip,ct.barChartLinesGlobal,ct.barChartLine,ct.barChartArea,ct.barChartTooltipItem);function ut(){const t=u(["\n bottom: 6px;\n"]);return ut=function(){return t},t}function pt(){const t=u(["\n top: 6px;\n"]);return pt=function(){return t},t}function ht(){const t=u(["\n position: relative;\n font-size: 11px;\n color: #fff;\n font-weight: bold;\n letter-spacing: 0.52px;\n"]);return ht=function(){return t},t}function mt(){const t=u(["\n text-align: right;\n flex-shrink: 0;\n flex-grow: 1;\n"]);return mt=function(){return t},t}function ft(){const t=u(["\n margin-right: 4px;\n"]);return ft=function(){return t},t}function bt(){const t=u(["\n height: 2px;\n border-radius: 0;\n"]);return bt=function(){return t},t}function gt(){const t=u(["\n margin-right: 4px;\n width: 10px;\n height: 10px;\n border-radius: 2px;\n"]);return gt=function(){return t},t}function xt(){const t=u(["\n display: flex;\n align-items: center;\n margin-right: 4px;\n"]);return xt=function(){return t},t}function yt(){const t=u(["\n display: flex;\n align-items: center;\n"]);return yt=function(){return t},t}function Ct(){const t=u(["\n font-size: 14px;\n margin-bottom: 6px;\n"]);return Ct=function(){return t},t}function Lt(){const t=u(["\n position: relative;\n font-size: 11px;\n color: #fff;\n margin-bottom: 8px;\n padding: 4px 6px;\n background-color: rgba(48, 69, 79, 1);\n border-radius: 4px;\n :before {\n content: '';\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, 100%);\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 4px 3px 0 3px;\n border-color: rgba(48, 69, 79, 1) transparent transparent transparent;\n }\n"]);return Lt=function(){return t},t}function vt(){const t=u(["\n align-items: center;\n"]);return vt=function(){return t},t}function Mt(){const t=u([""]);return Mt=function(){return t},t}function At(){const t=u(["\n width: 0;\n height: 0;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n pointer-events: none;\n white-space: nowrap;\n"]);return At=function(){return t},t}const Tt=i.div(At()),St=i(Tt)(Mt()),kt=i(St)(vt()),Gt=i.div(Lt()),Nt=i.div(Ct()),wt=i.div(yt()),Et=i.div(xt()),Yt=i.div(gt()),Pt=i(Yt)(bt()),It=i.div(ft()),Rt=i.div(mt()),Dt=i.div(ht()),Xt=i(Dt)(pt()),Bt=i(Dt)(ut()),Ot=(t,e)=>{const{data:l,lineData:i=[],barWidth:o,barPadding:s,colors:u,margin:h,xAxisPadding:m,yAxisPadding:f,drawGridY:b,drawGridX:g,customYScale:x,customXScale:y,customYAxisLeft:C,customXAxisBottom:L,customYAxis:v,customXAxis:M,customBars:A,customize:T,dynamicTooltipEnable:S,renderTooltip:k,labelPosition:G,renderLabel:N,tooltipY:w,tooltipBind:E,stackedLine:Y,curve:P,formatTooltipValue:I,formatTooltipName:R,sectionPadding:D,minValuesLine:X,tooltipYDomain:B,marshalledMap:O,minValue:j,maxValue:F,minDomainValue:V,maxDomainValue:z,drawBars:W}=e;if(null!==t&&l.length){const U=h?h.top:0,_=h?h.right:0,q=h?h.bottom:0,H=h?h.left:0,Z=12,{width:K}=t.getBoundingClientRect(),Q=e.width||K,$=e.height||0,tt=(t=>{let{data:e,minDomainValue:a,maxDomainValue:n}=t,r=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.forEach(t=>{let e=d(t,["groupName"]),a=0,n=0;Object.keys(e).forEach(t=>{const r=e[t];let l=0,i=0;Object.keys(r).forEach(t=>{const e=r[t];e>0?l+=e:i+=e}),a=Math.min(a,i),n=Math.max(n,l)}),r=Math.min(r,a),l=Math.max(l,n)}),0===r&&0===l?{min:"number"==typeof a?a:0,max:"number"==typeof n?n:1}:{min:"number"==typeof a?a:r,max:"number"==typeof n?n:l}})({data:l,minDomainValue:V,maxDomainValue:z}),et="number"==typeof j?j:Math.min(n.min(i,t=>{let{values:e}=t;return n.min(e)})||Number.POSITIVE_INFINITY,tt.min||0),at="number"==typeof F?F:Math.max(n.max(i,t=>{let{values:e}=t;return n.max(e)})||Number.NEGATIVE_INFINITY,tt.max),nt=p(t,Q,$||0),rt=6,lt=l.map(t=>t.groupName);let it=o||Z;const st=n.scaleLinear().domain([et,at]).range([$-U-q-(m||0),U]).nice();"function"==typeof x&&x(st);const dt=st.ticks(),ut=n.axisLeft(st).ticks(rt);"function"==typeof C&&C(ut);const pt=ut.tickArguments()[0],ht=nt.append("g").attr("class",ct.barChartYAxis).call(ut);"function"==typeof v&&v(ht);const{width:mt}=J(ht),ft=[H+mt+(f||0),Q-_],bt=n.scaleBand().domain(n.range(l.length)).range(ft);it=(t=>{let{data:e,range:a,barWidth:n,barPadding:r,sectionPadding:l}=t;const i="number"==typeof l?l:0,o=a[1]-a[0],s=e.reduce((t,e)=>{let a=d(e,["groupName"]);return t+Object.keys(a).reduce((t,e,a)=>a>0?t+(n||0)+(r||0):t+n,0)+i},i);return o<s?Math.floor(n*(o/s)):n})({data:l,sectionPadding:D,range:ft,barWidth:it,barPadding:s}),"function"==typeof y&&y(bt);const gt=n.axisBottom(bt).tickFormat((t,e)=>lt[e]);"function"==typeof L&&L(gt);const xt=nt.append("g").call(gt).attr("class",ct.barChartXAxis);"function"==typeof M&&M(xt),ht.attr("transform","translate("+(H+mt)+", 0)");const yt=(t=>{let{data:e,yScale:a,xScale:n,barWidth:r,barPadding:l,colors:i,marginTop:o}=t;return e.map((t,e)=>{let{groupName:s}=t,c=d(t,["groupName"]);const u=[],p=n.bandwidth(),h=Object.keys(c);return h.forEach((t,n)=>{const d=c[t],m=Object.keys(d),f=(r+l)*h.length-(m.length>1?l:0);let b=0,g=0;m.forEach(t=>{const c=d[t],h=i[t],m=(r+l)*n+p/2-f/2,x=c>0,y=x?Math.abs(Math.round(100*(a(b-c)-a(b)+Number.EPSILON))/100):Math.abs(Math.round(100*(a(g-c)-a(g)+Number.EPSILON))/100);x&&(b+=c);const C=x?Math.round(100*(a(b)+Number.EPSILON))/100:a(g)-a(0)+a(0);u.push({x:Math.round(m),y:Math.round(C+(o||0)),height:Math.round(y),color:h,value:c,groupName:s,name:t,stackIndex:n,groupIndex:e}),x||(g+=c)})}),u})})({data:l,yScale:st,xScale:bt,barWidth:it,barPadding:"number"==typeof s?s:0,colors:u,marginTop:U}),Ct="function"==typeof O?O(yt):yt;ht.attr("transform","translate( "+((H||0)+mt)+", 0)"),(t=>{let{svg:e,yScale:a,xScale:n,yTicksCount:r,drawGridX:l,drawGridY:i}=t;if(!i&&!l)return;const o=e.append("g").attr("class",ct.barChartGridGlobal),s=a.ticks(r),c=n.range(),d=n.domain();if(l&&o.append("g").selectAll("line").data(s).join("line").attr("class",t=>0===t?ct.barChartGridLineX+" "+ct.barChartGridLineXZero:ct.barChartGridLineX).attr("x1",()=>c[0]).attr("x2",()=>c[1]).attr("y1",t=>Math.round(a(t))).attr("y2",t=>Math.round(a(t))),i){const t=t=>void 0!==d[t]?0===t?c[0]:Math.round(n.step()*t+c[0]-n.step()/2*n.padding()):c[1];o.append("g").selectAll("line").data(Array.from({length:d.length+1},(t,e)=>e)).join("line").attr("class",t=>0===t?ct.barChartGridLineY+" "+ct.barChartGridLineYZero:ct.barChartGridLineY).attr("x1",t).attr("x2",t).attr("y1",()=>Math.round(a(s[0]))).attr("y2",()=>Math.round(a(s[s.length-1])))}})({svg:nt,yScale:st,xScale:bt,yTicksCount:pt,drawGridY:b,drawGridX:g}),xt.attr("transform","translate(0, "+(st(dt[0])+(m||0))+")");const Lt=nt.append("g").attr("class",ct.barChartBarGlobal).selectAll("g").data(Ct).enter().append("g").attr("transform",(t,e)=>"translate("+Math.round(bt(e.toString()))+","+-(U||0)+")"),vt="function"==typeof W?W({groups:Lt,yScale:st,marshalledData:Ct}):(t=>{let{groups:e,barWidth:a}=t;return e.selectAll("rect").data(t=>t).join("rect").attr("x",t=>t.x).attr("y",t=>t.y).attr("width",a).attr("height",t=>t.height).style("fill",t=>t.color)})({groups:Lt,barWidth:it});let Mt=null;Array.isArray(i)&&i.length>0&&(Mt=(t=>{let{svg:e,lineData:a,min:r,yScale:l,xScale:i,curve:o,stackedLine:s}=t,c=null,d=null,u=null;const p=n.line().defined(t=>null!==t).x((t,e)=>i(e.toString())+h/2).y(t=>l(t)).curve(o||n.curveLinear),h=i.bandwidth(),m=a.filter(t=>{let{lineType:e}=t;return"line"===e}),f=a.filter(t=>{let{lineType:e}=t;return"area"===e});if(m.length>0&&(c=e.append("g").attr("class",ot.barChartLinesGlobal).selectAll("path").data(m).join("path").attr("class",ot.barChartLine).attr("d",t=>p(t.values)).attr("stroke",t=>{let{stroke:e}=t;return e||""}).attr("fill",t=>{let{fill:e}=t;return e||"none"})),f.length>0){let t=-2;u=n.area().x((t,e)=>i(e.toString())+h/2).y0((e,n)=>(0===n&&(t+=1),l(s&&t>-1?"number"!=typeof a[t].values[n]?0:a[t].values[n]:r))).y1(t=>l(t)).curve(o||n.curveLinear),d=e.append("g").attr("class",ot.barChartAreasGlobal).selectAll("path").data(f).join("path").attr("class",ot.barChartArea).attr("d",t=>u&&u(t.values)).attr("fill",t=>{let{fill:e}=t;return e||"none"})}return{areasSelection:d,linesSelection:c,area:u}})({svg:nt,lineData:i,xScale:bt,yScale:st,min:"number"==typeof X?X:et,stackedLine:Y,curve:P})),"function"==typeof A&&A({bars:vt,yScale:st,lines:Mt,marshalledData:Ct,lineData:i}),(S||G)&&(t=>{let{svg:e,node:l,data:i,marshalledData:o,xScale:s,yScale:u,renderTooltip:p,labelPosition:h,marginTop:m,renderLabel:f,barWidth:b,dynamicTooltipEnable:g,tooltipY:x,tooltipBind:y,lineData:C,formatTooltipValue:L,formatTooltipName:v,tooltipYDomain:M}=t;n.select(l).select("."+ct.barChartMouseContainer).remove();const A=s.domain(),[T,S]=s.range(),[k,G]=u.range(),N=s.bandwidth(),w=n.format(","),E=A.map(t=>{return e=Number(t)+1,void 0!==A[e]?0===e?T:Math.round(s.step()*e+T-s.step()/2*s.padding()):S;var e}),Y="function"==typeof M?M({data:o,lineData:C,yScale:u}):o.reduce((t,e,a)=>{const r=n.min(C,t=>{let{values:e}=t;return"number"==typeof e[a]?u((e[a]||0)-G):Number.POSITIVE_INFINITY})||Number.POSITIVE_INFINITY;return t.push(e.reduce((t,e)=>{let{y:a}=e;return Math.min(t,a,r)},Number.POSITIVE_INFINITY)),t},[]),P=e.append("g").attr("class","lineChartMouseGlobal").append("rect").attr("width",S-T).attr("height",Math.abs(k-G)).attr("class",ct.barChartMouseRect).attr("transform","translate("+T+", "+G+")"),I=n.select(l).append("div").attr("class",ct.barChartMouseContainer);if(g){const t=I.append("div").attr("class",ct.barChartMouseTooltip).style("opacity","0").style("position","absolute").html(()=>r.renderToString(a.createElement(Tt,{className:ct.barChartTooltipFlex},a.createElement(Gt,{className:ct.barChartTooltip})))),e=t.select("."+ct.barChartTooltipFlex),u=t.select("."+ct.barChartTooltip);let h=!1,m=null;const f=e=>{h=Boolean(e),t.style("opacity",h?"1":"0"),h?t.style("transition",null):(m=null,t.style("transition","none"),t.style("top",null),t.style("left",null))};P.on("mouseout",()=>f()),P.on("touchmove mousemove",b=>{const[g]=n.pointer(b,P),[M]=n.pointer(b,l),A=g-(g-M),T=E.findIndex(t=>A<=t);if(y&&m===T)return;let S=o[T];if(!Array.isArray(S)||0!==S.length){if(C){const t=C.map(t=>{let{values:e}=t;return c({},d(t,["values"]),{value:e[T],groupName:i[T]&&i[T].groupName})});Array.isArray(t)&&Array.isArray(S)&&(S=t.concat(S))}t.style("left",(y?(s(T.toString())||0)+N/2:A)+"px").style("top",()=>("number"==typeof x?x:Y[T]-G)+"px"),"function"==typeof p?e.html(()=>r.renderToString(a.createElement(a.Fragment,null,p(S)))):(h||f(!0),u.html(()=>r.renderToString(a.createElement(a.Fragment,null,S&&S[0]&&a.createElement(Nt,{className:ct.barChartTooltipGroupName},S[0].groupName),S&&S.map(t=>{let{name:e,value:n,stroke:r,fill:l,color:i,lineType:o}=t;return a.createElement(wt,{key:e,className:ct.barChartTooltipItem},a.createElement(Et,{className:ct.barChartTooltipColFlex},o?a.createElement(Pt,{className:ct.barChartColorLine,style:{backgroundColor:r||l}}):a.createElement(Yt,{className:ct.barChartColorBox,style:{backgroundColor:i}}),a.createElement(It,{className:ct.barChartTooltipName},"function"==typeof v?v(e):e)),a.createElement(Rt,{className:ct.barChartTooltipValue},"function"==typeof L?L(n):w(n)))}))))),m=T,h||f(!0)}})}const R=I.append("div").attr("class",ct.barChartLabelContainer).style("position","absolute").style("top",G+"px");if(h){const t=R.selectAll("div").data(o).enter().append("div").style("position","absolute").style("transform",(t,e)=>"translate("+s(e.toString())+"px,"+-(m||0)+"px)"),e="center"===h?kt:St,n=(t=>{switch(t){case"top":return Xt;case"bottom":return Bt;default:return Dt}})(h);t.selectAll("span").data(t=>t).join("div").style("left",t=>t.x+b/2+"px").style("top",t=>((t,e,a)=>{switch(t){case"center":return a.y+a.height/2-e;case"bottom":return a.y+a.height-e;default:return a.y}})(h,G,t)+"px").style("position","absolute").html(t=>r.renderToString(a.createElement(e,{className:ct.barChartLabelFlex},"function"==typeof f?f(t):a.createElement(n,{className:ct.barChartLabel},t.value))))}})({svg:nt,node:t,xScale:bt,yScale:st,marshalledData:Ct,data:l,lineData:i,renderTooltip:k,labelPosition:G,marginTop:U,renderLabel:N,barWidth:it,dynamicTooltipEnable:S,tooltipY:w,tooltipBind:E,formatTooltipValue:I,formatTooltipName:R,tooltipYDomain:B}),"function"==typeof T&&T({svg:nt,marshalledData:Ct,yScale:st,xScale:bt})}},jt=t=>{const{className:n,style:r,children:l}=t,[i,c]=o();return e.useEffect(()=>{c&&Ot(c,t)},[c,t]),s(t.width,()=>Ot(c,t)),a.createElement("div",{className:n,style:r},a.createElement(dt,{ref:i},l))};jt.defaultProps={data:[],colors:{},margin:{top:10,right:10,bottom:10,left:0},barWidth:12,barPadding:0,height:320,yAxisPadding:0,xAxisPadding:0,tooltipBind:!0,sectionPadding:1},exports.BarChart=jt,exports.CalendarChart=Z,exports.LineChart=it,exports.PieChart=V,exports.RadarChart=I,exports.barChartClassNames=ct,exports.calendarChartClassNames=q,exports.lineChartClassNames=$,exports.pieChartclassNames=X,exports.radarChartclassNames=E; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),a=t(e),n=require("styled-components"),r=t(n),l=require("d3"),i=t(require("react-dom/server"));function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t}).apply(this,arguments)}function s(t,e){if(null==t)return{};var a,n,r={},l=Object.keys(t);for(n=0;n<l.length;n++)e.indexOf(a=l[n])>=0||(r[a]=t[a]);return r}function c(t,e){return e||(e=t.slice(0)),t.raw=e,t}function d(){const t=c(["\n width: 100%;\n overflow: hidden;\n user-select: none;\n"]);return d=function(){return t},t}const u=r.div(d());function h(){const[t,a]=e.useState(null);return[e.useCallback(t=>a(t),[]),t]}const p=t=>t*(2-t),m=(t,e,a)=>Math.min(Math.max(t,e),a),b={animation:0,speed:0,timestamp:0,startX:0,currentX:0},g=t=>{let{children:n,width:r}=t,i=s(t,["children","width"]);const[c,d]=h();return((t,a)=>{let{width:n,duration:r,animationFunc:i,onSwipe:o}=a;const s=l.select(t),c=l.select("body"),d=l.select(document),u=e.useRef(b);e.useEffect(()=>{n&&u.current.animation&&(cancelAnimationFrame(u.current.animation),u.current=b)},[n]);const h=e.useCallback(e=>{const{width:a}=t?t.getBoundingClientRect():{width:0},[r]=l.pointer(e.type.includes("touch")?e.touches[0]:e),i=m(r-u.current.startX,-(n-a),0);if(s.style("transform","translateX("+i+"px)"),u.current.currentX){const t=100,e=Date.now(),a=Math.round((i-u.current.currentX)/(e-u.current.timestamp)*t);u.current.speed=a,u.current.timestamp=e}u.current.currentX=i,o&&o(i,s)},[o,n,t,s]),g=e.useCallback(()=>{const{width:e}=t?t.getBoundingClientRect():{width:0};d.on("mousemove touchmove mouseup touchend",null),c.style("cursor",null),s.style("cursor",n>e?"grab":null),Date.now()-u.current.timestamp<44&&function(t){let{duration:e,timing:a,draw:n}=t;const r=performance.now();let l;requestAnimationFrame((function t(i){let o=(i-r)/e;o<1&&(l=requestAnimationFrame(t)),o>1&&cancelAnimationFrame(l);const s=a(o);n(s,l)}))}({duration:r,timing:i||p,draw:(t,a)=>{u.current.animation=a;const r=Math.round(2*u.current.speed*t),l=u.current.currentX+r,i=n-e,c=m(l,-i,0),d=Math.max(Math.min(l,i),0);u.current.currentX!==d&&(s.style("transform","translateX("+c+"px)"),o&&o(c,s))}})},[c,i,o,s,r,t,n,d]),f=e.useCallback(e=>{const a=e.type.includes("touch"),[n]=l.pointer(a?e.touches[0]:e,t),{left:r}=t&&t.parentElement?t.parentElement.getBoundingClientRect():{left:0};c.style("cursor","grabbing"),s.style("cursor","grabbing"),u.current.animation&&(cancelAnimationFrame(u.current.animation),u.current=b),u.current.startX=Math.max(n+r,0),d.on("mousemove touchmove",h),d.on("mouseup touchend",g)},[s,c,t,g,h,d]);e.useEffect(()=>{if(t){const{width:e}=t.getBoundingClientRect();n>e&&(s.style("cursor","grab"),s.on("mousedown touchstart",f))}},[s,f,t,n])})(d,o({width:r},i)),a.createElement(u,Object.assign({},i),a.createElement("div",{ref:c},n))};g.defaultProps={duration:1400};const f=(t,a)=>{const n=e.useMemo(()=>a?function(t,e){let a=!1;return function(){a||(t(...arguments),a=!0,setTimeout((function(){a=!1}),44))}}(a):void 0,[a]);e.useEffect(()=>(n&&"number"!=typeof t&&window.addEventListener("resize",n),()=>n&&window.removeEventListener("resize",n)),[t,n])},x=(t,e,a)=>(l.select(t).select("svg").remove(),l.select(t).append("svg").attr("width",e).attr("height",a));function y(){const t=c(["\n position: absolute;\n"]);return y=function(){return t},t}const C=t=>{let{anchor:e,index:a,translateX:n,translateY:r}=t;return 0===a&&"middle"===e?"translate(calc(-50% + "+n+"px), calc(-100% + "+r+"px))":"middle"===e?"translate(calc(-50% + "+n+"px), calc("+r+"px))":"start"===e?"translate(calc("+n+"px), calc(-50% + "+r+"px))":"end"===e?"translate(calc(-100% + "+n+"px), calc(-50% + "+r+"px))":"translate("+n+"px, "+r+"px)"},v=r.div.attrs(t=>({style:{transform:C(t)}}))(y());function L(){const t=c(["\n margin-left: 4px;\n font-size: 10px;\n color: rgba(255, 255, 255, 0.54);\n"]);return L=function(){return t},t}function M(){const t=c(["\n ","\n"]);return M=function(){return t},t}function A(){const t=c(["\n display: flex;\n align-items: center;\n padding: 2px 4px;\n border-radius: 4px;\n color: rgb(255, 255, 255);\n background-color: rgb(144, 197, 61);\n margin-left: 8px;\n"]);return A=function(){return t},t}function T(){const t=c(["\n position: absolute;\n top: 50%;\n right: 0;\n transform: translate(calc(100% + 6px), -50%);\n"]);return T=function(){return t},t}function S(){const t=c(["\n text-align: center;\n max-width: 120px;\n"]);return S=function(){return t},t}function k(){const t=c(["\n display: flex;\n align-items: center;\n font-size: 12px;\n"]);return k=function(){return t},t}const w=r.div(k()),G=r.div(S()),N=n.css(T()),E=r.div(A()),Y=r(E)(M(),N),R=r.div(L());function P(){const t=c(["\n position: relative;\n width: 100%;\n box-sizing: border-box;\n"]);return P=function(){return t},t}const I=r.div(P());function D(){const t=c(["\n ."," {\n path,\n line,\n circle {\n fill: none;\n stroke-width: 1px;\n stroke: rgba(149, 149, 149, 0.18);\n }\n }\n ."," {\n font-size: 12px;\n fill-opacity: 0.56;\n }\n ."," {\n fill-opacity: 0.06;\n stroke-width: 2px;\n fill: rgb(144, 197, 61);\n stroke: rgb(144, 197, 61);\n }\n ."," {\n fill: rgb(144, 197, 61);\n }\n"]);return D=function(){return t},t}const X={radar:"radar",radarAxis:"radarAxis",radarAxisTextGlobal:"radarAxisTextGlobal",radarAxisText:"radarAxisText",radarPolygon:"radarPolygon",radarLabel:"radarLabel",radarLabelName:"radarLabelName",radarLabelBadge:"radarLabelBadge",radarLabelBadgePrefix:"radarLabelBadgePrefix",radarCircle:"radarCircle"},B=r(I)(D(),X.radarAxis,X.radarAxisText,X.radarPolygon,X.radarCircle),F=(t,e)=>{const{data:n,curve:r,polar:s,formatValue:c,badgePrefix:d,labelOffset:u,circleRadius:h,svgElements:p,renderLabel:m,customize:b}=e;if(null!==t&&n.length){const g=10,f="number"==typeof e.bleedLength?e.bleedLength:g,{width:y}=t.getBoundingClientRect(),C=e.width||y,L=400,M=e.height||L,A=e.minValue||Math.min(0,l.min(n,t=>l.min(t.map(t=>{let{value:e}=t;return e})))),T=(e.maxValue||Math.max(0,l.max(n,t=>l.max(t.map(t=>{let{value:e}=t;return e})))))-A,S=e.paddingY||0,k=Math.min((C-2*(e.paddingX||0)-2*f)/2,(M-2*S-2*f)/2),N=l.scaleLinear().range([0,k]).domain([0,T]),P=4,I=e.levels||P,D=2*Math.PI/n[0].length,B=l.lineRadial().curve(l.curveLinearClosed).radius(t=>{let{value:e}=t;return N(e)}).angle((t,e)=>e*D),F=l.lineRadial().curve(r||l.curveLinearClosed).radius(t=>{let{value:e}=t;return N(e)}).angle((t,e)=>e*D),O=x(t,C,M),j=O.append("g"),V=l.range(1,I+1).reverse(),z=t=>-t*k/I,W=t=>T*t/I,q=j.append("g").attr("class",X.radarAxis).selectAll().data([n[0]]).enter(),U=j.append("g").attr("class",X.radar),_=q.selectAll().data(n[0].map(t=>{let{name:e}=t;return e})).enter();let H=0;s?V.forEach(t=>{const e=q.append("circle").attr("cx",0).attr("cy",0).attr("r",()=>k/I*t).node().getBoundingClientRect().height;H=Math.max(H,e)}):V.map(W).forEach(t=>{const e=q.append("path").attr("d",()=>B(Array.from({length:n[0].length},()=>({value:t})))).node().getBoundingClientRect().height;H=Math.max(H,e)});const Z=N(T)+f;_.append("line").attr("x1",0).attr("y1",0).attr("x2",(t,e)=>Math.round(Z*Math.cos(D*e-Math.PI/2))).attr("y2",(t,e)=>Math.round(Z*Math.sin(D*e-Math.PI/2))),n.forEach(t=>{U.append("path").attr("class",X.radarPolygon).attr("d",()=>F(t.map(t=>o({},t,{value:t.value-A}))))}),j.append("g").attr("class",X.radarAxisTextGlobal).selectAll("text").data(V).enter().append("text").attr("class",X.radarAxisText).attr("x","4").attr("y",z).attr("dy",0).attr("dominant-baseline","central").text(t=>W(t)+A),h&&n.forEach(t=>{const e=j.append("g").attr("class",X.radarCircle);t.forEach((t,a)=>{let{value:n}=t;e.append("circle").attr("cx",Math.round(N(n)*Math.cos(D*a-Math.PI/2))).attr("cy",Math.round(N(n*Math.sin(D*a-Math.PI/2)))).attr("r",h)})});const J=8,K=M-f-S,Q=C/2,$=K/2+(K-H)/2,tt=f+(u||J);if(j.attr("transform","translate("+Q+","+$+")"),(t=>{let{node:e,dataLength:n,radiusScale:r,maxValue:o,angleSlice:s,radius:c,xOffset:d,yOffset:u,translateX:h,translateY:p,renderLabel:m}=t;const b=l.select(e);b.selectAll(".d3-chart-label").remove();const g=t=>o/c*t,f=t=>r((o+g(u||0))*Math.sin(s*t-Math.PI/2));Array.from({length:n},(t,e)=>{return{x:Math.ceil((a=e,r(o+g(d||0))*Math.cos(s*a-Math.PI/2))),y:Math.ceil(f(e))};var a}).forEach((t,e)=>{let{x:r,y:l}=t;const o=((t,e)=>{const a=((t,e)=>360/e*t)(t,e),n=180;return[0,n].includes(a)?"middle":a<n?"start":"end"})(e,n),s=i.renderToString(a.createElement(v,{anchor:o,translateX:h||0,translateY:p||0,index:e,style:{left:r,top:l}},"function"==typeof m?m(o,e):m));b.append("div").attr("class","d3-chart-label").html(s)})})({node:t,maxValue:T,translateX:Q,translateY:$,dataLength:n[0].length,angleSlice:D,radius:k,radiusScale:N,xOffset:tt,yOffset:tt,renderLabel:(t,e)=>{const r="middle"===t?Y:E,l=n[0][e].name,i=n[0][e].value;return m?m({name:l,value:i}):a.createElement(w,{className:X.radarLabel},a.createElement(G,{className:X.radarLabelName},l),1===n.length&&a.createElement(r,{className:X.radarLabelBadge},c?c(i):i,d&&a.createElement(R,{className:X.radarLabelBadgePrefix},d)))}}),p){const t=i.renderToString(p);O.append("g").html(t)}b&&b(O)}},O=t=>{const{className:n,style:r}=t,[l,i]=h();return e.useEffect(()=>{i&&F(i,t)},[i,t]),f(t.width,()=>F(i,t)),a.createElement("div",{className:n,style:r},a.createElement(B,{ref:l}))};function j(t){return t*(Math.PI/180)}function V(){const t=c(["\n ."," {\n fill: #4a4a4a;\n }\n ."," {\n position: absolute;\n max-width: 128px;\n }\n ."," {\n stroke: #000;\n }\n"]);return V=function(){return t},t}O.defaultProps={height:400,data:[],curve:l.curveLinearClosed};const z={pieSlice:"pieSlice",pieSliceLabel:"pieSliceLabel",pieSliceLabelValue:"pieSliceLabelValue",pieSliceLabelName:"pieSliceLabelName",pieRadialLabel:"pieRadialLabel",pieRadialLink:"pieRadialLink"},W=r(I)(V(),z.pieSliceLabel,z.pieRadialLabel,z.pieRadialLink),q=t=>t.startAngle+(t.endAngle-t.startAngle)/2<Math.PI?1:-1,U=t=>t.startAngle+(t.endAngle-t.startAngle)/2<Math.PI?"start":"end",_=(t,e)=>{const{data:a,padAngle:n,onClick:r,outerRadius:o,startAngle:s,endAngle:c,cornerRadius:d,margin:u,enableSlicesLabels:h,formatSliceLabel:p,slicesLabelsSkipAngle:m,enableSlicesLabelsName:b,formatSliceLabelName:g,borderWidth:f,borderColor:y,enableRadialLabels:C,backgroundColor:v,radialLabelsLinkHorizontalLength:L,radialLabelsTextXOffset:M,formatRadialLabel:A,radialLabelYOffset:T,svgElements:S,formatSliceTitle:k,radialAngleXOffset:w}=e;if(null!==t&&a.length){const G=u?u.top:0,N=u?u.right:0,E=u?u.bottom:0,Y=u?u.left:0,{width:R}=t.getBoundingClientRect(),P=e.width||R,I=240,D=e.height||I,X=(Math.min(P,D)-2*(f||0)-(P>D?G+E:N+Y))/2,B=x(t,P,D),F=B.append("g").attr("transform","translate("+((P-(Y+N))/2+Y)+","+((D-(E+G))/2+G)+")"),O=45,V=100,W=360,_=l.pie().startAngle(-j(s||0)).endAngle(j(c||W)).padAngle(n?Math.max(Math.min(n/V,O),0):0).sort(null).value(t=>{let{value:e}=t;return e})(a),H=.95,Z=l.arc().cornerRadius(d||0).innerRadius(X).outerRadius(X*Math.min(Math.max(o||0,0),H));if("string"==typeof v&&F.append("path").attr("fill",v).attr("d",()=>Z({startAngle:j(0),endAngle:j(W)})),F.selectAll("allSlices").data(_).enter().append("path").attr("d",Z).attr("class",z.pieSlice).attr("fill",t=>{let{index:e}=t;return a[e].color||""}).attr("stroke",y||"").attr("stroke-width",f||0).attr("style",r?"cursor: pointer":"").on("click",(t,e)=>r&&r(a[e.index])).append("svg:title").text(t=>k?k(t):(a[t.index].name||"")+" ("+(t=>{if(null==t)return"";let e="";const a=String(t).split("."),n=a[0];let r=n.length%3;for(let t=0;t<n.length;t++)t===r&&(e+=" ",r+=3),e+=n[t];return a[1]?[e.trim(),a[1]].join(","):e.trim()})(parseFloat(a[t.index].value.toFixed(2)))+")"),h){const t=F.selectAll("allSlices").data(_).enter().append("text").attr("class",z.pieSliceLabel).attr("text-anchor","middle").attr("dominant-baseline","central").attr("transform",t=>"translate("+Z.centroid(t)+")");t.append("tspan").attr("class",z.pieSliceLabelValue).text(t=>{const e=180*(t.endAngle-t.startAngle)/Math.PI;if(!m||e>m)return p?p(t):t.value}),b&&t.append("tspan").attr("class",z.pieSliceLabelName).text(t=>g?g(t):t.data.name).attr("x","0").attr("dy","1.2em")}if((t=>{let{arc:e,enableRadialLabels:a,global:n,node:r,radius:o,dataReady:s,radialLabelsLinkHorizontalLength:c,formatRadialLabel:d,radialLabelsTextXOffset:u,translateX:h,translateY:p,radialLabelYOffset:m,radialAngleXOffset:b}=t;const g=l.select(r);if(g.selectAll("."+z.pieRadialLabel).remove(),a){const t=4,a=l.arc().innerRadius(o).outerRadius(o);n.selectAll("allPolylines").data(s).enter().append("polyline").attr("class",z.pieRadialLink).style("fill","none").attr("points",n=>{const r=q(n),l=e.centroid(n),i=a.centroid(n),s=a.centroid(n),d=[(o+(c||t))*r,s[1]];return[[l[0],l[1]],[i[0]+(b||0)*r,i[1]-(m||0)*n.index],[d[0],d[1]-(m||0)*n.index]]});const r=e=>{const n=a.centroid(e);return[(o+(c||t))*q(e),n[1]]},f=4;g.selectAll("allLabels").data(s).enter().append("div").html(t=>i.renderToString(d?d(t):t.data.name)).attr("class",z.pieRadialLabel).style("transform",t=>(t=>{let{anchor:e,index:a,translateX:n,translateY:r}=t;return 0===a&&"middle"===e?"translate(calc(-50% + "+n+"px), calc(-100% + "+r+"px))":"middle"===e?"translate(calc(-50% + "+n+"px), calc("+r+"px))":"start"===e?"translate(calc("+n+"px), calc(-50% + "+r+"px))":"end"===e?"translate(calc(-100% + "+n+"px), calc(-50% + "+r+"px))":"translate("+n+"px, "+r+"px)"})({anchor:U(t),index:t.index,translateX:h,translateY:p-(m||0)*t.index})).style("left",t=>r(t)[0]-("start"===U(t)?-(u||f):u||f)+"px").style("top",t=>r(t)[1]+"px").style("text-align",U)}})({arc:Z,enableRadialLabels:C,global:F,radius:X,node:t,dataReady:_,translateX:(P-(Y-N))/2,translateY:(D+(G-E))/2,radialLabelsLinkHorizontalLength:L,radialLabelsTextXOffset:M,formatRadialLabel:A,radialLabelYOffset:T,radialAngleXOffset:w}),S){const t=i.renderToString(S);B.append("g").html(t)}}},H=t=>{const{className:n,style:r,children:l}=t,[i,o]=h();return e.useEffect(()=>{o&&_(o,t)},[o,t]),f(t.width,()=>_(o,t)),a.createElement("div",{className:n,style:r},a.createElement(W,{ref:i},l))};H.defaultProps={data:[],startAngle:0,endAngle:360,slicesLabelsSkipAngle:0,radialLabelYOffset:16,radialAngleXOffset:8};const Z={legendContainer:"d3-legend-container",legendTitle:"d3-legend-title",legendTick:"d3-legend-tick",legendTickLine:"d3-legend-tick-line",legendTickText:"d3-legend-tick-text"};function J(t,e){void 0===e&&(e=256);const a=document.createElement("canvas");a.width=e,a.height=1;const n=a.getContext("2d");for(let a=0;a<e;++a)n.fillStyle=t(a/(e-1)),n.fillRect(a,0,1,1);return a}const K={tickSize:6,height:44,width:320,marginTop:18,marginBottom:16,ticksDivier:64,titleMarginBottom:6};function Q(){const t=c(["\n ."," {\n display: flex;\n margin-bottom: 16px;\n }\n ."," {\n display: inline-flex;\n align-items: flex-end;\n height: ",";\n margin-bottom: 4px;\n font-weight: bold;\n }\n ."," {\n height: ",";\n margin-bottom: 4px;\n position: relative;\n display: flex;\n }\n ."," {\n font-size: 14px;\n bottom: 0;\n position: absolute;\n }\n ."," {\n display: flex;\n flex-direction: column;\n margin-right: 10px;\n }\n ."," {\n font-size: 12px;\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n }\n ."," {\n position: relative;\n }\n ."," {\n position: absolute;\n }\n"]);return Q=function(){return t},t}const $=o({calendarChart:"calendarChart",calendarYear:"calendarYear",calendarAxis:"calendarAxis",calendarBody:"calendarBody",calendarHeader:"calendarHeader",calendarYearTitle:"calendarYearTitle",calendarWeekDay:"calendarWeekDay",calendarMonth:"calendarMonth",calendarDays:"calendarDays",calendarDay:"calendarDay"},Z),tt=r(I)(Q(),$.calendarYear,$.calendarYearTitle,"20px",$.calendarHeader,"20px",$.calendarMonth,$.calendarAxis,$.calendarWeekDay,$.calendarDays,$.calendarDay),et=t=>{const{className:n,style:r,children:i,data:s,startSunday:c,weekdays:d,cellOffset:u,cellSize:p,interpolator:m,monthSpacing:b,colorRange:g,legendProps:f}=t,[x,y]=h();return e.useEffect(()=>{y&&((t,e)=>{const{data:a,startSunday:n,weekdays:r,interpolator:i,monthSpacing:s,onEachDay:c,colorRange:d,legendProps:u}=e;if(null!==t&&a.length){const h=l.group(a,t=>t.date.getUTCFullYear()),p="number"==typeof e.cellOffset?e.cellOffset:0,m=7,b=18,g=e.cellSize||b,f=t=>n?t:(t+(m-1))%m,x=r||["вс","пн","вт","ср","чт","пт","сб"],y=6,C=t=>n?x[t]:t===y?x[0]:x[t+1],v=l.utcFormat("%x"),L=n?l.utcSunday:l.utcMonday,M=(t,e)=>L.count(l.utcYear(t),e),A=t=>t.getUTCMonth()*(s||0),T=l.utcFormat("%b"),S=l.max(a.map(t=>{let{value:e}=t;return e})),k=l.min(a.map(t=>{let{value:e}=t;return e})),w=d?l.scaleLinear().domain([k,S]).range(d):l.scaleSequential(i||l.interpolateGreens).domain([k,+S]);let G=0;h.forEach((t,e)=>{const a=new Date(e,1),n=l.max(t.map(t=>t.date)),r=n.getUTCMonth()-a.getUTCMonth(),i=M(a,n)+1;G=Math.max(G,i*(g+p)+(s||0)*r)}),l.select(t).select("."+$.calendarChart).remove();const N=l.select(t).append("div").attr("class",$.calendarChart),E=N.selectAll("div").data(h).join("div").attr("class",$.calendarYear),Y=E.append("div").attr("class",$.calendarAxis);Y.append("div").attr("class",$.calendarYearTitle).text(t=>{let[e]=t;return e}),Y.selectAll("span").data(l.range(m)).join("div").attr("class",$.calendarWeekDay).style("height",g+"px").style("margin-bottom",p+"px").text(C);const R=E.append("div").attr("class",$.calendarBody);if(R.append("div").attr("class",$.calendarHeader).selectAll("div").data(t=>{let[e,a]=t;return l.utcMonths(l.utcMonth(new Date(a[0].date.getUTCFullYear(),1,1)),l.utcMonth(new Date(a[0].date.getUTCFullYear(),12,31)))}).join("div").attr("class",$.calendarMonth).style("left",t=>M(t,L.ceil(t))*(g+p)+A(t)+"px").text(T),R.append("div").attr("class",$.calendarDays).style("height",(g+p)*m+"px").style("width",G+"px").selectAll("div").data(t=>{let[,e]=t;return e}).join("div").each((t,e,a)=>{if(c){const n=a[e],r=w(t.value);c(t,n,r)}}).attr("class",$.calendarDay).style("width",g+"px").style("height",g+"px").style("left",t=>M(t.date,t.date)*(g+p)+A(t.date)+"px").style("top",t=>f(t.date.getUTCDay())*(g+p)+"px").style("background-color",t=>w(t.value)).attr("title",t=>v(t.date)+" - "+t.value),"object"==typeof u){const t=(t=>{let{color:e,title:a,tickSize:n=K.tickSize,width:r=K.width,height:i=K.height+n,marginTop:o=K.marginTop,marginRight:s=0,marginBottom:c=K.marginBottom+n,marginLeft:d=0,ticks:u=K.width/K.ticksDivier,tickFormat:h,tickValues:p,titleMarginBottom:m}=t;const b=l.create("svg").attr("width",r).attr("height",i).attr("viewBox",[0,0,r,i]).style("overflow","visible").style("display","block");let g;if(e.interpolate){const t=Math.min(e.domain().length,e.range().length);g=e.copy().rangeRound(l.quantize(l.interpolate(d,r-s),t)),b.append("image").attr("x",d).attr("y",o).attr("class",Z.legendContainer).attr("width",r-d-s).attr("height",i-o-c).attr("preserveAspectRatio","none").attr("xlink:href",J(e.copy().domain(l.quantize(l.interpolate(0,1),t))).toDataURL())}else if(e.interpolator&&(g=Object.assign(e.copy().interpolator(l.interpolateRound(d,r-s)),{range:()=>[d,r-s]}),b.append("image").attr("x",d).attr("y",o).attr("width",r-d-s).attr("height",i-o-c).attr("preserveAspectRatio","none").attr("xlink:href",J(e.interpolator()).toDataURL()),!g.ticks)){if(void 0===p){const t=Math.round(u+1);p=l.range(t).map(a=>l.quantile(e.domain(),a/(t-1)))}"function"!=typeof h&&(h=l.format(void 0===h?",f":h))}return b.append("g").attr("transform","translate(0,"+(i-c)+")").call(l.axisBottom(g).ticks(u,"string"==typeof h?h:void 0).tickFormat("function"==typeof h?h:void 0).tickSize(n).tickValues(p)).call(t=>{const e=t.selectAll(".tick");return e.selectAll(".tick line").attr("y1",o+c-i).attr("class",Z.legendTickLine),e.selectAll(".tick text").attr("class",Z.legendTickText),e.attr("class",Z.legendTick),e}).call(t=>t.select(".domain").remove()).call(t=>t.append("text").attr("x",d).attr("class",Z.legendTitle).attr("y",o+c-i-(m||K.titleMarginBottom)).attr("fill","currentColor").attr("text-anchor","start").attr("font-weight","bold").text(a)),b})(o({color:w},u)),e=N.node(),a=t.node();e.appendChild(a)}}})(y,t)},[y,s,c,d,u,p,m,b,g,f]),a.createElement(tt,{ref:x,className:n,style:r},i)};function at(t){let e;const a=t.node();return e=a instanceof SVGGraphicsElement?a.getBBox():a.getBoundingClientRect(),e}function nt(){}function rt(){const t=c(["\n .",",\n ."," {\n shape-rendering: crispEdges;\n }\n ."," {\n fill: none;\n stroke: steelblue;\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n ."," {\n mix-blend-mode: multiply;\n }\n ."," {\n fill-opacity: 0.24;\n }\n ."," {\n shape-rendering: crispEdges;\n }\n .",",\n .",",\n ."," {\n stroke: rgba(149, 149, 149, 0.24);\n }\n .",",\n ."," {\n transition: opacity linear 200ms;\n pointer-events: none;\n stroke-width: 1px;\n }\n ."," {\n stroke: #fff;\n stroke-width: 2px;\n }\n ."," {\n shape-rendering: crispEdges;\n }\n ."," {\n fill: none;\n pointer-events: all;\n }\n ."," {\n transition: opacity linear 200ms;\n z-index: 1;\n ."," {\n white-space: nowrap;\n justify-content: flex-start;\n align-items: center;\n pointer-events: none;\n }\n ."," {\n margin: 0 0 0 10px;\n }\n }\n"]);return rt=function(){return t},t}et.defaultProps={data:[]};const lt={lineChartYScaleGlobal:"lineChartYScaleGlobal",lineChartXScaleGlobal:"lineChartXScaleGlobal",lineChartLinesGlobal:"lineChartLinesGlobal",lineChartLine:"lineChartLine",lineChartAreasGlobal:"lineChartAreasGlobal",lineChartArea:"lineChartArea",lineChartDotsGlobalContainer:"lineChartDotsGlobalContainer",lineChartDotsGlobal:"lineChartDotsGlobal",lineChartDot:"lineChartDot",lineChartGridGlobal:"lineChartGridGlobal",lineChartGridLineX:"lineChartGridLineX",lineChartGridLineY:"lineChartGridLineY",lineChartLabelContainer:"lineChartLabelContainer",lineChartLabelFlex:"lineChartLabelFlex",lineChartLabel:"lineChartLabel",lineChartMouseGlobal:"lineChartMouseGlobal",lineChartMouseLine:"lineChartMouseLine",lineChartMouseRect:"lineChartMouseRect",lineChartMouseCircle:"lineChartMouseCircle",lineChartMouseLabelContainer:"lineChartMouseLabelContainer",lineChartMouseLabel:"lineChartMouseLabel"},it=r(I)(rt(),lt.lineChartYScaleGlobal,lt.lineChartXScaleGlobal,lt.lineChartLinesGlobal,lt.lineChartLine,lt.lineChartArea,lt.lineChartGridGlobal,lt.lineChartGridLineX,lt.lineChartGridLineY,lt.lineChartMouseLine,lt.lineChartMouseLine,lt.lineChartMouseCircle,lt.lineChartDot,lt.lineChartMouseLine,lt.lineChartMouseRect,lt.lineChartMouseLabel,lt.lineChartLabelFlex,lt.lineChartLabel);function ot(){const t=c(["\n margin-bottom: 4px;\n"]);return ot=function(){return t},t}function st(){const t=c(["\n width: 0;\n height: 0;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n font-size: 12px;\n"]);return st=function(){return t},t}const ct=r.div(st()),dt=r.div(ot()),ut=(t,e)=>{const{data:n,labels:r,margin:c,customYAxisSelection:d,customXAxisSelection:u,customYAxis:h,customXAxis:p,curve:m,dotRadius:b,yAxisPadding:g,xAxisPadding:f,drawGridY:y,drawGridX:C,eachDot:v,withLabels:L,formatLabel:M,eachLabel:A,stacked:T,dynamicTooltipEnable:S,dynamicCircleRadius:k,formatDynamicTooltip:w,renderTooltip:G,stackedTooltip:N,stackedTooltipIndex:E,tooltipLineTop:Y,customize:R,customYScale:P,customLine:I}=e;if(null!==t&&n.length){const D=T?(t=>{const e={};return t.map((t,a)=>(e[a]={},a>0?o({},t,{values:t.values.map((t,n)=>{const r=e[a-1][n];return e[a][n]=Number(("number"!=typeof r?0:Math.abs(r))+("number"!=typeof t?0:Math.abs(t))),e[a][n]})}):(t.values.forEach((t,n)=>{e[a][n]=Number(t)}),t)))})(n):n,X=c?c.top:0,B=c?c.right:0,F=c?c.bottom:0,O=c?c.left:0,{width:j}=t.getBoundingClientRect(),V=e.width||j,z=e.height||0,W="number"==typeof e.min?e.min:l.min(D,t=>{let{values:e}=t;return l.min(e)}),q="number"==typeof e.max?e.max:l.max(D,t=>{let{values:e}=t;return l.max(e)}),U=x(t,V,z||0),_=l.scaleLinear().domain([W||0,q||0]).range([z-X-F-(f||0),X]).nice();P&&P(_);const H=8,Z=l.axisLeft(_).ticks(H);h&&h(Z);const J=Z.tickArguments()[0],K=U.append("g").attr("class",lt.lineChartYScaleGlobal).call(Z).call(d||nt),{width:Q}=at(K);K.attr("transform","translate("+(O+Q)+", 0)");const $=r&&r.length?r.length-1:D.reduce((t,e)=>{let{values:a}=e;return Math.max(t,a.length)},0)-1,tt=l.scaleLinear().domain([0,$]).range([O+Q+(g||0),V-B]),et=l.axisBottom(tt).tickFormat(t=>r&&r.length>0?r[t]:0).ticks($);if(p&&p(et),(t=>{let{svg:e,yScale:a,xScale:n,yTicksCount:r,lastIndex:l,drawGridX:i,drawGridY:o}=t;if(!o&&!i)return;const s=e.append("g").attr("class",lt.lineChartGridGlobal),c=a.ticks(r);i&&s.append("g").selectAll("line").data(c).join("line").attr("class",lt.lineChartGridLineX).attr("x1",()=>n(0)).attr("x2",()=>n(l)).attr("y1",t=>Math.round(a(t))).attr("y2",t=>Math.round(a(t))),o&&s.append("g").selectAll("line").data(Array.from({length:l+1},(t,e)=>e)).join("line").attr("class",lt.lineChartGridLineY).attr("x1",(t,e)=>Math.round(n(e))).attr("x2",(t,e)=>Math.round(n(e))).attr("y1",()=>Math.round(a(c[0]))).attr("y2",()=>Math.round(a(c[c.length-1])))})({svg:U,yScale:_,xScale:tt,yTicksCount:J,lastIndex:$,drawGridY:y,drawGridX:C}),Array.isArray(r)&&r.length>0){const t=U.append("g").call(u||nt).attr("class",lt.lineChartXScaleGlobal).call(et),{height:e}=at(t);t.attr("transform","translate(0, "+(z-Math.ceil(e)-F)+")")}const rt=l.line().defined(t=>null!==t).x((t,e)=>tt(e)).y(t=>_(t)).curve(m||l.curveLinear);if(I&&I(rt),U.append("g").attr("class",lt.lineChartLinesGlobal).selectAll("path").data(D).join("path").attr("class",lt.lineChartLine).attr("d",t=>rt(t.values)).attr("stroke",t=>{let{stroke:e}=t;return e||"steelblue"}),D.some(t=>{let{fill:e}=t;return e})){let t=-2;const e=l.area().x((t,e)=>tt(e)).y0((e,a)=>(0===a&&(t+=1),_(T&&t>-1?"number"!=typeof D[t].values[a]?0:D[t].values[a]:W))).y1(t=>_(t)).curve(m||l.curveLinear);U.append("g").attr("class",lt.lineChartAreasGlobal).selectAll("path").data(D).join("path").attr("class",lt.lineChartArea).attr("d",t=>e(t.values)).attr("fill",t=>{let{fill:e}=t;return e||"none"})}if(b){const t=U.append("g").attr("class",lt.lineChartDotsGlobalContainer);D.forEach(e=>{let{values:a}=e;t.append("g").attr("class",lt.lineChartDotsGlobal).selectAll("circle").data(a).join("circle").each(v||nt).attr("class",lt.lineChartDot).attr("cx",(t,e)=>tt(e)).attr("cy",t=>_(t)).attr("r",b)})}l.select(t).select(".d3-chart-label").remove(),L&&(t=>{let{node:e,data:n,yScale:r,xScale:o,formatLabel:s,eachLabel:c}=t;const d=l.select(e).append("div").attr("class","d3-chart-label");n.forEach(t=>{let{values:e}=t;d.append("div").selectAll("div").data(e).join("div").attr("class",lt.lineChartLabelContainer).style("position","absolute").style("left",(t,e)=>o(e)+"px").style("top",t=>r(t)+"px").html((t,e,n)=>{const r=l.format(",");return i.renderToString(a.createElement(ct,{className:lt.lineChartLabelFlex},a.createElement(dt,{className:lt.lineChartLabel},s?s(t,e,n):r(t))))}).each(c||nt)})})({node:t,eachLabel:A,data:D,yScale:_,xScale:tt,formatLabel:M}),S&&(t=>{let{svg:e,node:n,data:r,xScale:c,yScale:d,dynamicCircleRadius:u,formatDynamicTooltip:h,renderTooltip:p,stackedTooltipIndex:m,stackedTooltip:b,tooltipLineTop:g}=t;l.select(n).select("."+lt.lineChartMouseLabelContainer).remove();const f="number"==typeof m?[r[m]]:b?[r[0]]:r,[x,y]=c.range(),[C,v]=d.range(),L=e.append("g").attr("class",lt.lineChartMouseGlobal),M=L.append("rect").attr("width",y-x).attr("height",Math.abs(C-v)).attr("class",lt.lineChartMouseRect).attr("transform","translate("+x+", "+v+")"),A=L.append("path").attr("class",lt.lineChartMouseLine).style("opacity","0"),T=e.selectAll("."+lt.lineChartLine).nodes(),S=L.selectAll("circle").data(r).join("circle").attr("class",lt.lineChartMouseCircle).attr("r",u).attr("fill",t=>{let{stroke:e}=t;return e||"none"}).attr("stroke",t=>{let{stroke:e}=t;return e||"none"}).style("opacity","0"),k=l.select(n).append("div").attr("class",lt.lineChartMouseLabelContainer).selectAll("div").data(f).join("div").attr("class",lt.lineChartMouseLabel).style("opacity","0").style("position","absolute").html(()=>i.renderToString(a.createElement(ct,{className:lt.lineChartLabelFlex},a.createElement(dt,{className:lt.lineChartLabel}))));let w=!1;const G=t=>{w=Boolean(t);const e=w?"1":"0";A.style("opacity",e),S.style("opacity",e),k.style("opacity",e)};M.on("mouseover",()=>G(!0)),M.on("mouseout",()=>G()),M.on("touchmove mousemove",t=>{const[e]=l.pointer(t,M),[u]=l.pointer(t,n),f=e-(e-u),x=c.invert(f),y={};T.forEach((t,e)=>{let a={x:0,y:0},n=0,r=t.getTotalLength(),l=null;for(;l=Math.floor((n+r)/2),a=t.getPointAtLength(l),l!==r&&l!==n||a.x===f;)if(a.x>f)r=l;else{if(!(a.x<f))break;n=l}y[e]=a}),S.attr("transform",(t,e)=>"translate("+f+","+y[e].y+")");const L=l.format(","),N=r.map((t,e)=>{let{values:a}=t;return o({},s(t,["values"]),{value:a[Math.floor(x)],invertValue:d.invert(y[e].y)})}),E=1===N.length&&(null==(Y=N[0].value)||Number.isNaN(Y));var Y;E&&w?G():w||E||G(!0);const R=Object.keys(y).reduce((t,e,a)=>0===a?t:y[t].y>y[e].y?e:t,"0"),P=k.style("left",f+"px").style("top",(t,e)=>{const a="number"==typeof m?m:b?R:e;return(y[a]&&y[a].y)+"px"}).select("."+lt.lineChartLabel);p?k.html((t,e)=>i.renderToString(a.createElement(ct,{className:lt.lineChartLabelFlex},p(N,{indexX:Math.round(x),indexY:e})))):P.text((t,e)=>{const a=N[e].invertValue;return h?h(a,N[e].value):L(a)}),A.attr("d",()=>{let t="M"+f+","+C;return t+=" "+f+","+(g?v:y[R].y),t})})})({tooltipLineTop:Y,stackedTooltip:N,renderTooltip:G,stackedTooltipIndex:E,formatDynamicTooltip:w,node:t,svg:U,data:D,xScale:tt,yScale:_,dynamicCircleRadius:k}),R&&R({svg:U,yScale:_,xScale:tt})}},ht=t=>{const{className:n,style:r,children:l}=t,[i,o]=h();return e.useEffect(()=>{o&&ut(o,t)},[o,t]),f(t.width,()=>ut(o,t)),a.createElement("div",{className:n,style:r},a.createElement(it,{ref:i},l))};ht.defaultProps={data:[],labels:[],height:240,yAxisPadding:10,xAxisPadding:20,margin:{top:10,right:10,bottom:10,left:0},dynamicCircleRadius:4};const pt={barChartLinesGlobal:"barChartLinesGlobal",barChartLine:"barChartLine",barChartAreasGlobal:"barChartAreasGlobal",barChartArea:"barChartArea"};function mt(){const t=c(["\n line {\n stroke-width: 1px;\n shape-rendering: crispEdges;\n }\n .",",\n ."," {\n stroke: rgba(48, 69, 79, 0.06);\n }\n ."," {\n }\n ."," {\n fill: none;\n pointer-events: all;\n }\n ."," {\n z-index: 1;\n }\n ."," {\n stroke-width: 1.5px;\n stroke-linejoin: round;\n stroke-linecap: round;\n }\n ."," {\n shape-rendering: auto;\n }\n ."," {\n fill-opacity: 0.24;\n }\n ."," {\n margin-bottom: 4px;\n :last-of-type {\n margin-bottom: 0;\n }\n }\n"]);return mt=function(){return t},t}const bt=o({barChartBarGlobal:"barChartBarGlobal",barChartYScaleGlobal:"barChartYScaleGlobal",barChartYAxis:"barChartYAxis",barChartXAxis:"barChartXAxis",barChartGridGlobal:"barChartGridGlobal",barChartGridLineX:"barChartGridLineX",barChartGridLineXZero:"barChartGridLineXZero",barChartGridLineYZero:"barChartGridLineYZero",barChartGridLineY:"barChartGridLineY"},{barChartMouseRect:"barChartMouseRect",barChartMouseContainer:"barChartMouseContainer",barChartTooltipFlex:"barChartTooltipFlex",barChartMouseTooltip:"barChartMouseTooltip",barChartTooltip:"barChartTooltip",barChartTooltipItem:"barChartTooltipItem",barChartTooltipColFlex:"barChartTooltipColFlex",barChartTooltipGroupName:"barChartTooltipGroupName",barChartColorBox:"barChartColorBox",barChartColorLine:"barChartColorLine",barChartTooltipName:"barChartTooltipName",barChartTooltipValue:"barChartTooltipValue"},{barChartLabelContainer:"barChartLabelContainer",barChartLabelFlex:"barChartLabelFlex",barChartLabel:"barChartLabel"},pt),gt=r(I)(mt(),bt.barChartGridLineX,bt.barChartGridLineY,bt.barChartMouseRect,bt.barChartMouseRect,bt.barChartMouseTooltip,bt.barChartLinesGlobal,bt.barChartLine,bt.barChartArea,bt.barChartTooltipItem);function ft(){const t=c(["\n bottom: 6px;\n"]);return ft=function(){return t},t}function xt(){const t=c(["\n top: 6px;\n"]);return xt=function(){return t},t}function yt(){const t=c(["\n position: relative;\n font-size: 11px;\n color: #fff;\n font-weight: bold;\n letter-spacing: 0.52px;\n"]);return yt=function(){return t},t}function Ct(){const t=c(["\n text-align: right;\n flex-shrink: 0;\n flex-grow: 1;\n"]);return Ct=function(){return t},t}function vt(){const t=c(["\n margin-right: 4px;\n"]);return vt=function(){return t},t}function Lt(){const t=c(["\n height: 2px;\n border-radius: 0;\n"]);return Lt=function(){return t},t}function Mt(){const t=c(["\n margin-right: 4px;\n width: 10px;\n height: 10px;\n border-radius: 2px;\n"]);return Mt=function(){return t},t}function At(){const t=c(["\n display: flex;\n align-items: center;\n margin-right: 4px;\n"]);return At=function(){return t},t}function Tt(){const t=c(["\n display: flex;\n align-items: center;\n"]);return Tt=function(){return t},t}function St(){const t=c(["\n font-size: 14px;\n margin-bottom: 6px;\n"]);return St=function(){return t},t}function kt(){const t=c(["\n position: relative;\n font-size: 11px;\n color: #fff;\n margin-bottom: 8px;\n padding: 4px 6px;\n background-color: rgba(48, 69, 79, 1);\n border-radius: 4px;\n :before {\n content: '';\n position: absolute;\n bottom: 0;\n left: 50%;\n transform: translate(-50%, 100%);\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 4px 3px 0 3px;\n border-color: rgba(48, 69, 79, 1) transparent transparent transparent;\n }\n"]);return kt=function(){return t},t}function wt(){const t=c(["\n align-items: center;\n"]);return wt=function(){return t},t}function Gt(){const t=c([""]);return Gt=function(){return t},t}function Nt(){const t=c(["\n width: 0;\n height: 0;\n display: flex;\n align-items: flex-end;\n justify-content: center;\n pointer-events: none;\n white-space: nowrap;\n"]);return Nt=function(){return t},t}const Et=r.div(Nt()),Yt=r(Et)(Gt()),Rt=r(Yt)(wt()),Pt=r.div(kt()),It=r.div(St()),Dt=r.div(Tt()),Xt=r.div(At()),Bt=r.div(Mt()),Ft=r(Bt)(Lt()),Ot=r.div(vt()),jt=r.div(Ct()),Vt=r.div(yt()),zt=r(Vt)(xt()),Wt=r(Vt)(ft()),qt=(t,e)=>{const{data:n,lineData:r=[],barWidth:c,barPadding:d,colors:u,margin:h,xAxisPadding:p,yAxisPadding:m,drawGridY:b,drawGridX:g,customYScale:f,customXScale:y,customYAxisLeft:C,customXAxisBottom:v,customYAxis:L,customXAxis:M,customBars:A,customize:T,dynamicTooltipEnable:S,renderTooltip:k,labelPosition:w,renderLabel:G,tooltipY:N,tooltipBind:E,stackedLine:Y,curve:R,formatTooltipValue:P,formatTooltipName:I,sectionPadding:D,minValuesLine:X,tooltipYDomain:B,marshalledMap:F,minValue:O,maxValue:j,minDomainValue:V,maxDomainValue:z,drawBars:W}=e;if(null!==t&&n.length){const q=h?h.top:0,U=h?h.right:0,_=h?h.bottom:0,H=h?h.left:0,Z=12,{width:J}=t.getBoundingClientRect(),K=e.width||J,Q=e.height||0,$=(t=>{let{data:e,minDomainValue:a,maxDomainValue:n}=t,r=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY;return e.forEach(t=>{let e=s(t,["groupName"]),a=0,n=0;Object.keys(e).forEach(t=>{const r=e[t];let l=0,i=0;Object.keys(r).forEach(t=>{const e=r[t];e>0?l+=e:i+=e}),a=Math.min(a,i),n=Math.max(n,l)}),r=Math.min(r,a),l=Math.max(l,n)}),0===r&&0===l?{min:"number"==typeof a?a:0,max:"number"==typeof n?n:1}:{min:"number"==typeof a?a:r,max:"number"==typeof n?n:l}})({data:n,minDomainValue:V,maxDomainValue:z}),tt="number"==typeof O?O:Math.min(l.min(r,t=>{let{values:e}=t;return l.min(e)})||Number.POSITIVE_INFINITY,$.min||0),et="number"==typeof j?j:Math.max(l.max(r,t=>{let{values:e}=t;return l.max(e)})||Number.NEGATIVE_INFINITY,$.max),nt=x(t,K,Q||0),rt=6,lt=n.map(t=>t.groupName);let it=c||Z;const ot=l.scaleLinear().domain([tt,et]).range([Q-q-_-(p||0),q]).nice();f&&f(ot);const st=ot.ticks(),ct=l.axisLeft(ot).ticks(rt);C&&C(ct);const dt=ct.tickArguments()[0],ut=nt.append("g").attr("class",bt.barChartYAxis).call(ct);L&&L(ut);const{width:ht}=at(ut),mt=[H+ht+(m||0),K-U],gt=l.scaleBand().domain(l.range(n.length)).range(mt);it=(t=>{let{data:e,range:a,barWidth:n,barPadding:r,sectionPadding:l}=t;const i="number"==typeof l?l:0,o=a[1]-a[0],c=e.reduce((t,e)=>{let a=s(e,["groupName"]);return t+Object.keys(a).reduce((t,e,a)=>a>0?t+(n||0)+(r||0):t+n,0)+i},i);return o<c?Math.floor(n*(o/c)):n})({data:n,sectionPadding:D,range:mt,barWidth:it,barPadding:d}),y&&y(gt);const ft=l.axisBottom(gt).tickFormat((t,e)=>lt[e]);v&&v(ft);const xt=nt.append("g").call(ft).attr("class",bt.barChartXAxis);M&&M(xt),ut.attr("transform","translate("+(H+ht)+", 0)");const yt=(t=>{let{data:e,yScale:a,xScale:n,barWidth:r,barPadding:l,colors:i,marginTop:o}=t;return e.map((t,e)=>{let{groupName:c}=t,d=s(t,["groupName"]);const u=[],h=n.bandwidth(),p=Object.keys(d);return p.forEach((t,n)=>{const s=d[t],m=Object.keys(s),b=(r+l)*p.length-(m.length>1?l:0);let g=0,f=0;m.forEach(t=>{const d=s[t],p=i[t],m=(r+l)*n+h/2-b/2,x=d>0,y=x?Math.abs(Math.round(100*(a(g-d)-a(g)+Number.EPSILON))/100):Math.abs(Math.round(100*(a(f-d)-a(f)+Number.EPSILON))/100);x&&(g+=d);const C=x?Math.round(100*(a(g)+Number.EPSILON))/100:a(f)-a(0)+a(0);u.push({x:Math.round(m),y:Math.round(C+(o||0)),height:Math.round(y),color:p,value:d,groupName:c,name:t,stackIndex:n,groupIndex:e}),x||(f+=d)})}),u})})({data:n,yScale:ot,xScale:gt,barWidth:it,barPadding:"number"==typeof d?d:0,colors:u,marginTop:q}),Ct=F?F(yt):yt;ut.attr("transform","translate( "+((H||0)+ht)+", 0)"),(t=>{let{svg:e,yScale:a,xScale:n,yTicksCount:r,drawGridX:l,drawGridY:i}=t;if(!i&&!l)return;const o=e.append("g").attr("class",bt.barChartGridGlobal),s=a.ticks(r),c=n.range(),d=n.domain();if(l&&o.append("g").selectAll("line").data(s).join("line").attr("class",t=>0===t?bt.barChartGridLineX+" "+bt.barChartGridLineXZero:bt.barChartGridLineX).attr("x1",()=>c[0]).attr("x2",()=>c[1]).attr("y1",t=>Math.round(a(t))).attr("y2",t=>Math.round(a(t))),i){const t=t=>void 0!==d[t]?0===t?c[0]:Math.round(n.step()*t+c[0]-n.step()/2*n.padding()):c[1];o.append("g").selectAll("line").data(Array.from({length:d.length+1},(t,e)=>e)).join("line").attr("class",t=>0===t?bt.barChartGridLineY+" "+bt.barChartGridLineYZero:bt.barChartGridLineY).attr("x1",t).attr("x2",t).attr("y1",()=>Math.round(a(s[0]))).attr("y2",()=>Math.round(a(s[s.length-1])))}})({svg:nt,yScale:ot,xScale:gt,yTicksCount:dt,drawGridY:b,drawGridX:g}),xt.attr("transform","translate(0, "+(ot(st[0])+(p||0))+")");const vt=nt.append("g").attr("class",bt.barChartBarGlobal).selectAll("g").data(Ct).enter().append("g").attr("transform",(t,e)=>"translate("+Math.round(gt(e.toString()))+","+-(q||0)+")"),Lt=W?W({groups:vt,yScale:ot,marshalledData:Ct}):(t=>{let{groups:e,barWidth:a}=t;return e.selectAll("rect").data(t=>t).join("rect").attr("x",t=>t.x).attr("y",t=>t.y).attr("width",a).attr("height",t=>t.height).style("fill",t=>t.color)})({groups:vt,barWidth:it});let Mt=null;Array.isArray(r)&&r.length>0&&(Mt=(t=>{let{svg:e,lineData:a,min:n,yScale:r,xScale:i,curve:o,stackedLine:s}=t,c=null,d=null,u=null;const h=l.line().defined(t=>null!==t).x((t,e)=>i(e.toString())+p/2).y(t=>r(t)).curve(o||l.curveLinear),p=i.bandwidth(),m=a.filter(t=>{let{lineType:e}=t;return"line"===e}),b=a.filter(t=>{let{lineType:e}=t;return"area"===e});if(m.length>0&&(c=e.append("g").attr("class",pt.barChartLinesGlobal).selectAll("path").data(m).join("path").attr("class",pt.barChartLine).attr("d",t=>h(t.values)).attr("stroke",t=>{let{stroke:e}=t;return e||""}).attr("fill",t=>{let{fill:e}=t;return e||"none"})),b.length>0){let t=-2;u=l.area().x((t,e)=>i(e.toString())+p/2).y0((e,l)=>(0===l&&(t+=1),r(s&&t>-1?"number"!=typeof a[t].values[l]?0:a[t].values[l]:n))).y1(t=>r(t)).curve(o||l.curveLinear),d=e.append("g").attr("class",pt.barChartAreasGlobal).selectAll("path").data(b).join("path").attr("class",pt.barChartArea).attr("d",t=>u&&u(t.values)).attr("fill",t=>{let{fill:e}=t;return e||"none"})}return{areasSelection:d,linesSelection:c,area:u}})({svg:nt,lineData:r,xScale:gt,yScale:ot,min:"number"==typeof X?X:tt,stackedLine:Y,curve:R})),A&&A({bars:Lt,yScale:ot,lines:Mt,marshalledData:Ct,lineData:r}),(S||w)&&(t=>{let{svg:e,node:n,data:r,marshalledData:c,xScale:d,yScale:u,renderTooltip:h,labelPosition:p,marginTop:m,renderLabel:b,barWidth:g,dynamicTooltipEnable:f,tooltipY:x,tooltipBind:y,lineData:C,formatTooltipValue:v,formatTooltipName:L,tooltipYDomain:M}=t;l.select(n).select("."+bt.barChartMouseContainer).remove();const A=d.domain(),[T,S]=d.range(),[k,w]=u.range(),G=d.bandwidth(),N=l.format(","),E=A.map(t=>{return e=Number(t)+1,void 0!==A[e]?0===e?T:Math.round(d.step()*e+T-d.step()/2*d.padding()):S;var e}),Y=M?M({data:c,lineData:C,yScale:u}):c.reduce((t,e,a)=>{const n=l.min(C,t=>{let{values:e}=t;return"number"==typeof e[a]?u((e[a]||0)-w):Number.POSITIVE_INFINITY})||Number.POSITIVE_INFINITY;return t.push(e.reduce((t,e)=>{let{y:a}=e;return Math.min(t,a,n)},Number.POSITIVE_INFINITY)),t},[]),R=e.append("g").attr("class","lineChartMouseGlobal").append("rect").attr("width",S-T).attr("height",Math.abs(k-w)).attr("class",bt.barChartMouseRect).attr("transform","translate("+T+", "+w+")"),P=l.select(n).append("div").attr("class",bt.barChartMouseContainer);if(f){const t=P.append("div").attr("class",bt.barChartMouseTooltip).style("opacity","0").style("position","absolute").html(()=>i.renderToString(a.createElement(Et,{className:bt.barChartTooltipFlex},a.createElement(Pt,{className:bt.barChartTooltip})))),e=t.select("."+bt.barChartTooltipFlex),u=t.select("."+bt.barChartTooltip);let p=!1,m=null;const b=e=>{p=Boolean(e),t.style("opacity",p?"1":"0"),p?t.style("transition",null):(m=null,t.style("transition","none"),t.style("top",null),t.style("left",null))};R.on("mouseout",()=>b()),R.on("touchmove mousemove",g=>{const[f]=l.pointer(g,R),[M]=l.pointer(g,n),A=f-(f-M),T=E.findIndex(t=>A<=t);if(y&&m===T)return;let S=c[T];if(!Array.isArray(S)||0!==S.length){if(C){const t=C.map(t=>{let{values:e}=t;return o({},s(t,["values"]),{value:e[T],groupName:r[T]&&r[T].groupName})});Array.isArray(t)&&Array.isArray(S)&&(S=t.concat(S))}t.style("left",(y?(d(T.toString())||0)+G/2:A)+"px").style("top",()=>("number"==typeof x?x:Y[T]-w)+"px"),h?e.html(()=>i.renderToString(a.createElement(a.Fragment,null,h(S)))):(p||b(!0),u.html(()=>i.renderToString(a.createElement(a.Fragment,null,S&&S[0]&&a.createElement(It,{className:bt.barChartTooltipGroupName},S[0].groupName),S&&S.map(t=>{let{name:e,value:n,stroke:r,fill:l,color:i,lineType:o}=t;return a.createElement(Dt,{key:e,className:bt.barChartTooltipItem},a.createElement(Xt,{className:bt.barChartTooltipColFlex},o?a.createElement(Ft,{className:bt.barChartColorLine,style:{backgroundColor:r||l}}):a.createElement(Bt,{className:bt.barChartColorBox,style:{backgroundColor:i}}),a.createElement(Ot,{className:bt.barChartTooltipName},L?L(e):e)),a.createElement(jt,{className:bt.barChartTooltipValue},v?v(n):N(n)))}))))),m=T,p||b(!0)}})}const I=P.append("div").attr("class",bt.barChartLabelContainer).style("position","absolute").style("top",w+"px");if(p){const t=I.selectAll("div").data(c).enter().append("div").style("position","absolute").style("transform",(t,e)=>"translate("+d(e.toString())+"px,"+-(m||0)+"px)"),e="center"===p?Rt:Yt,n=(t=>{switch(t){case"top":return zt;case"bottom":return Wt;default:return Vt}})(p);t.selectAll("span").data(t=>t).join("div").style("left",t=>t.x+g/2+"px").style("top",t=>((t,e,a)=>{switch(t){case"center":return a.y+a.height/2-e;case"bottom":return a.y+a.height-e;default:return a.y}})(p,w,t)+"px").style("position","absolute").html(t=>i.renderToString(a.createElement(e,{className:bt.barChartLabelFlex},b?b(t):a.createElement(n,{className:bt.barChartLabel},t.value))))}})({svg:nt,node:t,xScale:gt,yScale:ot,marshalledData:Ct,data:n,lineData:r,renderTooltip:k,labelPosition:w,marginTop:q,renderLabel:G,barWidth:it,dynamicTooltipEnable:S,tooltipY:N,tooltipBind:E,formatTooltipValue:P,formatTooltipName:I,tooltipYDomain:B}),T&&T({svg:nt,marshalledData:Ct,yScale:ot,xScale:gt})}},Ut=t=>{const{className:n,style:r,children:l}=t,[i,o]=h();return e.useEffect(()=>{o&&qt(o,t)},[o,t]),f(t.width,()=>qt(o,t)),a.createElement("div",{className:n,style:r},a.createElement(gt,{ref:i},l))};Ut.defaultProps={data:[],colors:{},margin:{top:10,right:10,bottom:10,left:0},barWidth:12,barPadding:0,height:320,yAxisPadding:0,xAxisPadding:0,tooltipBind:!0,sectionPadding:1},exports.BarChart=Ut,exports.CalendarChart=et,exports.LineChart=ht,exports.PieChart=H,exports.RadarChart=O,exports.SwipeScroll=g,exports.barChartClassNames=bt,exports.calendarChartClassNames=$,exports.lineChartClassNames=lt,exports.pieChartclassNames=z,exports.radarChartclassNames=X; | ||
//# sourceMappingURL=charts.cjs.production.min.js.map |
@@ -46,2 +46,4 @@ import * as d3 from 'd3'; | ||
}) => void; | ||
customYScale?: (yScale: (value: number) => number) => void; | ||
customLine?: (line: d3.Line<[number, number]>) => void; | ||
}; | ||
@@ -48,0 +50,0 @@ export declare type LineChartData = { |
import { ReactNode } from 'react'; | ||
import { RadarChartProps } from '../types'; | ||
declare type RenderLabel = (anchor: string, index: number) => ReactNode; | ||
@@ -8,2 +7,3 @@ export declare type DrawRadialLabels = { | ||
radiusScale: any; | ||
maxValue: number; | ||
angleSlice: number; | ||
@@ -16,3 +16,9 @@ radius: number; | ||
translateY?: number; | ||
} & Pick<RadarChartProps, 'maxValue'>; | ||
}; | ||
export declare type LabelContainerProps = { | ||
anchor: string; | ||
translateX: number; | ||
translateY: number; | ||
index: number; | ||
}; | ||
export {}; |
@@ -0,1 +1,3 @@ | ||
export { SwipeScroll } from './common/components/SwipeScroll'; | ||
export { SwipeScrollProps } from './common/components/SwipeScroll/types'; | ||
export { RadarChart } from './charts/RadarChart'; | ||
@@ -2,0 +4,0 @@ export { radarChartclassNames } from './charts/RadarChart/styled'; |
{ | ||
"version": "1.0.11", | ||
"version": "1.0.14", | ||
"license": "MIT", | ||
@@ -46,3 +46,3 @@ "main": "dist/index.js", | ||
"@storybook/react": "^6.0.26", | ||
"@types/d3": "^6.2.0", | ||
"@types/d3": "^6.3.0", | ||
"@types/react": "^16.9.52", | ||
@@ -62,6 +62,6 @@ "@types/react-dom": "^16.9.8", | ||
"dependencies": { | ||
"d3": "^6.2.0", | ||
"d3": "^6.6.0", | ||
"styled-components": "^5.2.0" | ||
}, | ||
"gitHead": "f27edaeb9cef9a4714ef3fb01ca0469d63d0a2bc" | ||
"gitHead": "9e69dabaa9f15aa2c9fca682cfd7f84d04655f81" | ||
} |
Sorry, the diff of this file is too big to display
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 too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
802400
83
5436
1
Updatedd3@^6.6.0