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.8.0 to 0.8.1

src/array.js

35

build/d3-array.js

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

// https://d3js.org/d3-array/ Version 0.8.0. Copyright 2016 Mike Bostock.
// https://d3js.org/d3-array/ Version 0.8.1. Copyright 2016 Mike Bostock.
(function (global, factory) {

@@ -119,2 +119,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

var array = Array.prototype;
var slice = array.slice;
var map = array.map;
function constant(x) {

@@ -170,6 +175,2 @@ return function() {

function number$1(x) {
return +x;
}
function histogram() {

@@ -186,18 +187,16 @@ var value = identity,

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

@@ -228,15 +227,11 @@ while (tz[m - 1] >= x1) tz.pop(), --m;

histogram.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), histogram) : value;
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
};
histogram.domain = function(_) {
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([+_[0], +_[1]]), histogram) : domain;
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
};
histogram.thresholds = function(_) {
if (!arguments.length) return threshold;
threshold = typeof _ === "function" ? _
: Array.isArray(_) ? constant(Array.prototype.map.call(_, number$1))
: constant(+_);
return histogram;
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
};

@@ -261,3 +256,3 @@

function freedmanDiaconis(values, min, max) {
values.sort(ascending);
values = map.call(values, number).sort(ascending);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));

@@ -264,0 +259,0 @@ }

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

// https://d3js.org/d3-array/ Version 0.8.0. Copyright 2016 Mike Bostock.
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3=n.d3||{})}(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>=R?u*=10:o>=B?u*=5:o>=C&&(u*=2),n>r?-u:u}function v(n){return Math.ceil(Math.log(n.length)/Math.LN2)+1}function d(n){return+n}function p(){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,d=new Array(g+1);for(u=0;g>=u;++u)v=d[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&&d[O(c,o,0,g)].push(n[u]);return d}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,d):+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 y(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 N(n,r,t){return Math.ceil((t-r)/(3.5*l(n)*Math.pow(n.length,-1/3)))}function m(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 b(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 A(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 _(n){if(!(u=n.length))return[];for(var r=-1,t=x(n,z),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 z(n){return n.length}function D(){return _(arguments)}var F=t(r),O=F.right,P=F.left,R=Math.sqrt(50),B=Math.sqrt(10),C=Math.sqrt(2);n.bisect=O,n.bisectRight=O,n.bisectLeft=P,n.ascending=r,n.bisector=t,n.descending=u,n.deviation=l,n.extent=i,n.histogram=p,n.thresholdFreedmanDiaconis=y,n.thresholdScott=N,n.thresholdSturges=v,n.max=m,n.mean=b,n.median=A,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=_,n.variance=f,n.zip=D,Object.defineProperty(n,"__esModule",{value:!0})});
// https://d3js.org/d3-array/ Version 0.8.1. Copyright 2016 Mike Bostock.
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3=n.d3||{})}(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 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));for(var g=c.length;c[0]<=a;)c.shift(),--g;for(;c[g-1]>=h;)c.pop(),--g;var v,d=new Array(g+1);for(u=0;g>=u;++u)v=d[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&&d[F(c,o,0,g)].push(n[u]);return d}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)?R.call(r):r),n):e},n}function p(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=B.call(n,o).sort(r),Math.ceil((e-t)/(2*(p(n,.75)-p(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 m(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 p(u.sort(r),.5)}function A(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 w(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 x(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 k(n,r){for(var t=r.length,e=new Array(t);t--;)e[t]=n[r[t]];return e}function q(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 L(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 S(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 j(n){if(!(u=n.length))return[];for(var r=-1,t=w(n,_),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 _(n){return n.length}function z(){return j(arguments)}var D=t(r),F=D.right,O=D.left,P=Array.prototype,R=P.slice,B=P.map,C=Math.sqrt(50),E=Math.sqrt(10),G=Math.sqrt(2);n.bisect=F,n.bisectRight=F,n.bisectLeft=O,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=m,n.median=b,n.merge=A,n.min=w,n.pairs=x,n.permute=k,n.quantile=p,n.range=c,n.scan=q,n.shuffle=L,n.sum=S,n.ticks=s,n.tickStep=g,n.transpose=j,n.variance=f,n.zip=z,Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-array",
"version": "0.8.0",
"version": "0.8.1",
"description": "Array manipulation, ordering, searching, summarizing, etc.",

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

@@ -303,5 +303,5 @@ # d3-array

If *value* is specified, sets the value accessor to the specified function or number and returns this histogram generator. If *value* is not specified, returns the current value accessor, which defaults to the identity function.
If *value* is specified, sets the value accessor to the specified function or constant and returns this histogram generator. If *value* is not specified, returns the current value accessor, which defaults to the identity function.
When a histogram is [generated](#_histogram), the value accessor will be invoked for each element in the input data array, being passed the element `d`, the index `i`, and the array `data` as three arguments. The default value accessor assumes that the input data are numbers, or that they are coercible to numbers using [valueOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf). If your data are not simply numbers, then you should specify an accessor that returns the corresponding numeric value for a given datum.
When a histogram is [generated](#_histogram), the value accessor will be invoked for each element in the input data array, being passed the element `d`, the index `i`, and the array `data` as three arguments. The default value accessor assumes that the input data are orderable (comparable), such as numbers or dates. If your data are not, then you should specify an accessor that returns the corresponding orderable value for a given datum.

@@ -333,3 +333,3 @@ This is similar to mapping your data to values before invoking the histogram generator, but has the benefit that the input data remains associated with the returned bins, thereby making it easier to access other fields of the data.

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 *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). (Thus by default, the histogram values must be numbers!) Thresholds are defined as an array of values [*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.

@@ -344,10 +344,10 @@ 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).

Returns the number of bins 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); the input *values* must be numbers.
<a name="thresholdScott" href="#thresholdScott">#</a> d3.<b>thresholdScott</b>(<i>values</i>, <i>min</i>, <i>max</i>)
Returns the number of bins 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); the input *values* must be numbers.
<a name="thresholdSturges" href="#thresholdSturges">#</a> d3.<b>thresholdSturges</b>(<i>values</i>)
Returns the number of bins 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); the input *values* must be numbers.

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

import {slice} from "./array";
import bisect from "./bisect";

@@ -8,6 +9,2 @@ import constant from "./constant";

function number(x) {
return +x;
}
export default function() {

@@ -24,18 +21,16 @@ var value = identity,

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

@@ -66,15 +61,11 @@ while (tz[m - 1] >= x1) tz.pop(), --m;

histogram.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), histogram) : value;
return arguments.length ? (value = typeof _ === "function" ? _ : constant(_), histogram) : value;
};
histogram.domain = function(_) {
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([+_[0], +_[1]]), histogram) : domain;
return arguments.length ? (domain = typeof _ === "function" ? _ : constant([_[0], _[1]]), histogram) : domain;
};
histogram.thresholds = function(_) {
if (!arguments.length) return threshold;
threshold = typeof _ === "function" ? _
: Array.isArray(_) ? constant(Array.prototype.map.call(_, number))
: constant(+_);
return histogram;
return arguments.length ? (threshold = typeof _ === "function" ? _ : Array.isArray(_) ? constant(slice.call(_)) : constant(_), histogram) : threshold;
};

@@ -81,0 +72,0 @@

@@ -0,7 +1,9 @@

import {map} from "../array";
import ascending from "../ascending";
import number from "../number";
import quantile from "../quantile";
export default function(values, min, max) {
values.sort(ascending);
values = map.call(values, number).sort(ascending);
return Math.ceil((max - min) / (2 * (quantile(values, 0.75) - quantile(values, 0.25)) * Math.pow(values.length, -1 / 3)));
}
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