Socket
Socket
Sign inDemoInstall

d3-array

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-array - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

src/ticks.js

2

build/bundle.js

@@ -1,1 +0,1 @@

var version = "0.5.2"; export * from "../index"; export {version};
var version = "0.6.0"; export * from "../index"; export {version};

@@ -134,21 +134,48 @@ (function (global, factory) {

function uniform(min, max, n) {
var h = (max - min) / (n + 1),
thresholds = new Array(n),
i = -1;
min += h;
while (++i < n) thresholds[i] = min + i * h;
return thresholds;
function range(start, stop, step) {
if ((n = arguments.length) < 3) {
step = 1;
if (n < 2) {
stop = start;
start = 0;
}
}
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
};
function uniform$1(n) {
return function(min, max) {
return uniform(min, max, n);
};
var e10 = Math.sqrt(50);
var e5 = Math.sqrt(10);
var e2 = Math.sqrt(2);
function ticks(start, stop, count) {
var step = tickStep(start, stop, count);
return range(
Math.ceil(start / step) * step,
Math.floor(stop / step) * step + step / 2, // inclusive
step
);
};
function sturges(min, max, values) {
return uniform(min, max, Math.ceil(Math.log(values.length) / Math.LN2));
function tickStep(start, stop, count) {
var step0 = Math.abs(stop - start) / Math.max(0, count),
step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)),
error = step0 / step1;
if (error >= e10) step1 *= 10;
else if (error >= e5) step1 *= 5;
else if (error >= e2) step1 *= 2;
return stop < start ? -step1 : step1;
};
function sturges(values) {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
};
function number(x) {

@@ -177,7 +204,10 @@ return +x;

x1 = +xz[1],
tz = threshold(x0, x1, values),
m = tz.length;
tz = threshold(values, x0, x1);
// Convert number of thresholds into uniform thresholds.
if (!Array.isArray(tz)) tz = ticks(x0, x1, +tz);
// Coerce thresholds to numbers, ignoring any outside the domain.
for (i = 0; i < m; ++i) x = tz[i] = +tz[i];
var m = tz.length;
for (i = 0; i < m; ++i) tz[i] = +tz[i];
while (tz[0] <= x0) tz.shift(), --m;

@@ -219,3 +249,3 @@ while (tz[m - 1] >= x1) tz.pop(), --m;

: Array.isArray(_) ? constant(Array.prototype.map.call(_, number))
: uniform$1(+_);
: constant(+_);
return histogram;

@@ -240,13 +270,9 @@ };

function freedmanDiaconis(min, max, values) {
function freedmanDiaconis(values, min, max) {
values.sort(ascending);
var h = 2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3),
k = Math.ceil((max - min) / h);
return uniform(min, max, k - 1);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
};
function scott(min, max, values) {
var h = 3.5 * deviation(values) * Math.pow(values.length, -1 / 3),
k = Math.ceil((max - min) / h);
return uniform(min, max, k - 1);
function scott(values, min, max) {
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
};

@@ -519,22 +545,2 @@

function range(start, stop, step) {
if ((n = arguments.length) < 3) {
step = 1;
if (n < 2) {
stop = start;
start = 0;
}
}
var i = -1,
n = Math.max(0, Math.ceil((stop - start) / step)) | 0,
range = new Array(n);
while (++i < n) {
range[i] = start + i * step;
}
return range;
};
function scan(array, compare) {

@@ -651,3 +657,3 @@ if (!(n = array.length)) return;

var version = "0.5.2";
var version = "0.6.0";

@@ -684,2 +690,4 @@ exports.version = version;

exports.sum = sum;
exports.ticks = ticks;
exports.tickStep = tickStep;
exports.transpose = transpose;

@@ -686,0 +694,0 @@ exports.values = values;

@@ -1,1 +0,1 @@

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define("d3-array",["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(arguments.length<3&&(e=0),arguments.length<4&&(u=r.length);u>e;){var i=e+u>>>1;n(r[i],t)<0?e=i+1:u=i}return e},right:function(r,t,e,u){for(arguments.length<3&&(e=0),arguments.length<4&&(u=r.length);u>e;){var i=e+u>>>1;n(r[i],t)>0?u=i:e=i+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 i(n){return null===n?NaN:+n}function o(n,r){var t,e,u=n.length,o=0,f=0,a=-1,s=0;if(1===arguments.length)for(;++a<u;)isNaN(t=i(n[a]))||(e=t-o,o+=e/++s,f+=e*(t-o));else for(;++a<u;)isNaN(t=i(r(n[a],a,n)))||(e=t-o,o+=e/++s,f+=e*(t-o));return s>1?f/(s-1):void 0}function f(){var n=o.apply(this,arguments);return n?Math.sqrt(n):n}function a(n){var r=[];for(var t in n)r.push({key:t,value:n[t]});return r}function s(n,r){var t,e,u,i=-1,o=n.length;if(1===arguments.length){for(;++i<o;)if(null!=(e=n[i])&&e>=e){t=u=e;break}for(;++i<o;)null!=(e=n[i])&&(t>e&&(t=e),e>u&&(u=e))}else{for(;++i<o;)if(null!=(e=r(n[i],i,n))&&e>=e){t=u=e;break}for(;++i<o;)null!=(e=r(n[i],i,n))&&(t>e&&(t=e),e>u&&(u=e))}return[t,u]}function l(n){return function(){return n}}function h(n){return n}function c(n,r,t){var e=(r-n)/(t+1),u=new Array(t),i=-1;for(n+=e;++i<t;)u[i]=n+i*e;return u}function g(n){return function(r,t){return c(r,t,n)}}function v(n,r,t){return c(n,r,Math.ceil(Math.log(t.length)/Math.LN2))}function p(n){return+n}function m(){function n(n){var u,i,o=n.length,f=new Array(o);for(u=0;o>u;++u)f[u]=+r(n[u],u,n);var a=t(f),s=+a[0],l=+a[1],h=e(s,l,f),c=h.length;for(u=0;c>u;++u)i=h[u]=+h[u];for(;h[0]<=s;)h.shift(),--c;for(;h[c-1]>=l;)h.pop(),--c;var g,v=new Array(c+1);for(u=0;c>=u;++u)g=v[u]=[],g.x0=u>0?h[u-1]:s,g.x1=c>u?h[u]:l;for(u=0;o>u;++u)i=f[u],i>=s&&l>=i&&v[P(h,i,0,c)].push(n[u]);return v}var r=h,t=s,e=v;return n.value=function(t){return arguments.length?(r="function"==typeof t?t:l(+t),n):r},n.domain=function(r){return arguments.length?(t="function"==typeof r?r:l([+r[0],+r[1]]),n):t},n.thresholds=function(r){return arguments.length?(e="function"==typeof r?r:Array.isArray(r)?l(Array.prototype.map.call(r,p)):g(+r),n):e},n}function y(n,r,t){if(arguments.length<3&&(t=i),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,o=Math.floor(u),f=+t(n[o],o,n),a=+t(n[o+1],o+1,n);return f+(a-f)*(u-o)}}function d(n,t,e){e.sort(r);var u=2*(y(e,.75)-y(e,.25))*Math.pow(e.length,-1/3),i=Math.ceil((t-n)/u);return c(n,t,i-1)}function N(n,r,t){var e=3.5*f(t)*Math.pow(t.length,-1/3),u=Math.ceil((r-n)/e);return c(n,r,u-1)}function k(n){var r=[];for(var t in n)r.push(t);return r}function A(){}function w(n,r){var t=new A;if(n instanceof A)n.each(function(n,r){t.set(r,n)});else if(Array.isArray(n)){var e,u=-1,i=n.length;if(1===arguments.length)for(;++u<i;)t.set(u,n[u]);else for(;++u<i;)t.set(r(e=n[u],u,n),e)}else if(n)for(var o in n)t.set(o,n[o]);return t}function b(n,r){var t,e,u=-1,i=n.length;if(1===arguments.length){for(;++u<i;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<i;)null!=(e=n[u])&&e>t&&(t=e)}else{for(;++u<i;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<i;)null!=(e=r(n[u],u,n))&&e>t&&(t=e)}return t}function M(n,r){var t,e=0,u=n.length,o=-1,f=u;if(1===arguments.length)for(;++o<u;)isNaN(t=i(n[o]))?--f:e+=t;else for(;++o<u;)isNaN(t=i(r(n[o],o,n)))?--f:e+=t;return f?e/f:void 0}function x(n,t){var e,u=[],o=n.length,f=-1;if(1===arguments.length)for(;++f<o;)isNaN(e=i(n[f]))||u.push(e);else for(;++f<o;)isNaN(e=i(t(n[f],f,n)))||u.push(e);return y(u.sort(r),.5)}function z(n){for(var r,t,e,u=n.length,i=-1,o=0;++i<u;)o+=n[i].length;for(t=new Array(o);--u>=0;)for(e=n[u],r=e.length;--r>=0;)t[--o]=e[r];return t}function j(n,r){var t,e,u=-1,i=n.length;if(1===arguments.length){for(;++u<i;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<i;)null!=(e=n[u])&&t>e&&(t=e)}else{for(;++u<i;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<i;)null!=(e=r(n[u],u,n))&&t>e&&(t=e)}return t}function q(){function n(r,u,o,f){if(u>=i.length)return e?e(r):t?r.sort(t):r;for(var a,s,l,h=-1,c=r.length,g=i[u++],v=w(),p=o();++h<c;)(l=v.get(a=g(s=r[h])+""))?l.push(s):v.set(a,[s]);return v.each(function(r,t){f(p,t,n(r,u,o,f))}),p}function r(n,t){if(t>=i.length)return n;var e=[],u=o[t++];return n.each(function(n,u){e.push({key:u,values:r(n,t)})}),u?e.sort(function(n,r){return u(n.key,r.key)}):e}var t,e,u,i=[],o=[];return u={object:function(r){return n(r,0,L,S)},map:function(r){return n(r,0,D,F)},entries:function(t){return r(n(t,0,D,F),0)},key:function(n){return i.push(n),u},sortKeys:function(n){return o[i.length-1]=n,u},sortValues:function(n){return t=n,u},rollup:function(n){return e=n,u}}}function L(){return{}}function S(n,r,t){n[r]=t}function D(){return w()}function F(n,r,t){n.set(r,t)}function K(n){for(var r,t=0,e=n.length-1,u=n[0],i=new Array(0>e?0:e);e>t;)i[t]=[r=u,u=n[++t]];return i}function R(n,r){for(var t=r.length,e=new Array(t);t--;)e[t]=n[r[t]];return e}function V(n,r,t){(u=arguments.length)<3&&(t=1,2>u&&(r=n,n=0));for(var e=-1,u=0|Math.max(0,Math.ceil((r-n)/t)),i=new Array(u);++e<u;)i[e]=n+e*t;return i}function $(n,t){if(e=n.length){var e,u,i=0,o=0,f=n[o];for(t||(t=r);++i<e;)(t(u=n[i],f)<0||0!==t(f,f))&&(f=u,o=i);return 0===t(f,f)?o:void 0}}function _(){}function B(n,r){var t=new _;if(n instanceof _)n.each(function(n){t.add(n)});else if(n){var e,u=-1,i=n.length;if(1===arguments.length)for(;++u<i;)t.add(n[u]);else for(;++u<i;)t.add(r(e=n[u],u,n))}return t}function C(n,r,t){(i=arguments.length)<3&&(t=n.length,2>i&&(r=0));for(var e,u,i=t-r;i;)u=Math.random()*i--|0,e=n[i+r],n[i+r]=n[u+r],n[u+r]=e;return n}function E(n,r){var t,e=0,u=n.length,i=-1;if(1===arguments.length)for(;++i<u;)isNaN(t=+n[i])||(e+=t);else for(;++i<u;)isNaN(t=+r(n[i],i,n))||(e+=t);return e}function G(n){if(!(u=n.length))return[];for(var r=-1,t=j(n,H),e=new Array(t);++r<t;)for(var u,i=-1,o=e[r]=new Array(u);++i<u;)o[i]=n[i][r];return e}function H(n){return n.length}function I(n){var r=[];for(var t in n)r.push(n[t]);return r}function J(){return G(arguments)}var O=t(r),P=O.right,Q=O.left,T="$";A.prototype=w.prototype={has:function(n){return T+n in this},get:function(n){return this[T+n]},set:function(n,r){return this[T+n]=r,this},remove:function(n){var r=T+n;return r in this&&delete this[r]},clear:function(){for(var n in this)n[0]===T&&delete this[n]},keys:function(){var n=[];for(var r in this)r[0]===T&&n.push(r.slice(1));return n},values:function(){var n=[];for(var r in this)r[0]===T&&n.push(this[r]);return n},entries:function(){var n=[];for(var r in this)r[0]===T&&n.push({key:r.slice(1),value:this[r]});return n},size:function(){var n=0;for(var r in this)r[0]===T&&++n;return n},empty:function(){for(var n in this)if(n[0]===T)return!1;return!0},each:function(n){for(var r in this)r[0]===T&&n(this[r],r.slice(1),this)}};var U=w.prototype;_.prototype=B.prototype={has:U.has,add:function(n){return n+="",this[T+n]=n,this},remove:U.remove,clear:U.clear,values:U.keys,size:U.size,empty:U.empty,each:U.each};var W="0.5.2";n.version=W,n.bisect=P,n.bisectRight=P,n.bisectLeft=Q,n.ascending=r,n.bisector=t,n.descending=u,n.deviation=f,n.entries=a,n.extent=s,n.histogram=m,n.thresholdFreedmanDiaconis=d,n.thresholdScott=N,n.thresholdSturges=v,n.keys=k,n.map=w,n.max=b,n.mean=M,n.median=x,n.merge=z,n.min=j,n.nest=q,n.pairs=K,n.permute=R,n.quantile=y,n.range=V,n.scan=$,n.set=B,n.shuffle=C,n.sum=E,n.transpose=G,n.values=I,n.variance=o,n.zip=J});
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define("d3-array",["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(arguments.length<3&&(e=0),arguments.length<4&&(u=r.length);u>e;){var i=e+u>>>1;n(r[i],t)<0?e=i+1:u=i}return e},right:function(r,t,e,u){for(arguments.length<3&&(e=0),arguments.length<4&&(u=r.length);u>e;){var i=e+u>>>1;n(r[i],t)>0?u=i:e=i+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 i(n){return null===n?NaN:+n}function o(n,r){var t,e,u=n.length,o=0,a=0,f=-1,s=0;if(1===arguments.length)for(;++f<u;)isNaN(t=i(n[f]))||(e=t-o,o+=e/++s,a+=e*(t-o));else for(;++f<u;)isNaN(t=i(r(n[f],f,n)))||(e=t-o,o+=e/++s,a+=e*(t-o));return s>1?a/(s-1):void 0}function a(){var n=o.apply(this,arguments);return n?Math.sqrt(n):n}function f(n){var r=[];for(var t in n)r.push({key:t,value:n[t]});return r}function s(n,r){var t,e,u,i=-1,o=n.length;if(1===arguments.length){for(;++i<o;)if(null!=(e=n[i])&&e>=e){t=u=e;break}for(;++i<o;)null!=(e=n[i])&&(t>e&&(t=e),e>u&&(u=e))}else{for(;++i<o;)if(null!=(e=r(n[i],i,n))&&e>=e){t=u=e;break}for(;++i<o;)null!=(e=r(n[i],i,n))&&(t>e&&(t=e),e>u&&(u=e))}return[t,u]}function h(n){return function(){return n}}function l(n){return n}function c(n,r,t){(u=arguments.length)<3&&(t=1,2>u&&(r=n,n=0));for(var e=-1,u=0|Math.max(0,Math.ceil((r-n)/t)),i=new Array(u);++e<u;)i[e]=n+e*t;return i}function g(n,r,t){var e=v(n,r,t);return c(Math.ceil(n/e)*e,Math.floor(r/e)*e+e/2,e)}function v(n,r,t){var e=Math.abs(r-n)/Math.max(0,t),u=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),i=e/u;return i>=T?u*=10:i>=U?u*=5:i>=W&&(u*=2),n>r?-u:u}function p(n){return Math.ceil(Math.log(n.length)/Math.LN2)+1}function m(n){return+n}function y(){function n(n){var u,i,o=n.length,a=new Array(o);for(u=0;o>u;++u)a[u]=+r(n[u],u,n);var f=t(a),s=+f[0],h=+f[1],l=e(a,s,h);Array.isArray(l)||(l=g(s,h,+l));var c=l.length;for(u=0;c>u;++u)l[u]=+l[u];for(;l[0]<=s;)l.shift(),--c;for(;l[c-1]>=h;)l.pop(),--c;var v,p=new Array(c+1);for(u=0;c>=u;++u)v=p[u]=[],v.x0=u>0?l[u-1]:s,v.x1=c>u?l[u]:h;for(u=0;o>u;++u)i=a[u],i>=s&&h>=i&&p[P(l,i,0,c)].push(n[u]);return p}var r=l,t=s,e=p;return n.value=function(t){return arguments.length?(r="function"==typeof t?t:h(+t),n):r},n.domain=function(r){return arguments.length?(t="function"==typeof r?r:h([+r[0],+r[1]]),n):t},n.thresholds=function(r){return arguments.length?(e="function"==typeof r?r:h(Array.isArray(r)?Array.prototype.map.call(r,m):+r),n):e},n}function d(n,r,t){if(arguments.length<3&&(t=i),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,o=Math.floor(u),a=+t(n[o],o,n),f=+t(n[o+1],o+1,n);return a+(f-a)*(u-o)}}function N(n,t,e){return n.sort(r),Math.ceil((e-t)/(2*(d(n,.75)-d(n,.25))*Math.pow(n.length,-1/3)))}function M(n,r,t){return Math.ceil((t-r)/(3.5*a(n)*Math.pow(n.length,-1/3)))}function k(n){var r=[];for(var t in n)r.push(t);return r}function A(){}function b(n,r){var t=new A;if(n instanceof A)n.each(function(n,r){t.set(r,n)});else if(Array.isArray(n)){var e,u=-1,i=n.length;if(1===arguments.length)for(;++u<i;)t.set(u,n[u]);else for(;++u<i;)t.set(r(e=n[u],u,n),e)}else if(n)for(var o in n)t.set(o,n[o]);return t}function w(n,r){var t,e,u=-1,i=n.length;if(1===arguments.length){for(;++u<i;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<i;)null!=(e=n[u])&&e>t&&(t=e)}else{for(;++u<i;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<i;)null!=(e=r(n[u],u,n))&&e>t&&(t=e)}return t}function x(n,r){var t,e=0,u=n.length,o=-1,a=u;if(1===arguments.length)for(;++o<u;)isNaN(t=i(n[o]))?--a:e+=t;else for(;++o<u;)isNaN(t=i(r(n[o],o,n)))?--a:e+=t;return a?e/a:void 0}function q(n,t){var e,u=[],o=n.length,a=-1;if(1===arguments.length)for(;++a<o;)isNaN(e=i(n[a]))||u.push(e);else for(;++a<o;)isNaN(e=i(t(n[a],a,n)))||u.push(e);return d(u.sort(r),.5)}function z(n){for(var r,t,e,u=n.length,i=-1,o=0;++i<u;)o+=n[i].length;for(t=new Array(o);--u>=0;)for(e=n[u],r=e.length;--r>=0;)t[--o]=e[r];return t}function L(n,r){var t,e,u=-1,i=n.length;if(1===arguments.length){for(;++u<i;)if(null!=(e=n[u])&&e>=e){t=e;break}for(;++u<i;)null!=(e=n[u])&&t>e&&(t=e)}else{for(;++u<i;)if(null!=(e=r(n[u],u,n))&&e>=e){t=e;break}for(;++u<i;)null!=(e=r(n[u],u,n))&&t>e&&(t=e)}return t}function S(){function n(r,u,o,a){if(u>=i.length)return e?e(r):t?r.sort(t):r;for(var f,s,h,l=-1,c=r.length,g=i[u++],v=b(),p=o();++l<c;)(h=v.get(f=g(s=r[l])+""))?h.push(s):v.set(f,[s]);return v.each(function(r,t){a(p,t,n(r,u,o,a))}),p}function r(n,t){if(t>=i.length)return n;var e=[],u=o[t++];return n.each(function(n,u){e.push({key:u,values:r(n,t)})}),u?e.sort(function(n,r){return u(n.key,r.key)}):e}var t,e,u,i=[],o=[];return u={object:function(r){return n(r,0,j,D)},map:function(r){return n(r,0,F,K)},entries:function(t){return r(n(t,0,F,K),0)},key:function(n){return i.push(n),u},sortKeys:function(n){return o[i.length-1]=n,u},sortValues:function(n){return t=n,u},rollup:function(n){return e=n,u}}}function j(){return{}}function D(n,r,t){n[r]=t}function F(){return b()}function K(n,r,t){n.set(r,t)}function R(n){for(var r,t=0,e=n.length-1,u=n[0],i=new Array(0>e?0:e);e>t;)i[t]=[r=u,u=n[++t]];return i}function V(n,r){for(var t=r.length,e=new Array(t);t--;)e[t]=n[r[t]];return e}function $(n,t){if(e=n.length){var e,u,i=0,o=0,a=n[o];for(t||(t=r);++i<e;)(t(u=n[i],a)<0||0!==t(a,a))&&(a=u,o=i);return 0===t(a,a)?o:void 0}}function _(){}function B(n,r){var t=new _;if(n instanceof _)n.each(function(n){t.add(n)});else if(n){var e,u=-1,i=n.length;if(1===arguments.length)for(;++u<i;)t.add(n[u]);else for(;++u<i;)t.add(r(e=n[u],u,n))}return t}function C(n,r,t){(i=arguments.length)<3&&(t=n.length,2>i&&(r=0));for(var e,u,i=t-r;i;)u=Math.random()*i--|0,e=n[i+r],n[i+r]=n[u+r],n[u+r]=e;return n}function E(n,r){var t,e=0,u=n.length,i=-1;if(1===arguments.length)for(;++i<u;)isNaN(t=+n[i])||(e+=t);else for(;++i<u;)isNaN(t=+r(n[i],i,n))||(e+=t);return e}function G(n){if(!(u=n.length))return[];for(var r=-1,t=L(n,H),e=new Array(t);++r<t;)for(var u,i=-1,o=e[r]=new Array(u);++i<u;)o[i]=n[i][r];return e}function H(n){return n.length}function I(n){var r=[];for(var t in n)r.push(n[t]);return r}function J(){return G(arguments)}var O=t(r),P=O.right,Q=O.left,T=Math.sqrt(50),U=Math.sqrt(10),W=Math.sqrt(2),X="$";A.prototype=b.prototype={has:function(n){return X+n in this},get:function(n){return this[X+n]},set:function(n,r){return this[X+n]=r,this},remove:function(n){var r=X+n;return r in this&&delete this[r]},clear:function(){for(var n in this)n[0]===X&&delete this[n]},keys:function(){var n=[];for(var r in this)r[0]===X&&n.push(r.slice(1));return n},values:function(){var n=[];for(var r in this)r[0]===X&&n.push(this[r]);return n},entries:function(){var n=[];for(var r in this)r[0]===X&&n.push({key:r.slice(1),value:this[r]});return n},size:function(){var n=0;for(var r in this)r[0]===X&&++n;return n},empty:function(){for(var n in this)if(n[0]===X)return!1;return!0},each:function(n){for(var r in this)r[0]===X&&n(this[r],r.slice(1),this)}};var Y=b.prototype;_.prototype=B.prototype={has:Y.has,add:function(n){return n+="",this[X+n]=n,this},remove:Y.remove,clear:Y.clear,values:Y.keys,size:Y.size,empty:Y.empty,each:Y.each};var Z="0.6.0";n.version=Z,n.bisect=P,n.bisectRight=P,n.bisectLeft=Q,n.ascending=r,n.bisector=t,n.descending=u,n.deviation=a,n.entries=f,n.extent=s,n.histogram=y,n.thresholdFreedmanDiaconis=N,n.thresholdScott=M,n.thresholdSturges=p,n.keys=k,n.map=b,n.max=w,n.mean=x,n.median=q,n.merge=z,n.min=L,n.nest=S,n.pairs=R,n.permute=V,n.quantile=d,n.range=c,n.scan=$,n.set=B,n.shuffle=C,n.sum=E,n.ticks=g,n.tickStep=v,n.transpose=G,n.values=I,n.variance=o,n.zip=J});

@@ -28,2 +28,3 @@ export {default as bisect, bisectRight, bisectLeft} from "./src/bisect";

export {default as sum} from "./src/sum";
export {default as ticks, tickStep} from "./src/ticks";
export {default as transpose} from "./src/transpose";

@@ -30,0 +31,0 @@ export {default as values} from "./src/values";

{
"name": "d3-array",
"version": "0.5.2",
"version": "0.6.0",
"description": "Array manipulation, ordering, searching, summarizing, etc.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -135,3 +135,3 @@ # d3-array

Returns an array containing an arithmetic progression, similar to the Python built-in [range](http://docs.python.org/library/functions.html#range). This method is often used to iterate over a sequence of regularly-spaced numeric values, such as the indexes of an array or the ticks of a linear scale.
Returns an array containing an arithmetic progression, similar to the Python built-in [range](http://docs.python.org/library/functions.html#range). This method is often used to iterate over a sequence of uniformly-spaced numeric values, such as the indexes of an array or the ticks of a linear scale. (See also [ticks](#ticks) for nicely-rounded values.)

@@ -155,2 +155,10 @@ If *step* is omitted, it defaults to 1. If *start* is omitted, it defaults to 0. The *stop* value is exclusive; it is not included in the result. If *step* is positive, the last element is the largest *start* + *i* \* *step* less than *stop*; if *step* is negative, the last element is the smallest *start* + *i* \* *step* greater than *stop*. If the returned array would contain an infinite number of values, an empty range is returned.

<a name="ticks" href="#ticks">#</a> <b>ticks</b>(<i>start</i>, <i>stop</i>, <i>count</i>)
Returns an array of approximately *count* + 1 uniformly-spaced, nicely-rounded values between *start* and *stop* (inclusive). Each value is a power of ten multiplied by 1, 2 or 5. See also [tickStep](#tickStep) and [*linear*.ticks](https://github.com/d3/d3-scale#linear_ticks). Note that due to the limited precision of IEEE 754 floating point, the returned values may not be exact decimals; use [d3-format](https://github.com/d3/d3-format) to format numbers for human consumption.
<a name="tickStep" href="#tickStep">#</a> <b>tickStep</b>(<i>start</i>, <i>stop</i>, <i>count</i>)
Returns the difference between adjacent tick values if the same arguments were passed to [ticks](#ticks): a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5. Note that due to the limited precision of IEEE 754 floating point, the returned value may not be exact decimals; use [d3-format](https://github.com/d3/d3-format) to format numbers for human consumption.
<a name="permute" href="#permute">#</a> <b>permute</b>(<i>array</i>, <i>indexes</i>)

@@ -541,21 +549,21 @@

If *thresholds* is specified, sets the threshold accessor to the specified function or array and returns this histogram generator. If *thresholds* is not specified, returns the current threshold accessor, which by default implements [Sturges’ formula](#thresholdSturges). Thresholds are defined as an array of numbers [*x0*, *x1*, …]. Any value less than *x0* will be placed in the first bin; any value greater than or equal to *x0* but less than *x1* will be placed in the second bin; and so on. Thus, the [generated histogram](#_histogram) will have *thresholds*.length + 1 bins. See [histogram thresholds](#histogram-thresholds) for more information.
If *thresholds* is specified, sets the [threshold generator](#histogram-thresholds) to the specified function or array and returns this histogram generator. If *thresholds* is not specified, returns the current threshold generator, which by default implements [Sturges’ formula](#thresholdSturges). Thresholds are defined as an array of numbers [*x0*, *x1*, …]. Any value less than *x0* will be placed in the first bin; any value greater than or equal to *x0* but less than *x1* will be placed in the second bin; and so on. Thus, the [generated histogram](#_histogram) will have *thresholds*.length + 1 bins. See [histogram thresholds](#histogram-thresholds) for more information.
If a *count* is specified instead of an array of *thresholds*, then the [domain](#histogram_domain) will be uniformly divided into *count* + 1 bins.
If a *count* is specified instead of an array of *thresholds*, then the [domain](#histogram_domain) will be uniformly divided into approximately *count* bins; see [ticks](#ticks).
### Histogram Thresholds
These functions are typically not used directly; instead, pass them to [*histogram*.thresholds](#histogram_thresholds). You may also implement your own threshold accessor function taking three arguments: the [observable domain](#histogram_domain), represented as *min* and *max*, and the array of input [*values*](#histogram_value) derived from the data. The accessor must then return the array of numeric thresholds.
These functions are typically not used directly; instead, pass them to [*histogram*.thresholds](#histogram_thresholds). You may also implement your own threshold generator taking three arguments: the array of input [*values*](#histogram_value) derived from the data, and the [observable domain](#histogram_domain) represented as *min* and *max*. The generator may then return either the array of numeric thresholds or the *count* of bins; in the latter case the domain is divided uniformly into approximately *count* bins; see [ticks](#ticks).
<a name="thresholdFreedmanDiaconis" href="#thresholdFreedmanDiaconis">#</a> <b>thresholdFreedmanDiaconis</b>(<i>min</i>, <i>max</i>, <i>values</i>)
<a name="thresholdFreedmanDiaconis" href="#thresholdFreedmanDiaconis">#</a> <b>thresholdFreedmanDiaconis</b>(<i>values</i>, <i>min</i>, <i>max</i>)
Returns the array of bin thresholds according to the [Freedman–Diaconis rule](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).
Returns the number of bins according to the [Freedman–Diaconis rule](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).
<a name="thresholdScott" href="#thresholdScott">#</a> <b>thresholdScott</b>(<i>min</i>, <i>max</i>, <i>values</i>)
<a name="thresholdScott" href="#thresholdScott">#</a> <b>thresholdScott</b>(<i>values</i>, <i>min</i>, <i>max</i>)
Returns the array of bin thresholds according to [Scott’s normal reference rule](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).
Returns the number of bins according to [Scott’s normal reference rule](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).
<a name="thresholdSturges" href="#thresholdSturges">#</a> <b>thresholdSturges</b>(<i>min</i>, <i>max</i>, <i>values</i>)
<a name="thresholdSturges" href="#thresholdSturges">#</a> <b>thresholdSturges</b>(<i>values</i>)
Returns the array of bin thresholds according to [Sturges’ formula](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).
Returns the number of bins according to [Sturges’ formula](https://en.wikipedia.org/wiki/Histogram#Mathematical_definition).

@@ -562,0 +570,0 @@ ## Changes from D3 3.x:

@@ -5,4 +5,4 @@ import bisect from "./bisect";

import identity from "./identity";
import ticks from "./ticks";
import sturges from "./threshold/sturges";
import uniform from "./threshold/uniform";

@@ -32,7 +32,10 @@ function number(x) {

x1 = +xz[1],
tz = threshold(x0, x1, values),
m = tz.length;
tz = threshold(values, x0, x1);
// Convert number of thresholds into uniform thresholds.
if (!Array.isArray(tz)) tz = ticks(x0, x1, +tz);
// Coerce thresholds to numbers, ignoring any outside the domain.
for (i = 0; i < m; ++i) x = tz[i] = +tz[i];
var m = tz.length;
for (i = 0; i < m; ++i) tz[i] = +tz[i];
while (tz[0] <= x0) tz.shift(), --m;

@@ -74,3 +77,3 @@ while (tz[m - 1] >= x1) tz.pop(), --m;

: Array.isArray(_) ? constant(Array.prototype.map.call(_, number))
: uniform(+_);
: constant(+_);
return histogram;

@@ -77,0 +80,0 @@ };

@@ -1,10 +0,7 @@

import {uniform} from "./uniform";
import ascending from "../ascending";
import quantile from "../quantile";
export default function(min, max, values) {
export default function(values, min, max) {
values.sort(ascending);
var h = 2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3),
k = Math.ceil((max - min) / h);
return uniform(min, max, k - 1);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
};

@@ -1,8 +0,5 @@

import {uniform} from "./uniform";
import deviation from "../deviation";
export default function(min, max, values) {
var h = 3.5 * deviation(values) * Math.pow(values.length, -1 / 3),
k = Math.ceil((max - min) / h);
return uniform(min, max, k - 1);
export default function(values, min, max) {
return Math.ceil((max - min) / (3.5 * deviation(values) * Math.pow(values.length, -1 / 3)));
};

@@ -1,5 +0,3 @@

import {uniform} from "./uniform";
export default function(min, max, values) {
return uniform(min, max, Math.ceil(Math.log(values.length) / Math.LN2));
export default function(values) {
return Math.ceil(Math.log(values.length) / Math.LN2) + 1;
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc