@evergis/charts
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -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()),k=i(T)(g(),A),S=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?k: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(S,{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:k,formatSliceTitle:S,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 S?S(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}),k){const t=r.renderToString(k);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"),k=n.max(a.map(t=>{let{value:e}=t;return e})),S=n.min(a.map(t=>{let{value:e}=t;return e})),G=d?n.scaleLinear().domain([S,k]).range(d):n.scaleSequential(i||n.interpolateGreens).domain([S,+k]);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:k,dynamicCircleRadius:S,formatDynamicTooltip:G,renderTooltip:N,stackedTooltip:w,stackedTooltipIndex:E,tooltipLineTop:Y}=e;if(null!==t&&l.length){const P=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,I=o?o.top:0,R=o?o.right:0,D=o?o.bottom:0,X=o?o.left:0,{width:B}=t.getBoundingClientRect(),O=e.width||B,j=e.height||0,F="number"==typeof e.min?e.min:n.min(P,t=>{let{values:e}=t;return n.min(e)}),V="number"==typeof e.max?e.max:n.max(P,t=>{let{values:e}=t;return n.max(e)}),z=p(t,O,j||0),W=n.scaleLinear().domain([F||0,V||0]).range([j-I-D-(x||0),I]).nice(),U=8,_=n.axisLeft(W).ticks(U),q=_.tickArguments()[0];h&&h(_);const H=z.append("g").attr("class",$.lineChartYScaleGlobal).call(_).call("function"==typeof s?s:K),{width:Z}=J(H);H.attr("transform","translate("+(X+Z)+", 0)");const Q=i&&i.length?i.length-1:P.reduce((t,e)=>{let{values:a}=e;return Math.max(t,a.length)},0)-1,tt=n.scaleLinear().domain([0,Q]).range([X+Z+(g||0),O-R]),et=n.axisBottom(tt).tickFormat(t=>i&&i.length?i[t]:"").ticks(Q);if(m&&m(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",$.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:z,yScale:W,xScale:tt,yTicksCount:q,lastIndex:Q,drawGridY:y,drawGridX:C}),Array.isArray(i)&&i.length>0){const t=z.append("g").call("function"==typeof u?u:K).attr("class",$.lineChartXScaleGlobal).call(et),{height:e}=J(t);t.attr("transform","translate(0, "+(j-Math.ceil(e)-D)+")")}const at=n.line().defined(t=>null!==t).x((t,e)=>tt(e)).y(t=>W(t)).curve(f||n.curveLinear);if(z.append("g").attr("class",$.lineChartLinesGlobal).selectAll("path").data(P).join("path").attr("class",$.lineChartLine).attr("d",t=>at(t.values)).attr("stroke",t=>{let{stroke:e}=t;return e||"steelblue"}),P.some(t=>{let{fill:e}=t;return e})){let t=-2;const e=n.area().x((t,e)=>tt(e)).y0((e,a)=>(0===a&&(t+=1),W(T&&t>-1?"number"!=typeof P[t].values[a]?0:P[t].values[a]:F))).y1(t=>W(t)).curve(f||n.curveLinear);z.append("g").attr("class",$.lineChartAreasGlobal).selectAll("path").data(P).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=z.append("g").attr("class",$.lineChartDotsGlobalContainer);P.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)=>tt(e)).attr("cy",t=>W(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:P,yScale:W,xScale:tt,formatLabel:M}),k&&(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(),k=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"),S=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),k.style("opacity",e),S.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}),k.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=S.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?S.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:z,data:P,xScale:tt,yScale:W,dynamicCircleRadius:S})}},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()),kt=i(Tt)(Mt()),St=i(kt)(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:k,renderTooltip:S,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}),(k||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,k]=s.range(),[S,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()):k;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",k-T).attr("height",Math.abs(S-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 k=o[T];if(!Array.isArray(k)||0!==k.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(k)&&(k=t.concat(k))}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(k)))):(h||f(!0),u.html(()=>r.renderToString(a.createElement(a.Fragment,null,k&&k[0]&&a.createElement(Nt,{className:ct.barChartTooltipGroupName},k[0].groupName),k&&k.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?St:kt,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:S,labelPosition:G,marginTop:U,renderLabel:N,barWidth:it,dynamicTooltipEnable:k,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("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; | ||
//# sourceMappingURL=charts.cjs.production.min.js.map |
@@ -41,2 +41,7 @@ import * as d3 from 'd3'; | ||
tooltipLineTop?: boolean; | ||
customize?: (args: { | ||
svg: d3.Selection<SVGSVGElement, unknown, null, undefined>; | ||
yScale: d3.ScaleLinear<number, number>; | ||
xScale: d3.ScaleLinear<number, number>; | ||
}) => void; | ||
}; | ||
@@ -43,0 +48,0 @@ export declare type LineChartData = { |
export { RadarChart } from './charts/RadarChart'; | ||
export { radarChartclassNames } from './charts/RadarChart/styled'; | ||
export { RadarChartProps } from './charts/RadarChart/types'; | ||
export { PieChart } from './charts/PieChart'; | ||
export { pieChartclassNames } from './charts/PieChart/styled'; | ||
export { PieChartProps } from './charts/PieChart/types'; | ||
export { CalendarChart } from './charts/CalendarChart'; | ||
export { calendarChartClassNames } from './charts/CalendarChart/styled'; | ||
export { CalendarChartProps } from './charts/CalendarChart/types'; | ||
export { LineChart } from './charts/LineChart'; | ||
export { lineChartClassNames } from './charts/LineChart/styled'; | ||
export { LineChartProps } from './charts/LineChart/types'; | ||
export { BarChart } from './charts/BarChart'; | ||
export { barChartClassNames } from './charts/BarChart/styled'; | ||
export { BarChartProps } from './charts/BarChart/types'; |
{ | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"license": "MIT", | ||
@@ -64,3 +64,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "98ee06fc2b000b65cc93b58b2c5b6520e51a2358" | ||
"gitHead": "e77e6b3e0676c30c37b0ccecfb2ba8cfa5b5e3a5" | ||
} |
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
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
762237
5143