mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
3 lines
18 KiB
JavaScript
3 lines
18 KiB
JavaScript
|
import{InternMap as n,range as e,bisect as t,tickStep as r,ticks as a,tickIncrement as i,quantileSorted as o,ascending as l,quantile as u}from"d3-array";import{interpolate as c,interpolateNumber as s,interpolateRound as f,piecewise as g}from"d3-interpolate";import{formatSpecifier as p,precisionFixed as h,precisionRound as m,precisionPrefix as d,formatPrefix as y,format as v}from"d3-format";import{timeTicks as w,timeTickInterval as M,timeYear as q,timeMonth as k,timeWeek as b,timeDay as x,timeHour as $,timeMinute as N,timeSecond as S,utcTicks as I,utcTickInterval as R,utcYear as A,utcMonth as L,utcWeek as P,utcDay as D,utcHour as E,utcMinute as F,utcSecond as z}from"d3-time";import{timeFormat as O,utcFormat as Q}from"d3-time-format";function initRange(n,e){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(e).domain(n);break}return this}function initInterpolator(n,e){switch(arguments.length){case 0:break;case 1:"function"===typeof n?this.interpolator(n):this.range(n);break;default:this.domain(n);"function"===typeof e?this.interpolator(e):this.range(e);break}return this}const T=Symbol("implicit");function ordinal(){var e=new n,t=[],r=[],a=T;function scale(n){let i=e.get(n);if(void 0===i){if(a!==T)return a;e.set(n,i=t.push(n)-1)}return r[i%r.length]}scale.domain=function(r){if(!arguments.length)return t.slice();t=[],e=new n;for(const n of r)e.has(n)||e.set(n,t.push(n)-1);return scale};scale.range=function(n){return arguments.length?(r=Array.from(n),scale):r.slice()};scale.unknown=function(n){return arguments.length?(a=n,scale):a};scale.copy=function(){return ordinal(t,r).unknown(a)};initRange.apply(scale,arguments);return scale}function band(){var n,t,r=ordinal().unknown(void 0),a=r.domain,i=r.range,o=0,l=1,u=false,c=0,s=0,f=.5;delete r.unknown;function rescale(){var r=a().length,g=l<o,p=g?l:o,h=g?o:l;n=(h-p)/Math.max(1,r-c+2*s);u&&(n=Math.floor(n));p+=(h-p-n*(r-c))*f;t=n*(1-c);u&&(p=Math.round(p),t=Math.round(t));var m=e(r).map((function(e){return p+n*e}));return i(g?m.reverse():m)}r.domain=function(n){return arguments.length?(a(n),rescale()):a()};r.range=function(n){return arguments.length?([o,l]=n,o=+o,l=+l,rescale()):[o,l]};r.rangeRound=function(n){return[o,l]=n,o=+o,l=+l,u=true,rescale()};r.bandwidth=function(){return t};r.step=function(){return n};r.round=function(n){return arguments.length?(u=!!n,rescale()):u};r.padding=function(n){return arguments.length?(c=Math.min(1,s=+n),rescale()):c};r.paddingInner=function(n){return arguments.length?(c=Math.min(1,n),rescale()):c};r.paddingOuter=function(n){return arguments.length?(s=+n,rescale()):s};r.align=function(n){return arguments.length?(f=Math.max(0,Math.min(1,n)),rescale()):f};r.copy=function(){return band(a(),[o,l]).round(u).paddingInner(c).paddingOuter(s).align(f)};return initRange.apply(rescale(),arguments)}function pointish(n){var e=n.copy;n.padding=n.paddingOuter;delete n.paddingInner;delete n.paddingOuter;n.copy=function(){return pointish(e())};return n}function point(){return pointish(band.apply(null,arguments).paddingInner(1))}function constants(n){return function(){return n}}function number$1(n){return+n}var U=[0,1];function identity$1(n){return n}function normalize(n,e){return(e-=n=+n)?function(t){return(t-n)/e}:constants(isNaN(e)?NaN:.5)}function clamper(n,e){var t;n>e&&(t=n,n=e,e=t);return function(t){return Math.max(n,Math.min(e,t))}}function bimap(n,e,t){var r=n[0],a=n[1],i=e[0],o=e[1];a<r?(r=normalize(a,r),i=t(o,i)):(r=normalize(r,a),i=t(i,o));return function(n){return i(r(n))}}function polymap(n,e,r){var a=Math.min(n.length,e.length)-1,i=new Array(a),o=new Array(a),l=-1;if(n[a]<n[0]){n=n.slice().reverse();e=e.slice().reverse()}while(++l<a){i[l]=normalize(n[l],n[l+1]);o[l]=r(e[l],e[l+1])}return function(e){var r=t(n,e,1,a)-1;return o[r](i[r](e))}}function copy$1(n,e){return e.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function transformer$2(){var n,e,t,r,a,i,o=U,l=U,u=c,g=identity$1;function rescale(){var n=Math.min(o.length,l.length);g!==identity$1&&(g=clamper(o
|
||
|
|