This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
/
d3-array.v0.7.min.js
1 lines (1 loc) · 5.03 KB
/
d3-array.v0.7.min.js
1
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3_array={})}(this,function(n){"use strict";function r(n,r){return r>n?-1:n>r?1:n>=r?0:NaN}function t(n){return 1===n.length&&(n=e(n)),{left:function(r,t,e,u){for(null==e&&(e=0),null==u&&(u=r.length);u>e;){var o=e+u>>>1;n(r[o],t)<0?e=o+1:u=o}return e},right:function(r,t,e,u){for(null==e&&(e=0),null==u&&(u=r.length);u>e;){var o=e+u>>>1;n(r[o],t)>0?u=o:e=o+1}return e}}}function e(n){return function(t,e){return r(n(t),e)}}function u(n,r){return n>r?-1:r>n?1:r>=n?0:NaN}function o(n){return null===n?NaN:+n}function f(n,r){var t,e,u=n.length,f=0,l=0,i=-1,a=0;if(null==r)for(;++i<u;)isNaN(t=o(n[i]))||(e=t-f,f+=e/++a,l+=e*(t-f));else for(;++i<u;)isNaN(t=o(r(n[i],i,n)))||(e=t-f,f+=e/++a,l+=e*(t-f));return a>1?l/(a-1):void 0}function l(n,r){var t=f(n,r);return t?Math.sqrt(t):t}function i(n,r){var t,e,u,o=-1,f=n.length;if(null==r){for(;++o<f;)if(null!=(e=n[o])&&e>=e){t=u=e;break}for(;++o<f;)null!=(e=n[o])&&(t>e&&(t=e),e>u&&(u=e))}else{for(;++o<f;)if(null!=(e=r(n[o],o,n))&&e>=e){t=u=e;break}for(;++o<f;)null!=(e=r(n[o],o,n))&&(t>e&&(t=e),e>u&&(u=e))}return[t,u]}function a(n){return function(){return n}}function h(n){return n}function c(n,r,t){n=+n,r=+r,t=(u=arguments.length)<2?(r=n,n=0,1):3>u?1:+t;for(var e=-1,u=0|Math.max(0,Math.ceil((r-n)/t)),o=new Array(u);++e<u;)o[e]=n+e*t;return o}function s(n,r,t){var e=g(n,r,t);return c(Math.ceil(n/e)*e,Math.floor(r/e)*e+e/2,e)}function g(n,r,t){var e=Math.abs(r-n)/Math.max(0,t),u=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),o=e/u;return o>=C?u*=10:o>=E?u*=5:o>=G&&(u*=2),n>r?-u:u}function v(n){return Math.ceil(Math.log(n.length)/Math.LN2)+1}function p(n){return+n}function d(){function n(n){var u,o,f=n.length,l=new Array(f);for(u=0;f>u;++u)l[u]=+r(n[u],u,n);var i=t(l),a=+i[0],h=+i[1],c=e(l,a,h);Array.isArray(c)||(c=s(a,h,+c));var g=c.length;for(u=0;g>u;++u)c[u]=+c[u];for(;c[0]<=a;)c.shift(),--g;for(;c[g-1]>=h;)c.pop(),--g;var v,p=new Array(g+1);for(u=0;g>=u;++u)v=p[u]=[],v.x0=u>0?c[u-1]:a,v.x1=g>u?c[u]:h;for(u=0;f>u;++u)o=l[u],o>=a&&h>=o&&p[_(c,o,0,g)].push(n[u]);return p}var r=h,t=i,e=v;return n.value=function(t){return arguments.length?(r="function"==typeof t?t:a(+t),n):r},n.domain=function(r){return arguments.length?(t="function"==typeof r?r:a([+r[0],+r[1]]),n):t},n.thresholds=function(r){return arguments.length?(e="function"==typeof r?r:a(Array.isArray(r)?Array.prototype.map.call(r,p):+r),n):e},n}function M(n,r,t){if(null==t&&(t=o),e=n.length){if((r=+r)<=0||2>e)return+t(n[0],0,n);if(r>=1)return+t(n[e-1],e-1,n);var e,u=(e-1)*r,f=Math.floor(u),l=+t(n[f],f,n),i=+t(n[f+1],f+1,n);return l+(i-l)*(u-f)}}function m(n,t,e){return n.sort(r),Math.ceil((e-t)/(2*(M(n,.75)-M(n,.25))*Math.pow(n.length,-1/3)))}function y(n,r,t){return Math.ceil((t-r)/(3.5*l(n)*Math.pow(n.length,-1/3)))}function N(n,r){var t,e,u=-1,o=n.length;if(null==r){for(;++u<o;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<o;)null!=(e=n[u])&&e>t&&(t=e)}else{for(;++u<o;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<o;)null!=(e=r(n[u],u,n))&&e>t&&(t=e)}return t}function A(n,r){var t,e=0,u=n.length,f=-1,l=u;if(null==r)for(;++f<u;)isNaN(t=o(n[f]))?--l:e+=t;else for(;++f<u;)isNaN(t=o(r(n[f],f,n)))?--l:e+=t;return l?e/l:void 0}function b(n,t){var e,u=[],f=n.length,l=-1;if(null==t)for(;++l<f;)isNaN(e=o(n[l]))||u.push(e);else for(;++l<f;)isNaN(e=o(t(n[l],l,n)))||u.push(e);return M(u.sort(r),.5)}function w(n){for(var r,t,e,u=n.length,o=-1,f=0;++o<u;)f+=n[o].length;for(t=new Array(f);--u>=0;)for(e=n[u],r=e.length;--r>=0;)t[--f]=e[r];return t}function x(n,r){var t,e,u=-1,o=n.length;if(null==r){for(;++u<o;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<o;)null!=(e=n[u])&&t>e&&(t=e)}else{for(;++u<o;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<o;)null!=(e=r(n[u],u,n))&&t>e&&(t=e)}return t}function k(n){for(var r=0,t=n.length-1,e=n[0],u=new Array(0>t?0:t);t>r;)u[r]=[e,e=n[++r]];return u}function q(n,r){for(var t=r.length,e=new Array(t);t--;)e[t]=n[r[t]];return e}function L(n,t){if(e=n.length){var e,u,o=0,f=0,l=n[f];for(t||(t=r);++o<e;)(t(u=n[o],l)<0||0!==t(l,l))&&(l=u,f=o);return 0===t(l,l)?f:void 0}}function S(n,r,t){for(var e,u,o=(null==t?n.length:t)-(r=null==r?0:+r);o;)u=Math.random()*o--|0,e=n[o+r],n[o+r]=n[u+r],n[u+r]=e;return n}function j(n,r){var t,e=0,u=n.length,o=-1;if(null==r)for(;++o<u;)(t=+n[o])&&(e+=t);else for(;++o<u;)(t=+r(n[o],o,n))&&(e+=t);return e}function z(n){if(!(u=n.length))return[];for(var r=-1,t=x(n,D),e=new Array(t);++r<t;)for(var u,o=-1,f=e[r]=new Array(u);++o<u;)f[o]=n[o][r];return e}function D(n){return n.length}function F(){return z(arguments)}var R=t(r),_=R.right,B=R.left,C=Math.sqrt(50),E=Math.sqrt(10),G=Math.sqrt(2),H="0.7.1";n.version=H,n.bisect=_,n.bisectRight=_,n.bisectLeft=B,n.ascending=r,n.bisector=t,n.descending=u,n.deviation=l,n.extent=i,n.histogram=d,n.thresholdFreedmanDiaconis=m,n.thresholdScott=y,n.thresholdSturges=v,n.max=N,n.mean=A,n.median=b,n.merge=w,n.min=x,n.pairs=k,n.permute=q,n.quantile=M,n.range=c,n.scan=L,n.shuffle=S,n.sum=j,n.ticks=s,n.tickStep=g,n.transpose=z,n.variance=f,n.zip=F});