mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Enhance cash flow dashboard with new cash flow period handling and improved Sankey diagram rendering. Update D3 and related dependencies for better performance and features. * Fix Rubocop offenses * Refactor Sankey chart controller to use Number.parseFloat for value formatting and improve code readability by restructuring conditional logic for node shapes.
4 lines
8.4 KiB
JavaScript
4 lines
8.4 KiB
JavaScript
// d3-interpolate@3.0.1 downloaded from https://ga.jspm.io/npm:d3-interpolate@3.0.1/src/index.js
|
|
|
|
import{rgb as n,color as r,hsl as t,lab as e,hcl as a,cubehelix as o}from"d3-color";function basis(n,r,t,e,a){var o=n*n,u=o*n;return((1-3*n+3*o-u)*r+(4-6*o+3*u)*t+(1+3*n+3*o-3*u)*e+u*a)/6}function basis$1(n){var r=n.length-1;return function(t){var e=t<=0?t=0:t>=1?(t=1,r-1):Math.floor(t*r),a=n[e],o=n[e+1],u=e>0?n[e-1]:2*a-o,i=e<r-1?n[e+2]:2*o-a;return basis((t-e/r)*r,u,a,o,i)}}function basisClosed(n){var r=n.length;return function(t){var e=Math.floor(((t%=1)<0?++t:t)*r),a=n[(e+r-1)%r],o=n[e%r],u=n[(e+1)%r],i=n[(e+2)%r];return basis((t-e/r)*r,a,o,u,i)}}var constant=n=>()=>n;function linear(n,r){return function(t){return n+t*r}}function exponential(n,r,t){return n=Math.pow(n,t),r=Math.pow(r,t)-n,t=1/t,function(e){return Math.pow(n+e*r,t)}}function hue$1(n,r){var t=r-n;return t?linear(n,t>180||t<-180?t-360*Math.round(t/360):t):constant(isNaN(n)?r:n)}function gamma(n){return 1===(n=+n)?nogamma:function(r,t){return t-r?exponential(r,t,n):constant(isNaN(r)?t:r)}}function nogamma(n,r){var t=r-n;return t?linear(n,t):constant(isNaN(n)?r:n)}var u=function rgbGamma(r){var t=gamma(r);function rgb(r,e){var a=t((r=n(r)).r,(e=n(e)).r),o=t(r.g,e.g),u=t(r.b,e.b),i=nogamma(r.opacity,e.opacity);return function(n){r.r=a(n);r.g=o(n);r.b=u(n);r.opacity=i(n);return r+""}}rgb.gamma=rgbGamma;return rgb}(1);function rgbSpline(r){return function(t){var e,a,o=t.length,u=new Array(o),i=new Array(o),s=new Array(o);for(e=0;e<o;++e){a=n(t[e]);u[e]=a.r||0;i[e]=a.g||0;s[e]=a.b||0}u=r(u);i=r(i);s=r(s);a.opacity=1;return function(n){a.r=u(n);a.g=i(n);a.b=s(n);return a+""}}}var i=rgbSpline(basis$1);var s=rgbSpline(basisClosed);function numberArray(n,r){r||(r=[]);var t,e=n?Math.min(r.length,n.length):0,a=r.slice();return function(o){for(t=0;t<e;++t)a[t]=n[t]*(1-o)+r[t]*o;return a}}function isNumberArray(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function array(n,r){return(isNumberArray(r)?numberArray:genericArray)(n,r)}function genericArray(n,r){var t,e=r?r.length:0,a=n?Math.min(e,n.length):0,o=new Array(a),u=new Array(e);for(t=0;t<a;++t)o[t]=value(n[t],r[t]);for(;t<e;++t)u[t]=r[t];return function(n){for(t=0;t<a;++t)u[t]=o[t](n);return u}}function date(n,r){var t=new Date;return n=+n,r=+r,function(e){return t.setTime(n*(1-e)+r*e),t}}function number(n,r){return n=+n,r=+r,function(t){return n*(1-t)+r*t}}function object(n,r){var t,e={},a={};null!==n&&"object"===typeof n||(n={});null!==r&&"object"===typeof r||(r={});for(t in r)t in n?e[t]=value(n[t],r[t]):a[t]=r[t];return function(n){for(t in e)a[t]=e[t](n);return a}}var l=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,c=new RegExp(l.source,"g");function zero(n){return function(){return n}}function one(n){return function(r){return n(r)+""}}function string(n,r){var t,e,a,o=l.lastIndex=c.lastIndex=0,u=-1,i=[],s=[];n+="",r+="";while((t=l.exec(n))&&(e=c.exec(r))){if((a=e.index)>o){a=r.slice(o,a);i[u]?i[u]+=a:i[++u]=a}if((t=t[0])===(e=e[0]))i[u]?i[u]+=e:i[++u]=e;else{i[++u]=null;s.push({i:u,x:number(t,e)})}o=c.lastIndex}if(o<r.length){a=r.slice(o);i[u]?i[u]+=a:i[++u]=a}return i.length<2?s[0]?one(s[0].x):zero(r):(r=s.length,function(n){for(var t,e=0;e<r;++e)i[(t=s[e]).i]=t.x(n);return i.join("")})}function value(n,t){var e,a=typeof t;return null==t||"boolean"===a?constant(t):("number"===a?number:"string"===a?(e=r(t))?(t=e,u):string:t instanceof r?u:t instanceof Date?date:isNumberArray(t)?numberArray:Array.isArray(t)?genericArray:"function"!==typeof t.valueOf&&"function"!==typeof t.toString||isNaN(t)?object:number)(n,t)}function discrete(n){var r=n.length;return function(t){return n[Math.max(0,Math.min(r-1,Math.floor(t*r)))]}}function hue(n,r){var t=hue$1(+n,+r);return function(n){var r=t(n);return r-360*Math.floor(r/360)}}function round(n,r){return n=+n,r=+r,function(t){return Math.round(n*(1-t)+r*t)}}var f=180/Math.PI;var h={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function decompose(n,r,t,e,a,o){var u,i,s;(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u);(s=n*t+r*e)&&(t-=n*s,e-=r*s);(i=Math.sqrt(t*t+e*e))&&(t/=i,e/=i,s/=i);n*e<r*t&&(n=-n,r=-r,s=-s,u=-u);return{translateX:a,translateY:o,rotate:Math.atan2(r,n)*f,skewX:Math.atan(s)*f,scaleX:u,scaleY:i}}var p;function parseCss(n){const r=new("function"===typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(n+"");return r.isIdentity?h:decompose(r.a,r.b,r.c,r.d,r.e,r.f)}function parseSvg(n){if(null==n)return h;p||(p=document.createElementNS("http://www.w3.org/2000/svg","g"));p.setAttribute("transform",n);if(!(n=p.transform.baseVal.consolidate()))return h;n=n.matrix;return decompose(n.a,n.b,n.c,n.d,n.e,n.f)}function interpolateTransform(n,r,t,e){function pop(n){return n.length?n.pop()+" ":""}function translate(n,e,a,o,u,i){if(n!==a||e!==o){var s=u.push("translate(",null,r,null,t);i.push({i:s-4,x:number(n,a)},{i:s-2,x:number(e,o)})}else(a||o)&&u.push("translate("+a+r+o+t)}function rotate(n,r,t,a){if(n!==r){n-r>180?r+=360:r-n>180&&(n+=360);a.push({i:t.push(pop(t)+"rotate(",null,e)-2,x:number(n,r)})}else r&&t.push(pop(t)+"rotate("+r+e)}function skewX(n,r,t,a){n!==r?a.push({i:t.push(pop(t)+"skewX(",null,e)-2,x:number(n,r)}):r&&t.push(pop(t)+"skewX("+r+e)}function scale(n,r,t,e,a,o){if(n!==t||r!==e){var u=a.push(pop(a)+"scale(",null,",",null,")");o.push({i:u-4,x:number(n,t)},{i:u-2,x:number(r,e)})}else 1===t&&1===e||a.push(pop(a)+"scale("+t+","+e+")")}return function(r,t){var e=[],a=[];r=n(r),t=n(t);translate(r.translateX,r.translateY,t.translateX,t.translateY,e,a);rotate(r.rotate,t.rotate,e,a);skewX(r.skewX,t.skewX,e,a);scale(r.scaleX,r.scaleY,t.scaleX,t.scaleY,e,a);r=t=null;return function(n){var r,t=-1,o=a.length;while(++t<o)e[(r=a[t]).i]=r.x(n);return e.join("")}}}var m=interpolateTransform(parseCss,"px, ","px)","deg)");var g=interpolateTransform(parseSvg,", ",")",")");var b=1e-12;function cosh(n){return((n=Math.exp(n))+1/n)/2}function sinh(n){return((n=Math.exp(n))-1/n)/2}function tanh(n){return((n=Math.exp(2*n))-1)/(n+1)}var v=function zoomRho(n,r,t){function zoom(e,a){var o,u,i=e[0],s=e[1],l=e[2],c=a[0],f=a[1],h=a[2],p=c-i,m=f-s,g=p*p+m*m;if(g<b){u=Math.log(h/l)/n;o=function(r){return[i+r*p,s+r*m,l*Math.exp(n*r*u)]}}else{var v=Math.sqrt(g),y=(h*h-l*l+t*g)/(2*l*r*v),x=(h*h-l*l-t*g)/(2*h*r*v),M=Math.log(Math.sqrt(y*y+1)-y),d=Math.log(Math.sqrt(x*x+1)-x);u=(d-M)/n;o=function(t){var e=t*u,a=cosh(M),o=l/(r*v)*(a*tanh(n*e+M)-sinh(M));return[i+o*p,s+o*m,l*a/cosh(n*e+M)]}}o.duration=1e3*u*n/Math.SQRT2;return o}zoom.rho=function(n){var r=Math.max(.001,+n),t=r*r,e=t*t;return zoomRho(r,t,e)};return zoom}(Math.SQRT2,2,4);function hsl(n){return function(r,e){var a=n((r=t(r)).h,(e=t(e)).h),o=nogamma(r.s,e.s),u=nogamma(r.l,e.l),i=nogamma(r.opacity,e.opacity);return function(n){r.h=a(n);r.s=o(n);r.l=u(n);r.opacity=i(n);return r+""}}}var y=hsl(hue$1);var x=hsl(nogamma);function lab(n,r){var t=nogamma((n=e(n)).l,(r=e(r)).l),a=nogamma(n.a,r.a),o=nogamma(n.b,r.b),u=nogamma(n.opacity,r.opacity);return function(r){n.l=t(r);n.a=a(r);n.b=o(r);n.opacity=u(r);return n+""}}function hcl(n){return function(r,t){var e=n((r=a(r)).h,(t=a(t)).h),o=nogamma(r.c,t.c),u=nogamma(r.l,t.l),i=nogamma(r.opacity,t.opacity);return function(n){r.h=e(n);r.c=o(n);r.l=u(n);r.opacity=i(n);return r+""}}}var M=hcl(hue$1);var d=hcl(nogamma);function cubehelix(n){return function cubehelixGamma(r){r=+r;function cubehelix(t,e){var a=n((t=o(t)).h,(e=o(e)).h),u=nogamma(t.s,e.s),i=nogamma(t.l,e.l),s=nogamma(t.opacity,e.opacity);return function(n){t.h=a(n);t.s=u(n);t.l=i(Math.pow(n,r));t.opacity=s(n);return t+""}}cubehelix.gamma=cubehelixGamma;return cubehelix}(1)}var w=cubehelix(hue$1);var A=cubehelix(nogamma);function piecewise(n,r){void 0===r&&(r=n,n=value);var t=0,e=r.length-1,a=r[0],o=new Array(e<0?0:e);while(t<e)o[t]=n(a,a=r[++t]);return function(n){var r=Math.max(0,Math.min(e-1,Math.floor(n*=e)));return o[r](n-r)}}function quantize(n,r){var t=new Array(r);for(var e=0;e<r;++e)t[e]=n(e/(r-1));return t}export{value as interpolate,array as interpolateArray,basis$1 as interpolateBasis,basisClosed as interpolateBasisClosed,w as interpolateCubehelix,A as interpolateCubehelixLong,date as interpolateDate,discrete as interpolateDiscrete,M as interpolateHcl,d as interpolateHclLong,y as interpolateHsl,x as interpolateHslLong,hue as interpolateHue,lab as interpolateLab,number as interpolateNumber,numberArray as interpolateNumberArray,object as interpolateObject,u as interpolateRgb,i as interpolateRgbBasis,s as interpolateRgbBasisClosed,round as interpolateRound,string as interpolateString,m as interpolateTransformCss,g as interpolateTransformSvg,v as interpolateZoom,piecewise,quantize};
|
|
|