Comparing version 3.0.0 to 3.0.1
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-scale/ v3.0.0 Copyright 2019 Mike Bostock | ||
// https://d3js.org/d3-scale/ v3.0.1 Copyright 2019 Mike Bostock | ||
(function (global, factory) { | ||
@@ -863,3 +863,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-interpolate'), require('d3-format'), require('d3-time'), require('d3-time-format')) : | ||
function tickInterval(interval, start, stop, step) { | ||
function tickInterval(interval, start, stop) { | ||
if (interval == null) interval = 10; | ||
@@ -872,3 +872,4 @@ | ||
var target = Math.abs(stop - start) / interval, | ||
i = d3Array.bisector(function(i) { return i[2]; }).right(tickIntervals, target); | ||
i = d3Array.bisector(function(i) { return i[2]; }).right(tickIntervals, target), | ||
step; | ||
if (i === tickIntervals.length) { | ||
@@ -885,5 +886,6 @@ step = d3Array.tickStep(start / durationYear, stop / durationYear, interval); | ||
} | ||
return interval.every(step); | ||
} | ||
return step == null ? interval : interval.every(step); | ||
return interval; | ||
} | ||
@@ -899,3 +901,3 @@ | ||
scale.ticks = function(interval, step) { | ||
scale.ticks = function(interval) { | ||
var d = domain(), | ||
@@ -907,3 +909,3 @@ t0 = d[0], | ||
if (r) t = t0, t0 = t1, t1 = t; | ||
t = tickInterval(interval, t0, t1, step); | ||
t = tickInterval(interval, t0, t1); | ||
t = t ? t.range(t0, t1 + 1) : []; // inclusive stop | ||
@@ -917,5 +919,5 @@ return r ? t.reverse() : t; | ||
scale.nice = function(interval, step) { | ||
scale.nice = function(interval) { | ||
var d = domain(); | ||
return (interval = tickInterval(interval, d[0], d[d.length - 1], step)) | ||
return (interval = tickInterval(interval, d[0], d[d.length - 1])) | ||
? domain(nice(d, interval)) | ||
@@ -922,0 +924,0 @@ : scale; |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-scale/ v3.0.0 Copyright 2019 Mike Bostock | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-interpolate"),require("d3-format"),require("d3-time"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-interpolate","d3-format","d3-time","d3-time-format"],t):t(n.d3=n.d3||{},n.d3,n.d3,n.d3,n.d3,n.d3)}(this,function(n,t,r,e,u,i){"use strict";function o(n,t){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(t).domain(n)}return this}function a(n,t){switch(arguments.length){case 0:break;case 1:this.interpolator(n);break;default:this.interpolator(t).domain(n)}return this}const c=Symbol("implicit");function f(){var n=new Map,t=[],r=[],e=c;function u(u){var i=u+"",o=n.get(i);if(!o){if(e!==c)return e;n.set(i,o=t.push(u))}return r[(o-1)%r.length]}return u.domain=function(r){if(!arguments.length)return t.slice();t=[],n=new Map;for(const e of r){const r=e+"";n.has(r)||n.set(r,t.push(e))}return u},u.range=function(n){return arguments.length?(r=Array.from(n),u):r.slice()},u.unknown=function(n){return arguments.length?(e=n,u):e},u.copy=function(){return f(t,r).unknown(e)},o.apply(u,arguments),u}function l(){var n,r,e=f().unknown(void 0),u=e.domain,i=e.range,a=0,c=1,p=!1,s=0,h=0,g=.5;function m(){var e=u().length,o=c<a,f=o?c:a,l=o?a:c;n=(l-f)/Math.max(1,e-s+2*h),p&&(n=Math.floor(n)),f+=(l-f-n*(e-s))*g,r=n*(1-s),p&&(f=Math.round(f),r=Math.round(r));var m=t.range(e).map(function(t){return f+n*t});return i(o?m.reverse():m)}return delete e.unknown,e.domain=function(n){return arguments.length?(u(n),m()):u()},e.range=function(n){return arguments.length?([a,c]=n,a=+a,c=+c,m()):[a,c]},e.rangeRound=function(n){return[a,c]=n,a=+a,c=+c,p=!0,m()},e.bandwidth=function(){return r},e.step=function(){return n},e.round=function(n){return arguments.length?(p=!!n,m()):p},e.padding=function(n){return arguments.length?(s=Math.min(1,h=+n),m()):s},e.paddingInner=function(n){return arguments.length?(s=Math.min(1,n),m()):s},e.paddingOuter=function(n){return arguments.length?(h=+n,m()):h},e.align=function(n){return arguments.length?(g=Math.max(0,Math.min(1,n)),m()):g},e.copy=function(){return l(u(),[a,c]).round(p).paddingInner(s).paddingOuter(h).align(g)},o.apply(m(),arguments)}function p(n){return+n}var s=[0,1];function h(n){return n}function g(n,t){return(t-=n=+n)?function(r){return(r-n)/t}:(r=isNaN(t)?NaN:.5,function(){return r});var r}function m(n){var t,r=n[0],e=n[n.length-1];return r>e&&(t=r,r=e,e=t),function(n){return Math.max(r,Math.min(e,n))}}function d(n,t,r){var e=n[0],u=n[1],i=t[0],o=t[1];return u<e?(e=g(u,e),i=r(o,i)):(e=g(e,u),i=r(i,o)),function(n){return i(e(n))}}function y(n,r,e){var u=Math.min(n.length,r.length)-1,i=new Array(u),o=new Array(u),a=-1;for(n[u]<n[0]&&(n=n.slice().reverse(),r=r.slice().reverse());++a<u;)i[a]=g(n[a],n[a+1]),o[a]=e(r[a],r[a+1]);return function(r){var e=t.bisect(n,r,1,u)-1;return o[e](i[e](r))}}function v(n,t){return t.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function M(){var n,t,e,u,i,o,a=s,c=s,f=r.interpolate,l=h;function g(){return u=Math.min(a.length,c.length)>2?y:d,i=o=null,v}function v(t){return isNaN(t=+t)?e:(i||(i=u(a.map(n),c,f)))(n(l(t)))}return v.invert=function(e){return l(t((o||(o=u(c,a.map(n),r.interpolateNumber)))(e)))},v.domain=function(n){return arguments.length?(a=Array.from(n,p),l===h||(l=m(a)),g()):a.slice()},v.range=function(n){return arguments.length?(c=Array.from(n),g()):c.slice()},v.rangeRound=function(n){return c=Array.from(n),f=r.interpolateRound,g()},v.clamp=function(n){return arguments.length?(l=n?m(a):h,v):l!==h},v.interpolate=function(n){return arguments.length?(f=n,g()):f},v.unknown=function(n){return arguments.length?(e=n,v):e},function(r,e){return n=r,t=e,g()}}function k(n,t){return M()(n,t)}function w(n,r,u,i){var o,a=t.tickStep(n,r,u);switch((i=e.formatSpecifier(null==i?",f":i)).type){case"s":var c=Math.max(Math.abs(n),Math.abs(r));return null!=i.precision||isNaN(o=e.precisionPrefix(a,c))||(i.precision=o),e.formatPrefix(i,c);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=e.precisionRound(a,Math.max(Math.abs(n),Math.abs(r))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=e.precisionFixed(a))||(i.precision=o-2*("%"===i.type))}return e.format(i)}function x(n){var r=n.domain;return n.ticks=function(n){var e=r();return t.ticks(e[0],e[e.length-1],null==n?10:n)},n.tickFormat=function(n,t){var e=r();return w(e[0],e[e.length-1],null==n?10:n,t)},n.nice=function(e){null==e&&(e=10);var u,i=r(),o=0,a=i.length-1,c=i[o],f=i[a];return f<c&&(u=c,c=f,f=u,u=o,o=a,a=u),(u=t.tickIncrement(c,f,e))>0?(c=Math.floor(c/u)*u,f=Math.ceil(f/u)*u,u=t.tickIncrement(c,f,e)):u<0&&(c=Math.ceil(c*u)/u,f=Math.floor(f*u)/u,u=t.tickIncrement(c,f,e)),u>0?(i[o]=Math.floor(c/u)*u,i[a]=Math.ceil(f/u)*u,r(i)):u<0&&(i[o]=Math.ceil(c*u)/u,i[a]=Math.floor(f*u)/u,r(i)),n},n}function N(n,t){var r,e=0,u=(n=n.slice()).length-1,i=n[e],o=n[u];return o<i&&(r=e,e=u,u=r,r=i,i=o,o=r),n[e]=t.floor(i),n[u]=t.ceil(o),n}function b(n){return Math.log(n)}function S(n){return Math.exp(n)}function q(n){return-Math.log(-n)}function A(n){return-Math.exp(-n)}function D(n){return isFinite(n)?+("1e"+n):n<0?0:n}function I(n){return function(t){return-n(-t)}}function O(n){var r,u,i=n(b,S),o=i.domain,a=10;function c(){return r=function(n){return n===Math.E?Math.log:10===n&&Math.log10||2===n&&Math.log2||(n=Math.log(n),function(t){return Math.log(t)/n})}(a),u=function(n){return 10===n?D:n===Math.E?Math.exp:function(t){return Math.pow(n,t)}}(a),o()[0]<0?(r=I(r),u=I(u),n(q,A)):n(b,S),i}return i.base=function(n){return arguments.length?(a=+n,c()):a},i.domain=function(n){return arguments.length?(o(n),c()):o()},i.ticks=function(n){var e,i=o(),c=i[0],f=i[i.length-1];(e=f<c)&&(h=c,c=f,f=h);var l,p,s,h=r(c),g=r(f),m=null==n?10:+n,d=[];if(!(a%1)&&g-h<m){if(h=Math.round(h)-1,g=Math.round(g)+1,c>0){for(;h<g;++h)for(p=1,l=u(h);p<a;++p)if(!((s=l*p)<c)){if(s>f)break;d.push(s)}}else for(;h<g;++h)for(p=a-1,l=u(h);p>=1;--p)if(!((s=l*p)<c)){if(s>f)break;d.push(s)}}else d=t.ticks(h,g,Math.min(g-h,m)).map(u);return e?d.reverse():d},i.tickFormat=function(n,t){if(null==t&&(t=10===a?".0e":","),"function"!=typeof t&&(t=e.format(t)),n===1/0)return t;null==n&&(n=10);var o=Math.max(1,a*n/i.ticks().length);return function(n){var e=n/u(Math.round(r(n)));return e*a<a-.5&&(e*=a),e<=o?t(n):""}},i.nice=function(){return o(N(o(),{floor:function(n){return u(Math.floor(r(n)))},ceil:function(n){return u(Math.ceil(r(n)))}}))},i}function F(n){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/n))}}function P(n){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*n}}function E(n){var t=1,r=n(F(t),P(t));return r.constant=function(r){return arguments.length?n(F(t=+r),P(t)):t},x(r)}function L(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function R(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function T(n){return n<0?-n*n:n*n}function Q(n){var t=n(h,h),r=1;return t.exponent=function(t){return arguments.length?1===(r=+t)?n(h,h):.5===r?n(R,T):n(L(r),L(1/r)):r},x(t)}function U(){var n=Q(M());return n.copy=function(){return v(n,U()).exponent(n.exponent())},o.apply(n,arguments),n}var Y=1e3,j=60*Y,B=60*j,C=24*B,H=7*C,W=30*C,_=365*C;function z(n){return new Date(n)}function G(n){return n instanceof Date?+n:+new Date(+n)}function J(n,r,e,u,i,o,a,c,f){var l=k(h,h),p=l.invert,s=l.domain,g=f(".%L"),m=f(":%S"),d=f("%I:%M"),y=f("%I %p"),M=f("%a %d"),w=f("%b %d"),x=f("%B"),b=f("%Y"),S=[[a,1,Y],[a,5,5*Y],[a,15,15*Y],[a,30,30*Y],[o,1,j],[o,5,5*j],[o,15,15*j],[o,30,30*j],[i,1,B],[i,3,3*B],[i,6,6*B],[i,12,12*B],[u,1,C],[u,2,2*C],[e,1,H],[r,1,W],[r,3,3*W],[n,1,_]];function q(t){return(a(t)<t?g:o(t)<t?m:i(t)<t?d:u(t)<t?y:r(t)<t?e(t)<t?M:w:n(t)<t?x:b)(t)}function A(r,e,u,i){if(null==r&&(r=10),"number"==typeof r){var o=Math.abs(u-e)/r,a=t.bisector(function(n){return n[2]}).right(S,o);a===S.length?(i=t.tickStep(e/_,u/_,r),r=n):a?(i=(a=S[o/S[a-1][2]<S[a][2]/o?a-1:a])[1],r=a[0]):(i=Math.max(t.tickStep(e,u,r),1),r=c)}return null==i?r:r.every(i)}return l.invert=function(n){return new Date(p(n))},l.domain=function(n){return arguments.length?s(Array.from(n,G)):s().map(z)},l.ticks=function(n,t){var r,e=s(),u=e[0],i=e[e.length-1],o=i<u;return o&&(r=u,u=i,i=r),r=(r=A(n,u,i,t))?r.range(u,i+1):[],o?r.reverse():r},l.tickFormat=function(n,t){return null==t?q:f(t)},l.nice=function(n,t){var r=s();return(n=A(n,r[0],r[r.length-1],t))?s(N(r,n)):l},l.copy=function(){return v(l,J(n,r,e,u,i,o,a,c,f))},l}function K(){var n,t,r,e,u,i=0,o=1,a=h,c=!1;function f(t){return isNaN(t=+t)?u:a(0===r?.5:(t=(e(t)-n)*r,c?Math.max(0,Math.min(1,t)):t))}return f.domain=function(u){return arguments.length?([i,o]=u,n=e(i=+i),t=e(o=+o),r=n===t?0:1/(t-n),f):[i,o]},f.clamp=function(n){return arguments.length?(c=!!n,f):c},f.interpolator=function(n){return arguments.length?(a=n,f):a},f.unknown=function(n){return arguments.length?(u=n,f):u},function(u){return e=u,n=u(i),t=u(o),r=n===t?0:1/(t-n),f}}function V(n,t){return t.domain(n.domain()).interpolator(n.interpolator()).clamp(n.clamp()).unknown(n.unknown())}function X(){var n=Q(K());return n.copy=function(){return V(n,X()).exponent(n.exponent())},a.apply(n,arguments)}function Z(){var n,t,r,e,u,i,o,a=0,c=.5,f=1,l=h,p=!1;function s(n){return isNaN(n=+n)?o:(n=.5+((n=+i(n))-t)*(n<t?e:u),l(p?Math.max(0,Math.min(1,n)):n))}return s.domain=function(o){return arguments.length?([a,c,f]=o,n=i(a=+a),t=i(c=+c),r=i(f=+f),e=n===t?0:.5/(t-n),u=t===r?0:.5/(r-t),s):[a,c,f]},s.clamp=function(n){return arguments.length?(p=!!n,s):p},s.interpolator=function(n){return arguments.length?(l=n,s):l},s.unknown=function(n){return arguments.length?(o=n,s):o},function(o){return i=o,n=o(a),t=o(c),r=o(f),e=n===t?0:.5/(t-n),u=t===r?0:.5/(r-t),s}}function $(){var n=Q(Z());return n.copy=function(){return V(n,$()).exponent(n.exponent())},a.apply(n,arguments)}n.scaleBand=l,n.scalePoint=function(){return function n(t){var r=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return n(r())},t}(l.apply(null,arguments).paddingInner(1))},n.scaleIdentity=function n(t){var r;function e(n){return isNaN(n=+n)?r:n}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=Array.from(n,p),e):t.slice()},e.unknown=function(n){return arguments.length?(r=n,e):r},e.copy=function(){return n(t).unknown(r)},t=arguments.length?Array.from(t,p):[0,1],x(e)},n.scaleLinear=function n(){var t=k(h,h);return t.copy=function(){return v(t,n())},o.apply(t,arguments),x(t)},n.scaleLog=function n(){var t=O(M()).domain([1,10]);return t.copy=function(){return v(t,n()).base(t.base())},o.apply(t,arguments),t},n.scaleSymlog=function n(){var t=E(M());return t.copy=function(){return v(t,n()).constant(t.constant())},o.apply(t,arguments)},n.scaleOrdinal=f,n.scaleImplicit=c,n.scalePow=U,n.scaleSqrt=function(){return U.apply(null,arguments).exponent(.5)},n.scaleQuantile=function n(){var r,e=[],u=[],i=[];function a(){var n=0,r=Math.max(1,u.length);for(i=new Array(r-1);++n<r;)i[n-1]=t.quantile(e,n/r);return c}function c(n){return isNaN(n=+n)?r:u[t.bisect(i,n)]}return c.invertExtent=function(n){var t=u.indexOf(n);return t<0?[NaN,NaN]:[t>0?i[t-1]:e[0],t<i.length?i[t]:e[e.length-1]]},c.domain=function(n){if(!arguments.length)return e.slice();e=[];for(let t of n)null==t||isNaN(t=+t)||e.push(t);return e.sort(t.ascending),a()},c.range=function(n){return arguments.length?(u=Array.from(n),a()):u.slice()},c.unknown=function(n){return arguments.length?(r=n,c):r},c.quantiles=function(){return i.slice()},c.copy=function(){return n().domain(e).range(u).unknown(r)},o.apply(c,arguments)},n.scaleQuantize=function n(){var r,e=0,u=1,i=1,a=[.5],c=[0,1];function f(n){return n<=n?c[t.bisect(a,n,0,i)]:r}function l(){var n=-1;for(a=new Array(i);++n<i;)a[n]=((n+1)*u-(n-i)*e)/(i+1);return f}return f.domain=function(n){return arguments.length?([e,u]=n,e=+e,u=+u,l()):[e,u]},f.range=function(n){return arguments.length?(i=(c=Array.from(n)).length-1,l()):c.slice()},f.invertExtent=function(n){var t=c.indexOf(n);return t<0?[NaN,NaN]:t<1?[e,a[0]]:t>=i?[a[i-1],u]:[a[t-1],a[t]]},f.unknown=function(n){return arguments.length?(r=n,f):f},f.thresholds=function(){return a.slice()},f.copy=function(){return n().domain([e,u]).range(c).unknown(r)},o.apply(x(f),arguments)},n.scaleThreshold=function n(){var r,e=[.5],u=[0,1],i=1;function a(n){return n<=n?u[t.bisect(e,n,0,i)]:r}return a.domain=function(n){return arguments.length?(e=Array.from(n),i=Math.min(e.length,u.length-1),a):e.slice()},a.range=function(n){return arguments.length?(u=Array.from(n),i=Math.min(e.length,u.length-1),a):u.slice()},a.invertExtent=function(n){var t=u.indexOf(n);return[e[t-1],e[t]]},a.unknown=function(n){return arguments.length?(r=n,a):r},a.copy=function(){return n().domain(e).range(u).unknown(r)},o.apply(a,arguments)},n.scaleTime=function(){return o.apply(J(u.timeYear,u.timeMonth,u.timeWeek,u.timeDay,u.timeHour,u.timeMinute,u.timeSecond,u.timeMillisecond,i.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},n.scaleUtc=function(){return o.apply(J(u.utcYear,u.utcMonth,u.utcWeek,u.utcDay,u.utcHour,u.utcMinute,u.utcSecond,u.utcMillisecond,i.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},n.scaleSequential=function n(){var t=x(K()(h));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleSequentialLog=function n(){var t=O(K()).domain([1,10]);return t.copy=function(){return V(t,n()).base(t.base())},a.apply(t,arguments)},n.scaleSequentialPow=X,n.scaleSequentialSqrt=function(){return X.apply(null,arguments).exponent(.5)},n.scaleSequentialSymlog=function n(){var t=E(K());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},n.scaleSequentialQuantile=function n(){var r=[],e=h;function u(n){if(!isNaN(n=+n))return e((t.bisect(r,n)-1)/(r.length-1))}return u.domain=function(n){if(!arguments.length)return r.slice();r=[];for(let t of n)null==t||isNaN(t=+t)||r.push(t);return r.sort(t.ascending),u},u.interpolator=function(n){return arguments.length?(e=n,u):e},u.copy=function(){return n(e).domain(r)},a.apply(u,arguments)},n.scaleDiverging=function n(){var t=x(Z()(h));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleDivergingLog=function n(){var t=O(Z()).domain([.1,1,10]);return t.copy=function(){return V(t,n()).base(t.base())},a.apply(t,arguments)},n.scaleDivergingPow=$,n.scaleDivergingSqrt=function(){return $.apply(null,arguments).exponent(.5)},n.scaleDivergingSymlog=function n(){var t=E(Z());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},n.tickFormat=w,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-scale/ v3.0.1 Copyright 2019 Mike Bostock | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-interpolate"),require("d3-format"),require("d3-time"),require("d3-time-format")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-interpolate","d3-format","d3-time","d3-time-format"],t):t(n.d3=n.d3||{},n.d3,n.d3,n.d3,n.d3,n.d3)}(this,function(n,t,r,e,u,i){"use strict";function o(n,t){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(t).domain(n)}return this}function a(n,t){switch(arguments.length){case 0:break;case 1:this.interpolator(n);break;default:this.interpolator(t).domain(n)}return this}const c=Symbol("implicit");function f(){var n=new Map,t=[],r=[],e=c;function u(u){var i=u+"",o=n.get(i);if(!o){if(e!==c)return e;n.set(i,o=t.push(u))}return r[(o-1)%r.length]}return u.domain=function(r){if(!arguments.length)return t.slice();t=[],n=new Map;for(const e of r){const r=e+"";n.has(r)||n.set(r,t.push(e))}return u},u.range=function(n){return arguments.length?(r=Array.from(n),u):r.slice()},u.unknown=function(n){return arguments.length?(e=n,u):e},u.copy=function(){return f(t,r).unknown(e)},o.apply(u,arguments),u}function l(){var n,r,e=f().unknown(void 0),u=e.domain,i=e.range,a=0,c=1,p=!1,s=0,h=0,g=.5;function m(){var e=u().length,o=c<a,f=o?c:a,l=o?a:c;n=(l-f)/Math.max(1,e-s+2*h),p&&(n=Math.floor(n)),f+=(l-f-n*(e-s))*g,r=n*(1-s),p&&(f=Math.round(f),r=Math.round(r));var m=t.range(e).map(function(t){return f+n*t});return i(o?m.reverse():m)}return delete e.unknown,e.domain=function(n){return arguments.length?(u(n),m()):u()},e.range=function(n){return arguments.length?([a,c]=n,a=+a,c=+c,m()):[a,c]},e.rangeRound=function(n){return[a,c]=n,a=+a,c=+c,p=!0,m()},e.bandwidth=function(){return r},e.step=function(){return n},e.round=function(n){return arguments.length?(p=!!n,m()):p},e.padding=function(n){return arguments.length?(s=Math.min(1,h=+n),m()):s},e.paddingInner=function(n){return arguments.length?(s=Math.min(1,n),m()):s},e.paddingOuter=function(n){return arguments.length?(h=+n,m()):h},e.align=function(n){return arguments.length?(g=Math.max(0,Math.min(1,n)),m()):g},e.copy=function(){return l(u(),[a,c]).round(p).paddingInner(s).paddingOuter(h).align(g)},o.apply(m(),arguments)}function p(n){return+n}var s=[0,1];function h(n){return n}function g(n,t){return(t-=n=+n)?function(r){return(r-n)/t}:(r=isNaN(t)?NaN:.5,function(){return r});var r}function m(n){var t,r=n[0],e=n[n.length-1];return r>e&&(t=r,r=e,e=t),function(n){return Math.max(r,Math.min(e,n))}}function d(n,t,r){var e=n[0],u=n[1],i=t[0],o=t[1];return u<e?(e=g(u,e),i=r(o,i)):(e=g(e,u),i=r(i,o)),function(n){return i(e(n))}}function y(n,r,e){var u=Math.min(n.length,r.length)-1,i=new Array(u),o=new Array(u),a=-1;for(n[u]<n[0]&&(n=n.slice().reverse(),r=r.slice().reverse());++a<u;)i[a]=g(n[a],n[a+1]),o[a]=e(r[a],r[a+1]);return function(r){var e=t.bisect(n,r,1,u)-1;return o[e](i[e](r))}}function v(n,t){return t.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function M(){var n,t,e,u,i,o,a=s,c=s,f=r.interpolate,l=h;function g(){return u=Math.min(a.length,c.length)>2?y:d,i=o=null,v}function v(t){return isNaN(t=+t)?e:(i||(i=u(a.map(n),c,f)))(n(l(t)))}return v.invert=function(e){return l(t((o||(o=u(c,a.map(n),r.interpolateNumber)))(e)))},v.domain=function(n){return arguments.length?(a=Array.from(n,p),l===h||(l=m(a)),g()):a.slice()},v.range=function(n){return arguments.length?(c=Array.from(n),g()):c.slice()},v.rangeRound=function(n){return c=Array.from(n),f=r.interpolateRound,g()},v.clamp=function(n){return arguments.length?(l=n?m(a):h,v):l!==h},v.interpolate=function(n){return arguments.length?(f=n,g()):f},v.unknown=function(n){return arguments.length?(e=n,v):e},function(r,e){return n=r,t=e,g()}}function k(n,t){return M()(n,t)}function w(n,r,u,i){var o,a=t.tickStep(n,r,u);switch((i=e.formatSpecifier(null==i?",f":i)).type){case"s":var c=Math.max(Math.abs(n),Math.abs(r));return null!=i.precision||isNaN(o=e.precisionPrefix(a,c))||(i.precision=o),e.formatPrefix(i,c);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=e.precisionRound(a,Math.max(Math.abs(n),Math.abs(r))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=e.precisionFixed(a))||(i.precision=o-2*("%"===i.type))}return e.format(i)}function x(n){var r=n.domain;return n.ticks=function(n){var e=r();return t.ticks(e[0],e[e.length-1],null==n?10:n)},n.tickFormat=function(n,t){var e=r();return w(e[0],e[e.length-1],null==n?10:n,t)},n.nice=function(e){null==e&&(e=10);var u,i=r(),o=0,a=i.length-1,c=i[o],f=i[a];return f<c&&(u=c,c=f,f=u,u=o,o=a,a=u),(u=t.tickIncrement(c,f,e))>0?(c=Math.floor(c/u)*u,f=Math.ceil(f/u)*u,u=t.tickIncrement(c,f,e)):u<0&&(c=Math.ceil(c*u)/u,f=Math.floor(f*u)/u,u=t.tickIncrement(c,f,e)),u>0?(i[o]=Math.floor(c/u)*u,i[a]=Math.ceil(f/u)*u,r(i)):u<0&&(i[o]=Math.ceil(c*u)/u,i[a]=Math.floor(f*u)/u,r(i)),n},n}function N(n,t){var r,e=0,u=(n=n.slice()).length-1,i=n[e],o=n[u];return o<i&&(r=e,e=u,u=r,r=i,i=o,o=r),n[e]=t.floor(i),n[u]=t.ceil(o),n}function b(n){return Math.log(n)}function S(n){return Math.exp(n)}function q(n){return-Math.log(-n)}function A(n){return-Math.exp(-n)}function D(n){return isFinite(n)?+("1e"+n):n<0?0:n}function I(n){return function(t){return-n(-t)}}function O(n){var r,u,i=n(b,S),o=i.domain,a=10;function c(){return r=function(n){return n===Math.E?Math.log:10===n&&Math.log10||2===n&&Math.log2||(n=Math.log(n),function(t){return Math.log(t)/n})}(a),u=function(n){return 10===n?D:n===Math.E?Math.exp:function(t){return Math.pow(n,t)}}(a),o()[0]<0?(r=I(r),u=I(u),n(q,A)):n(b,S),i}return i.base=function(n){return arguments.length?(a=+n,c()):a},i.domain=function(n){return arguments.length?(o(n),c()):o()},i.ticks=function(n){var e,i=o(),c=i[0],f=i[i.length-1];(e=f<c)&&(h=c,c=f,f=h);var l,p,s,h=r(c),g=r(f),m=null==n?10:+n,d=[];if(!(a%1)&&g-h<m){if(h=Math.round(h)-1,g=Math.round(g)+1,c>0){for(;h<g;++h)for(p=1,l=u(h);p<a;++p)if(!((s=l*p)<c)){if(s>f)break;d.push(s)}}else for(;h<g;++h)for(p=a-1,l=u(h);p>=1;--p)if(!((s=l*p)<c)){if(s>f)break;d.push(s)}}else d=t.ticks(h,g,Math.min(g-h,m)).map(u);return e?d.reverse():d},i.tickFormat=function(n,t){if(null==t&&(t=10===a?".0e":","),"function"!=typeof t&&(t=e.format(t)),n===1/0)return t;null==n&&(n=10);var o=Math.max(1,a*n/i.ticks().length);return function(n){var e=n/u(Math.round(r(n)));return e*a<a-.5&&(e*=a),e<=o?t(n):""}},i.nice=function(){return o(N(o(),{floor:function(n){return u(Math.floor(r(n)))},ceil:function(n){return u(Math.ceil(r(n)))}}))},i}function F(n){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/n))}}function P(n){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*n}}function E(n){var t=1,r=n(F(t),P(t));return r.constant=function(r){return arguments.length?n(F(t=+r),P(t)):t},x(r)}function L(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function R(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function T(n){return n<0?-n*n:n*n}function Q(n){var t=n(h,h),r=1;return t.exponent=function(t){return arguments.length?1===(r=+t)?n(h,h):.5===r?n(R,T):n(L(r),L(1/r)):r},x(t)}function U(){var n=Q(M());return n.copy=function(){return v(n,U()).exponent(n.exponent())},o.apply(n,arguments),n}var Y=1e3,j=60*Y,B=60*j,C=24*B,H=7*C,W=30*C,_=365*C;function z(n){return new Date(n)}function G(n){return n instanceof Date?+n:+new Date(+n)}function J(n,r,e,u,i,o,a,c,f){var l=k(h,h),p=l.invert,s=l.domain,g=f(".%L"),m=f(":%S"),d=f("%I:%M"),y=f("%I %p"),M=f("%a %d"),w=f("%b %d"),x=f("%B"),b=f("%Y"),S=[[a,1,Y],[a,5,5*Y],[a,15,15*Y],[a,30,30*Y],[o,1,j],[o,5,5*j],[o,15,15*j],[o,30,30*j],[i,1,B],[i,3,3*B],[i,6,6*B],[i,12,12*B],[u,1,C],[u,2,2*C],[e,1,H],[r,1,W],[r,3,3*W],[n,1,_]];function q(t){return(a(t)<t?g:o(t)<t?m:i(t)<t?d:u(t)<t?y:r(t)<t?e(t)<t?M:w:n(t)<t?x:b)(t)}function A(r,e,u){if(null==r&&(r=10),"number"==typeof r){var i,o=Math.abs(u-e)/r,a=t.bisector(function(n){return n[2]}).right(S,o);return a===S.length?(i=t.tickStep(e/_,u/_,r),r=n):a?(i=(a=S[o/S[a-1][2]<S[a][2]/o?a-1:a])[1],r=a[0]):(i=Math.max(t.tickStep(e,u,r),1),r=c),r.every(i)}return r}return l.invert=function(n){return new Date(p(n))},l.domain=function(n){return arguments.length?s(Array.from(n,G)):s().map(z)},l.ticks=function(n){var t,r=s(),e=r[0],u=r[r.length-1],i=u<e;return i&&(t=e,e=u,u=t),t=(t=A(n,e,u))?t.range(e,u+1):[],i?t.reverse():t},l.tickFormat=function(n,t){return null==t?q:f(t)},l.nice=function(n){var t=s();return(n=A(n,t[0],t[t.length-1]))?s(N(t,n)):l},l.copy=function(){return v(l,J(n,r,e,u,i,o,a,c,f))},l}function K(){var n,t,r,e,u,i=0,o=1,a=h,c=!1;function f(t){return isNaN(t=+t)?u:a(0===r?.5:(t=(e(t)-n)*r,c?Math.max(0,Math.min(1,t)):t))}return f.domain=function(u){return arguments.length?([i,o]=u,n=e(i=+i),t=e(o=+o),r=n===t?0:1/(t-n),f):[i,o]},f.clamp=function(n){return arguments.length?(c=!!n,f):c},f.interpolator=function(n){return arguments.length?(a=n,f):a},f.unknown=function(n){return arguments.length?(u=n,f):u},function(u){return e=u,n=u(i),t=u(o),r=n===t?0:1/(t-n),f}}function V(n,t){return t.domain(n.domain()).interpolator(n.interpolator()).clamp(n.clamp()).unknown(n.unknown())}function X(){var n=Q(K());return n.copy=function(){return V(n,X()).exponent(n.exponent())},a.apply(n,arguments)}function Z(){var n,t,r,e,u,i,o,a=0,c=.5,f=1,l=h,p=!1;function s(n){return isNaN(n=+n)?o:(n=.5+((n=+i(n))-t)*(n<t?e:u),l(p?Math.max(0,Math.min(1,n)):n))}return s.domain=function(o){return arguments.length?([a,c,f]=o,n=i(a=+a),t=i(c=+c),r=i(f=+f),e=n===t?0:.5/(t-n),u=t===r?0:.5/(r-t),s):[a,c,f]},s.clamp=function(n){return arguments.length?(p=!!n,s):p},s.interpolator=function(n){return arguments.length?(l=n,s):l},s.unknown=function(n){return arguments.length?(o=n,s):o},function(o){return i=o,n=o(a),t=o(c),r=o(f),e=n===t?0:.5/(t-n),u=t===r?0:.5/(r-t),s}}function $(){var n=Q(Z());return n.copy=function(){return V(n,$()).exponent(n.exponent())},a.apply(n,arguments)}n.scaleBand=l,n.scalePoint=function(){return function n(t){var r=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return n(r())},t}(l.apply(null,arguments).paddingInner(1))},n.scaleIdentity=function n(t){var r;function e(n){return isNaN(n=+n)?r:n}return e.invert=e,e.domain=e.range=function(n){return arguments.length?(t=Array.from(n,p),e):t.slice()},e.unknown=function(n){return arguments.length?(r=n,e):r},e.copy=function(){return n(t).unknown(r)},t=arguments.length?Array.from(t,p):[0,1],x(e)},n.scaleLinear=function n(){var t=k(h,h);return t.copy=function(){return v(t,n())},o.apply(t,arguments),x(t)},n.scaleLog=function n(){var t=O(M()).domain([1,10]);return t.copy=function(){return v(t,n()).base(t.base())},o.apply(t,arguments),t},n.scaleSymlog=function n(){var t=E(M());return t.copy=function(){return v(t,n()).constant(t.constant())},o.apply(t,arguments)},n.scaleOrdinal=f,n.scaleImplicit=c,n.scalePow=U,n.scaleSqrt=function(){return U.apply(null,arguments).exponent(.5)},n.scaleQuantile=function n(){var r,e=[],u=[],i=[];function a(){var n=0,r=Math.max(1,u.length);for(i=new Array(r-1);++n<r;)i[n-1]=t.quantile(e,n/r);return c}function c(n){return isNaN(n=+n)?r:u[t.bisect(i,n)]}return c.invertExtent=function(n){var t=u.indexOf(n);return t<0?[NaN,NaN]:[t>0?i[t-1]:e[0],t<i.length?i[t]:e[e.length-1]]},c.domain=function(n){if(!arguments.length)return e.slice();e=[];for(let t of n)null==t||isNaN(t=+t)||e.push(t);return e.sort(t.ascending),a()},c.range=function(n){return arguments.length?(u=Array.from(n),a()):u.slice()},c.unknown=function(n){return arguments.length?(r=n,c):r},c.quantiles=function(){return i.slice()},c.copy=function(){return n().domain(e).range(u).unknown(r)},o.apply(c,arguments)},n.scaleQuantize=function n(){var r,e=0,u=1,i=1,a=[.5],c=[0,1];function f(n){return n<=n?c[t.bisect(a,n,0,i)]:r}function l(){var n=-1;for(a=new Array(i);++n<i;)a[n]=((n+1)*u-(n-i)*e)/(i+1);return f}return f.domain=function(n){return arguments.length?([e,u]=n,e=+e,u=+u,l()):[e,u]},f.range=function(n){return arguments.length?(i=(c=Array.from(n)).length-1,l()):c.slice()},f.invertExtent=function(n){var t=c.indexOf(n);return t<0?[NaN,NaN]:t<1?[e,a[0]]:t>=i?[a[i-1],u]:[a[t-1],a[t]]},f.unknown=function(n){return arguments.length?(r=n,f):f},f.thresholds=function(){return a.slice()},f.copy=function(){return n().domain([e,u]).range(c).unknown(r)},o.apply(x(f),arguments)},n.scaleThreshold=function n(){var r,e=[.5],u=[0,1],i=1;function a(n){return n<=n?u[t.bisect(e,n,0,i)]:r}return a.domain=function(n){return arguments.length?(e=Array.from(n),i=Math.min(e.length,u.length-1),a):e.slice()},a.range=function(n){return arguments.length?(u=Array.from(n),i=Math.min(e.length,u.length-1),a):u.slice()},a.invertExtent=function(n){var t=u.indexOf(n);return[e[t-1],e[t]]},a.unknown=function(n){return arguments.length?(r=n,a):r},a.copy=function(){return n().domain(e).range(u).unknown(r)},o.apply(a,arguments)},n.scaleTime=function(){return o.apply(J(u.timeYear,u.timeMonth,u.timeWeek,u.timeDay,u.timeHour,u.timeMinute,u.timeSecond,u.timeMillisecond,i.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},n.scaleUtc=function(){return o.apply(J(u.utcYear,u.utcMonth,u.utcWeek,u.utcDay,u.utcHour,u.utcMinute,u.utcSecond,u.utcMillisecond,i.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},n.scaleSequential=function n(){var t=x(K()(h));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleSequentialLog=function n(){var t=O(K()).domain([1,10]);return t.copy=function(){return V(t,n()).base(t.base())},a.apply(t,arguments)},n.scaleSequentialPow=X,n.scaleSequentialSqrt=function(){return X.apply(null,arguments).exponent(.5)},n.scaleSequentialSymlog=function n(){var t=E(K());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},n.scaleSequentialQuantile=function n(){var r=[],e=h;function u(n){if(!isNaN(n=+n))return e((t.bisect(r,n)-1)/(r.length-1))}return u.domain=function(n){if(!arguments.length)return r.slice();r=[];for(let t of n)null==t||isNaN(t=+t)||r.push(t);return r.sort(t.ascending),u},u.interpolator=function(n){return arguments.length?(e=n,u):e},u.copy=function(){return n(e).domain(r)},a.apply(u,arguments)},n.scaleDiverging=function n(){var t=x(Z()(h));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleDivergingLog=function n(){var t=O(Z()).domain([.1,1,10]);return t.copy=function(){return V(t,n()).base(t.base())},a.apply(t,arguments)},n.scaleDivergingPow=$,n.scaleDivergingSqrt=function(){return $.apply(null,arguments).exponent(.5)},n.scaleDivergingSymlog=function n(){var t=E(Z());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},n.tickFormat=w,Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-scale", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Encodings that map abstract data to visual representation.", | ||
@@ -25,2 +25,6 @@ "keywords": [ | ||
}, | ||
"files": [ | ||
"dist/**/*.js", | ||
"src/**/*.js" | ||
], | ||
"scripts": { | ||
@@ -33,3 +37,3 @@ "pretest": "rollup -c", | ||
"dependencies": { | ||
"d3-array": "^1.2.0 || 2", | ||
"d3-array": "1.2.0 - 2", | ||
"d3-format": "1", | ||
@@ -36,0 +40,0 @@ "d3-interpolate": "1", |
@@ -69,3 +69,3 @@ import {bisector, tickStep} from "d3-array"; | ||
function tickInterval(interval, start, stop, step) { | ||
function tickInterval(interval, start, stop) { | ||
if (interval == null) interval = 10; | ||
@@ -78,3 +78,4 @@ | ||
var target = Math.abs(stop - start) / interval, | ||
i = bisector(function(i) { return i[2]; }).right(tickIntervals, target); | ||
i = bisector(function(i) { return i[2]; }).right(tickIntervals, target), | ||
step; | ||
if (i === tickIntervals.length) { | ||
@@ -91,5 +92,6 @@ step = tickStep(start / durationYear, stop / durationYear, interval); | ||
} | ||
return interval.every(step); | ||
} | ||
return step == null ? interval : interval.every(step); | ||
return interval; | ||
} | ||
@@ -105,3 +107,3 @@ | ||
scale.ticks = function(interval, step) { | ||
scale.ticks = function(interval) { | ||
var d = domain(), | ||
@@ -113,3 +115,3 @@ t0 = d[0], | ||
if (r) t = t0, t0 = t1, t1 = t; | ||
t = tickInterval(interval, t0, t1, step); | ||
t = tickInterval(interval, t0, t1); | ||
t = t ? t.range(t0, t1 + 1) : []; // inclusive stop | ||
@@ -123,5 +125,5 @@ return r ? t.reverse() : t; | ||
scale.nice = function(interval, step) { | ||
scale.nice = function(interval) { | ||
var d = domain(); | ||
return (interval = tickInterval(interval, d[0], d[d.length - 1], step)) | ||
return (interval = tickInterval(interval, d[0], d[d.length - 1])) | ||
? domain(nice(d, interval)) | ||
@@ -128,0 +130,0 @@ : scale; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
956
167565
28
2031
Updatedd3-array@1.2.0 - 2