Comparing version 3.0.1 to 3.1.0
@@ -1,7 +0,7 @@ | ||
// https://d3js.org/d3-scale/ v3.0.1 Copyright 2019 Mike Bostock | ||
// https://d3js.org/d3-scale/ v3.1.0 Copyright 2019 Mike Bostock | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-interpolate'), require('d3-format'), require('d3-time'), require('d3-time-format')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-interpolate', 'd3-format', 'd3-time', 'd3-time-format'], factory) : | ||
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3)); | ||
}(this, (function (exports,d3Array,d3Interpolate,d3Format,d3Time,d3TimeFormat) { 'use strict'; | ||
(global = global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3, global.d3, global.d3, global.d3)); | ||
}(this, function (exports, d3Array, d3Interpolate, d3Format, d3Time, d3TimeFormat) { 'use strict'; | ||
@@ -191,4 +191,4 @@ function initRange(domain, range) { | ||
function clamper(domain) { | ||
var a = domain[0], b = domain[domain.length - 1], t; | ||
function clamper(a, b) { | ||
var t; | ||
if (a > b) t = a, a = b, b = t; | ||
@@ -252,3 +252,5 @@ return function(x) { return Math.max(a, Math.min(b, x)); }; | ||
function rescale() { | ||
piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap; | ||
var n = Math.min(domain.length, range.length); | ||
if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); | ||
piecewise = n > 2 ? polymap : bimap; | ||
output = input = null; | ||
@@ -267,3 +269,3 @@ return scale; | ||
scale.domain = function(_) { | ||
return arguments.length ? (domain = Array.from(_, number), clamp === identity || (clamp = clamper(domain)), rescale()) : domain.slice(); | ||
return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice(); | ||
}; | ||
@@ -280,3 +282,3 @@ | ||
scale.clamp = function(_) { | ||
return arguments.length ? (clamp = _ ? clamper(domain) : identity, scale) : clamp !== identity; | ||
return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; | ||
}; | ||
@@ -298,4 +300,4 @@ | ||
function continuous(transform, untransform) { | ||
return transformer()(transform, untransform); | ||
function continuous() { | ||
return transformer()(identity, identity); | ||
} | ||
@@ -387,3 +389,3 @@ | ||
function linear() { | ||
var scale = continuous(identity, identity); | ||
var scale = continuous(); | ||
@@ -526,4 +528,4 @@ scale.copy = function() { | ||
if (!(base % 1) && j - i < n) { | ||
i = Math.round(i) - 1, j = Math.round(j) + 1; | ||
if (u > 0) for (; i < j; ++i) { | ||
i = Math.floor(i), j = Math.ceil(j); | ||
if (u > 0) for (; i <= j; ++i) { | ||
for (k = 1, p = pows(i); k < base; ++k) { | ||
@@ -535,3 +537,3 @@ t = p * k; | ||
} | ||
} else for (; i < j; ++i) { | ||
} else for (; i <= j; ++i) { | ||
for (k = base - 1, p = pows(i); k >= 1; --k) { | ||
@@ -544,2 +546,3 @@ t = p * k; | ||
} | ||
if (!z.length) z = d3Array.ticks(u, v, n); | ||
} else { | ||
@@ -666,2 +669,61 @@ z = d3Array.ticks(i, j, Math.min(j - i, n)).map(pows); | ||
function square(x) { | ||
return Math.sign(x) * x * x; | ||
} | ||
function unsquare(x) { | ||
return Math.sign(x) * Math.sqrt(Math.abs(x)); | ||
} | ||
function radial() { | ||
var squared = continuous(), | ||
range = [0, 1], | ||
round = false, | ||
unknown; | ||
function scale(x) { | ||
var y = unsquare(squared(x)); | ||
return isNaN(y) ? unknown : round ? Math.round(y) : y; | ||
} | ||
scale.invert = function(y) { | ||
return squared.invert(square(y)); | ||
}; | ||
scale.domain = function(_) { | ||
return arguments.length ? (squared.domain(_), scale) : squared.domain(); | ||
}; | ||
scale.range = function(_) { | ||
return arguments.length ? (squared.range((range = Array.from(_, number)).map(square)), scale) : range.slice(); | ||
}; | ||
scale.rangeRound = function(_) { | ||
return scale.range(_).round(true); | ||
}; | ||
scale.round = function(_) { | ||
return arguments.length ? (round = !!_, scale) : round; | ||
}; | ||
scale.clamp = function(_) { | ||
return arguments.length ? (squared.clamp(_), scale) : squared.clamp(); | ||
}; | ||
scale.unknown = function(_) { | ||
return arguments.length ? (unknown = _, scale) : unknown; | ||
}; | ||
scale.copy = function() { | ||
return radial(squared.domain(), range) | ||
.round(round) | ||
.clamp(squared.clamp()) | ||
.unknown(unknown); | ||
}; | ||
initRange.apply(scale, arguments); | ||
return linearish(scale); | ||
} | ||
function quantile() { | ||
@@ -829,3 +891,3 @@ var domain = [], | ||
function calendar(year, month, week, day, hour, minute, second, millisecond, format) { | ||
var scale = continuous(identity, identity), | ||
var scale = continuous(), | ||
invert = scale.invert, | ||
@@ -974,2 +1036,6 @@ domain = scale.domain; | ||
scale.range = function() { | ||
return [interpolator(0), interpolator(1)]; | ||
}; | ||
scale.unknown = function(_) { | ||
@@ -1042,3 +1108,3 @@ return arguments.length ? (unknown = _, scale) : unknown; | ||
function scale(x) { | ||
if (!isNaN(x = +x)) return interpolator((d3Array.bisect(domain, x) - 1) / (domain.length - 1)); | ||
if (!isNaN(x = +x)) return interpolator((d3Array.bisect(domain, x, 1) - 1) / (domain.length - 1)); | ||
} | ||
@@ -1058,2 +1124,6 @@ | ||
scale.range = function() { | ||
return domain.map((d, i) => interpolator(i / (domain.length - 1))); | ||
}; | ||
scale.copy = function() { | ||
@@ -1070,2 +1140,3 @@ return sequentialQuantile(interpolator).domain(domain); | ||
x2 = 1, | ||
s = 1, | ||
t0, | ||
@@ -1082,7 +1153,7 @@ t1, | ||
function scale(x) { | ||
return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (x < t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); | ||
return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (s * x < s * t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); | ||
} | ||
scale.domain = function(_) { | ||
return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), scale) : [x0, x1, x2]; | ||
return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1, scale) : [x0, x1, x2]; | ||
}; | ||
@@ -1098,2 +1169,6 @@ | ||
scale.range = function() { | ||
return [interpolator(0), interpolator(0.5), interpolator(1)]; | ||
}; | ||
scale.unknown = function(_) { | ||
@@ -1104,3 +1179,3 @@ return arguments.length ? (unknown = _, scale) : unknown; | ||
return function(t) { | ||
transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1); | ||
transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1; | ||
return scale; | ||
@@ -1155,27 +1230,28 @@ }; | ||
exports.scaleBand = band; | ||
exports.scalePoint = point; | ||
exports.scaleDiverging = diverging; | ||
exports.scaleDivergingLog = divergingLog; | ||
exports.scaleDivergingPow = divergingPow; | ||
exports.scaleDivergingSqrt = divergingSqrt; | ||
exports.scaleDivergingSymlog = divergingSymlog; | ||
exports.scaleIdentity = identity$1; | ||
exports.scaleImplicit = implicit; | ||
exports.scaleLinear = linear; | ||
exports.scaleLog = log; | ||
exports.scaleSymlog = symlog; | ||
exports.scaleOrdinal = ordinal; | ||
exports.scaleImplicit = implicit; | ||
exports.scalePoint = point; | ||
exports.scalePow = pow; | ||
exports.scaleSqrt = sqrt; | ||
exports.scaleQuantile = quantile; | ||
exports.scaleQuantize = quantize; | ||
exports.scaleThreshold = threshold; | ||
exports.scaleTime = time; | ||
exports.scaleUtc = utcTime; | ||
exports.scaleRadial = radial; | ||
exports.scaleSequential = sequential; | ||
exports.scaleSequentialLog = sequentialLog; | ||
exports.scaleSequentialPow = sequentialPow; | ||
exports.scaleSequentialQuantile = sequentialQuantile; | ||
exports.scaleSequentialSqrt = sequentialSqrt; | ||
exports.scaleSequentialSymlog = sequentialSymlog; | ||
exports.scaleSequentialQuantile = sequentialQuantile; | ||
exports.scaleDiverging = diverging; | ||
exports.scaleDivergingLog = divergingLog; | ||
exports.scaleDivergingPow = divergingPow; | ||
exports.scaleDivergingSqrt = divergingSqrt; | ||
exports.scaleDivergingSymlog = divergingSymlog; | ||
exports.scaleSqrt = sqrt; | ||
exports.scaleSymlog = symlog; | ||
exports.scaleThreshold = threshold; | ||
exports.scaleTime = time; | ||
exports.scaleUtc = utcTime; | ||
exports.tickFormat = tickFormat; | ||
@@ -1185,2 +1261,2 @@ | ||
}))); | ||
})); |
@@ -1,2 +0,2 @@ | ||
// 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})}); | ||
// https://d3js.org/d3-scale/ v3.1.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=n||self).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,h=0,s=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-h+2*s),p&&(n=Math.floor(n)),f+=(l-f-n*(e-h))*g,r=n*(1-h),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?(h=Math.min(1,s=+n),m()):h},e.paddingInner=function(n){return arguments.length?(h=Math.min(1,n),m()):h},e.paddingOuter=function(n){return arguments.length?(s=+n,m()):s},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(h).paddingOuter(s).align(g)},o.apply(m(),arguments)}function p(n){return+n}var h=[0,1];function s(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,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 d(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 y(n,t){return t.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function v(){var n,t,e,u,i,o,a=h,c=h,f=r.interpolate,l=s;function g(){var n,t,r,e=Math.min(a.length,c.length);return l!==s&&(n=a[0],t=a[e-1],n>t&&(r=n,n=t,t=r),l=function(r){return Math.max(n,Math.min(t,r))}),u=e>2?d:m,i=o=null,y}function y(t){return isNaN(t=+t)?e:(i||(i=u(a.map(n),c,f)))(n(l(t)))}return y.invert=function(e){return l(t((o||(o=u(c,a.map(n),r.interpolateNumber)))(e)))},y.domain=function(n){return arguments.length?(a=Array.from(n,p),g()):a.slice()},y.range=function(n){return arguments.length?(c=Array.from(n),g()):c.slice()},y.rangeRound=function(n){return c=Array.from(n),f=r.interpolateRound,g()},y.clamp=function(n){return arguments.length?(l=!!n||s,g()):l!==s},y.interpolate=function(n){return arguments.length?(f=n,g()):f},y.unknown=function(n){return arguments.length?(e=n,y):e},function(r,e){return n=r,t=e,g()}}function M(){return v()(s,s)}function k(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 w(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 k(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 x(n){return Math.log(n)}function b(n){return Math.exp(n)}function S(n){return-Math.log(-n)}function q(n){return-Math.exp(-n)}function A(n){return isFinite(n)?+("1e"+n):n<0?0:n}function D(n){return function(t){return-n(-t)}}function I(n){var r,u,i=n(x,b),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?A:n===Math.E?Math.exp:function(t){return Math.pow(n,t)}}(a),o()[0]<0?(r=D(r),u=D(u),n(S,q)):n(x,b),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)&&(s=c,c=f,f=s);var l,p,h,s=r(c),g=r(f),m=null==n?10:+n,d=[];if(!(a%1)&&g-s<m){if(s=Math.floor(s),g=Math.ceil(g),c>0){for(;s<=g;++s)for(p=1,l=u(s);p<a;++p)if(!((h=l*p)<c)){if(h>f)break;d.push(h)}}else for(;s<=g;++s)for(p=a-1,l=u(s);p>=1;--p)if(!((h=l*p)<c)){if(h>f)break;d.push(h)}d.length||(d=t.ticks(c,f,m))}else d=t.ticks(s,g,Math.min(g-s,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 O(n){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/n))}}function F(n){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*n}}function P(n){var t=1,r=n(O(t),F(t));return r.constant=function(r){return arguments.length?n(O(t=+r),F(t)):t},w(r)}function R(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function E(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function L(n){return n<0?-n*n:n*n}function T(n){var t=n(s,s),r=1;function e(){return 1===r?n(s,s):.5===r?n(E,L):n(R(r),R(1/r))}return t.exponent=function(n){return arguments.length?(r=+n,e()):r},w(t)}function Q(){var n=T(v());return n.copy=function(){return y(n,Q()).exponent(n.exponent())},o.apply(n,arguments),n}function U(n){return Math.sign(n)*n*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=M(),p=l.invert,h=l.domain,s=f(".%L"),g=f(":%S"),m=f("%I:%M"),d=f("%I %p"),v=f("%a %d"),k=f("%b %d"),w=f("%B"),x=f("%Y"),b=[[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 S(t){return(a(t)<t?s:o(t)<t?g:i(t)<t?m:u(t)<t?d:r(t)<t?e(t)<t?v:k:n(t)<t?w:x)(t)}function q(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(b,o);return a===b.length?(i=t.tickStep(e/_,u/_,r),r=n):a?(i=(a=b[o/b[a-1][2]<b[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?h(Array.from(n,G)):h().map(z)},l.ticks=function(n){var t,r=h(),e=r[0],u=r[r.length-1],i=u<e;return i&&(t=e,e=u,u=t),t=(t=q(n,e,u))?t.range(e,u+1):[],i?t.reverse():t},l.tickFormat=function(n,t){return null==t?S:f(t)},l.nice=function(n){var t=h();return(n=q(n,t[0],t[t.length-1]))?h(N(t,n)):l},l.copy=function(){return y(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=s,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.range=function(){return[a(0),a(1)]},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=T(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=1,p=s,h=!1;function g(n){return isNaN(n=+n)?o:(n=.5+((n=+i(n))-t)*(l*n<l*t?e:u),p(h?Math.max(0,Math.min(1,n)):n))}return g.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),l=t<n?-1:1,g):[a,c,f]},g.clamp=function(n){return arguments.length?(h=!!n,g):h},g.interpolator=function(n){return arguments.length?(p=n,g):p},g.range=function(){return[p(0),p(.5),p(1)]},g.unknown=function(n){return arguments.length?(o=n,g):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),l=t<n?-1:1,g}}function $(){var n=T(Z());return n.copy=function(){return V(n,$()).exponent(n.exponent())},a.apply(n,arguments)}n.scaleBand=l,n.scaleDiverging=function n(){var t=w(Z()(s));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleDivergingLog=function n(){var t=I(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=P(Z());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},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],w(e)},n.scaleImplicit=c,n.scaleLinear=function n(){var t=M();return t.copy=function(){return y(t,n())},o.apply(t,arguments),w(t)},n.scaleLog=function n(){var t=I(v()).domain([1,10]);return t.copy=function(){return y(t,n()).base(t.base())},o.apply(t,arguments),t},n.scaleOrdinal=f,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.scalePow=Q,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(w(f),arguments)},n.scaleRadial=function n(){var t,r=M(),e=[0,1],u=!1;function i(n){var e=function(n){return Math.sign(n)*Math.sqrt(Math.abs(n))}(r(n));return isNaN(e)?t:u?Math.round(e):e}return i.invert=function(n){return r.invert(U(n))},i.domain=function(n){return arguments.length?(r.domain(n),i):r.domain()},i.range=function(n){return arguments.length?(r.range((e=Array.from(n,p)).map(U)),i):e.slice()},i.rangeRound=function(n){return i.range(n).round(!0)},i.round=function(n){return arguments.length?(u=!!n,i):u},i.clamp=function(n){return arguments.length?(r.clamp(n),i):r.clamp()},i.unknown=function(n){return arguments.length?(t=n,i):t},i.copy=function(){return n(r.domain(),e).round(u).clamp(r.clamp()).unknown(t)},o.apply(i,arguments),w(i)},n.scaleSequential=function n(){var t=w(K()(s));return t.copy=function(){return V(t,n())},a.apply(t,arguments)},n.scaleSequentialLog=function n(){var t=I(K()).domain([1,10]);return t.copy=function(){return V(t,n()).base(t.base())},a.apply(t,arguments)},n.scaleSequentialPow=X,n.scaleSequentialQuantile=function n(){var r=[],e=s;function u(n){if(!isNaN(n=+n))return e((t.bisect(r,n,1)-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.range=function(){return r.map((n,t)=>e(t/(r.length-1)))},u.copy=function(){return n(e).domain(r)},a.apply(u,arguments)},n.scaleSequentialSqrt=function(){return X.apply(null,arguments).exponent(.5)},n.scaleSequentialSymlog=function n(){var t=P(K());return t.copy=function(){return V(t,n()).constant(t.constant())},a.apply(t,arguments)},n.scaleSqrt=function(){return Q.apply(null,arguments).exponent(.5)},n.scaleSymlog=function n(){var t=P(v());return t.copy=function(){return y(t,n()).constant(t.constant())},o.apply(t,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.tickFormat=k,Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-scale", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Encodings that map abstract data to visual representation.", | ||
@@ -35,2 +35,3 @@ "keywords": [ | ||
}, | ||
"sideEffects": false, | ||
"dependencies": { | ||
@@ -45,7 +46,7 @@ "d3-array": "1.2.0 - 2", | ||
"d3-color": "1", | ||
"eslint": "5", | ||
"rollup": "0.64", | ||
"rollup-plugin-terser": "1", | ||
"eslint": "6", | ||
"rollup": "1", | ||
"rollup-plugin-terser": "5", | ||
"tape": "4" | ||
} | ||
} |
import {range as sequence} from "d3-array"; | ||
import {initRange} from "./init"; | ||
import ordinal from "./ordinal"; | ||
import {initRange} from "./init.js"; | ||
import ordinal from "./ordinal.js"; | ||
@@ -5,0 +5,0 @@ export default function band() { |
import {bisect} from "d3-array"; | ||
import {interpolate as interpolateValue, interpolateNumber, interpolateRound} from "d3-interpolate"; | ||
import constant from "./constant"; | ||
import number from "./number"; | ||
import constant from "./constant.js"; | ||
import number from "./number.js"; | ||
@@ -18,4 +18,4 @@ var unit = [0, 1]; | ||
function clamper(domain) { | ||
var a = domain[0], b = domain[domain.length - 1], t; | ||
function clamper(a, b) { | ||
var t; | ||
if (a > b) t = a, a = b, b = t; | ||
@@ -79,3 +79,5 @@ return function(x) { return Math.max(a, Math.min(b, x)); }; | ||
function rescale() { | ||
piecewise = Math.min(domain.length, range.length) > 2 ? polymap : bimap; | ||
var n = Math.min(domain.length, range.length); | ||
if (clamp !== identity) clamp = clamper(domain[0], domain[n - 1]); | ||
piecewise = n > 2 ? polymap : bimap; | ||
output = input = null; | ||
@@ -94,3 +96,3 @@ return scale; | ||
scale.domain = function(_) { | ||
return arguments.length ? (domain = Array.from(_, number), clamp === identity || (clamp = clamper(domain)), rescale()) : domain.slice(); | ||
return arguments.length ? (domain = Array.from(_, number), rescale()) : domain.slice(); | ||
}; | ||
@@ -107,3 +109,3 @@ | ||
scale.clamp = function(_) { | ||
return arguments.length ? (clamp = _ ? clamper(domain) : identity, scale) : clamp !== identity; | ||
return arguments.length ? (clamp = _ ? true : identity, rescale()) : clamp !== identity; | ||
}; | ||
@@ -125,4 +127,4 @@ | ||
export default function continuous(transform, untransform) { | ||
return transformer()(transform, untransform); | ||
export default function continuous() { | ||
return transformer()(identity, identity); | ||
} |
@@ -1,8 +0,8 @@ | ||
import {identity} from "./continuous"; | ||
import {initInterpolator} from "./init"; | ||
import {linearish} from "./linear"; | ||
import {loggish} from "./log"; | ||
import {copy} from "./sequential"; | ||
import {symlogish} from "./symlog"; | ||
import {powish} from "./pow"; | ||
import {identity} from "./continuous.js"; | ||
import {initInterpolator} from "./init.js"; | ||
import {linearish} from "./linear.js"; | ||
import {loggish} from "./log.js"; | ||
import {copy} from "./sequential.js"; | ||
import {symlogish} from "./symlog.js"; | ||
import {powish} from "./pow.js"; | ||
@@ -13,2 +13,3 @@ function transformer() { | ||
x2 = 1, | ||
s = 1, | ||
t0, | ||
@@ -25,7 +26,7 @@ t1, | ||
function scale(x) { | ||
return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (x < t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); | ||
return isNaN(x = +x) ? unknown : (x = 0.5 + ((x = +transform(x)) - t1) * (s * x < s * t1 ? k10 : k21), interpolator(clamp ? Math.max(0, Math.min(1, x)) : x)); | ||
} | ||
scale.domain = function(_) { | ||
return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), scale) : [x0, x1, x2]; | ||
return arguments.length ? ([x0, x1, x2] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), t2 = transform(x2 = +x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1, scale) : [x0, x1, x2]; | ||
}; | ||
@@ -41,2 +42,6 @@ | ||
scale.range = function() { | ||
return [interpolator(0), interpolator(0.5), interpolator(1)]; | ||
}; | ||
scale.unknown = function(_) { | ||
@@ -47,3 +52,3 @@ return arguments.length ? (unknown = _, scale) : unknown; | ||
return function(t) { | ||
transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1); | ||
transform = t, t0 = t(x0), t1 = t(x1), t2 = t(x2), k10 = t0 === t1 ? 0 : 0.5 / (t1 - t0), k21 = t1 === t2 ? 0 : 0.5 / (t2 - t1), s = t1 < t0 ? -1 : 1; | ||
return scale; | ||
@@ -50,0 +55,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
import {linearish} from "./linear"; | ||
import number from "./number"; | ||
import {linearish} from "./linear.js"; | ||
import number from "./number.js"; | ||
@@ -4,0 +4,0 @@ export default function identity(domain) { |
export { | ||
default as scaleBand, | ||
point as scalePoint | ||
} from "./band"; | ||
} from "./band.js"; | ||
export { | ||
default as scaleIdentity | ||
} from "./identity"; | ||
} from "./identity.js"; | ||
export { | ||
default as scaleLinear | ||
} from "./linear"; | ||
} from "./linear.js"; | ||
export { | ||
default as scaleLog | ||
} from "./log"; | ||
} from "./log.js"; | ||
export { | ||
default as scaleSymlog | ||
} from "./symlog"; | ||
} from "./symlog.js"; | ||
@@ -25,3 +25,3 @@ export { | ||
implicit as scaleImplicit | ||
} from "./ordinal"; | ||
} from "./ordinal.js"; | ||
@@ -31,23 +31,27 @@ export { | ||
sqrt as scaleSqrt | ||
} from "./pow"; | ||
} from "./pow.js"; | ||
export { | ||
default as scaleRadial | ||
} from "./radial.js"; | ||
export { | ||
default as scaleQuantile | ||
} from "./quantile"; | ||
} from "./quantile.js"; | ||
export { | ||
default as scaleQuantize | ||
} from "./quantize"; | ||
} from "./quantize.js"; | ||
export { | ||
default as scaleThreshold | ||
} from "./threshold"; | ||
} from "./threshold.js"; | ||
export { | ||
default as scaleTime | ||
} from "./time"; | ||
} from "./time.js"; | ||
export { | ||
default as scaleUtc | ||
} from "./utcTime"; | ||
} from "./utcTime.js"; | ||
@@ -60,7 +64,7 @@ export { | ||
sequentialSymlog as scaleSequentialSymlog | ||
} from "./sequential"; | ||
} from "./sequential.js"; | ||
export { | ||
default as scaleSequentialQuantile | ||
} from "./sequentialQuantile"; | ||
} from "./sequentialQuantile.js"; | ||
@@ -73,6 +77,6 @@ export { | ||
divergingSymlog as scaleDivergingSymlog | ||
} from "./diverging"; | ||
} from "./diverging.js"; | ||
export { | ||
default as tickFormat | ||
} from "./tickFormat"; | ||
} from "./tickFormat.js"; |
import {ticks, tickIncrement} from "d3-array"; | ||
import continuous, {copy, identity} from "./continuous"; | ||
import {initRange} from "./init"; | ||
import tickFormat from "./tickFormat"; | ||
import continuous, {copy} from "./continuous.js"; | ||
import {initRange} from "./init.js"; | ||
import tickFormat from "./tickFormat.js"; | ||
@@ -63,3 +63,3 @@ export function linearish(scale) { | ||
export default function linear() { | ||
var scale = continuous(identity, identity); | ||
var scale = continuous(); | ||
@@ -66,0 +66,0 @@ scale.copy = function() { |
import {ticks} from "d3-array"; | ||
import {format} from "d3-format"; | ||
import nice from "./nice"; | ||
import {copy, transformer} from "./continuous"; | ||
import {initRange} from "./init"; | ||
import nice from "./nice.js"; | ||
import {copy, transformer} from "./continuous.js"; | ||
import {initRange} from "./init.js"; | ||
@@ -89,4 +89,4 @@ function transformLog(x) { | ||
if (!(base % 1) && j - i < n) { | ||
i = Math.round(i) - 1, j = Math.round(j) + 1; | ||
if (u > 0) for (; i < j; ++i) { | ||
i = Math.floor(i), j = Math.ceil(j); | ||
if (u > 0) for (; i <= j; ++i) { | ||
for (k = 1, p = pows(i); k < base; ++k) { | ||
@@ -98,3 +98,3 @@ t = p * k; | ||
} | ||
} else for (; i < j; ++i) { | ||
} else for (; i <= j; ++i) { | ||
for (k = base - 1, p = pows(i); k >= 1; --k) { | ||
@@ -107,2 +107,3 @@ t = p * k; | ||
} | ||
if (!z.length) z = ticks(u, v, n); | ||
} else { | ||
@@ -109,0 +110,0 @@ z = ticks(i, j, Math.min(j - i, n)).map(pows); |
@@ -1,2 +0,2 @@ | ||
import {initRange} from "./init"; | ||
import {initRange} from "./init.js"; | ||
@@ -3,0 +3,0 @@ export const implicit = Symbol("implicit"); |
@@ -1,4 +0,4 @@ | ||
import {linearish} from "./linear"; | ||
import {copy, identity, transformer} from "./continuous"; | ||
import {initRange} from "./init"; | ||
import {linearish} from "./linear.js"; | ||
import {copy, identity, transformer} from "./continuous.js"; | ||
import {initRange} from "./init.js"; | ||
@@ -5,0 +5,0 @@ function transformPow(exponent) { |
import {ascending, bisect, quantile as threshold} from "d3-array"; | ||
import {initRange} from "./init"; | ||
import {initRange} from "./init.js"; | ||
@@ -4,0 +4,0 @@ export default function quantile() { |
import {bisect} from "d3-array"; | ||
import {linearish} from "./linear"; | ||
import {initRange} from "./init"; | ||
import {linearish} from "./linear.js"; | ||
import {initRange} from "./init.js"; | ||
@@ -5,0 +5,0 @@ export default function quantize() { |
@@ -1,7 +0,7 @@ | ||
import {identity} from "./continuous"; | ||
import {initInterpolator} from "./init"; | ||
import {linearish} from "./linear"; | ||
import {loggish} from "./log"; | ||
import {symlogish} from "./symlog"; | ||
import {powish} from "./pow"; | ||
import {identity} from "./continuous.js"; | ||
import {initInterpolator} from "./init.js"; | ||
import {linearish} from "./linear.js"; | ||
import {loggish} from "./log.js"; | ||
import {symlogish} from "./symlog.js"; | ||
import {powish} from "./pow.js"; | ||
@@ -35,2 +35,6 @@ function transformer() { | ||
scale.range = function() { | ||
return [interpolator(0), interpolator(1)]; | ||
}; | ||
scale.unknown = function(_) { | ||
@@ -37,0 +41,0 @@ return arguments.length ? (unknown = _, scale) : unknown; |
import {ascending, bisect} from "d3-array"; | ||
import {identity} from "./continuous"; | ||
import {initInterpolator} from "./init"; | ||
import {identity} from "./continuous.js"; | ||
import {initInterpolator} from "./init.js"; | ||
@@ -10,3 +10,3 @@ export default function sequentialQuantile() { | ||
function scale(x) { | ||
if (!isNaN(x = +x)) return interpolator((bisect(domain, x) - 1) / (domain.length - 1)); | ||
if (!isNaN(x = +x)) return interpolator((bisect(domain, x, 1) - 1) / (domain.length - 1)); | ||
} | ||
@@ -26,2 +26,6 @@ | ||
scale.range = function() { | ||
return domain.map((d, i) => interpolator(i / (domain.length - 1))); | ||
}; | ||
scale.copy = function() { | ||
@@ -28,0 +32,0 @@ return sequentialQuantile(interpolator).domain(domain); |
@@ -1,4 +0,4 @@ | ||
import {linearish} from "./linear"; | ||
import {copy, transformer} from "./continuous"; | ||
import {initRange} from "./init"; | ||
import {linearish} from "./linear.js"; | ||
import {copy, transformer} from "./continuous.js"; | ||
import {initRange} from "./init.js"; | ||
@@ -5,0 +5,0 @@ function transformSymlog(c) { |
import {bisect} from "d3-array"; | ||
import {initRange} from "./init"; | ||
import {initRange} from "./init.js"; | ||
@@ -4,0 +4,0 @@ export default function threshold() { |
import {bisector, tickStep} from "d3-array"; | ||
import {timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeMillisecond} from "d3-time"; | ||
import {timeFormat} from "d3-time-format"; | ||
import continuous, {copy, identity} from "./continuous"; | ||
import {initRange} from "./init"; | ||
import nice from "./nice"; | ||
import continuous, {copy} from "./continuous.js"; | ||
import {initRange} from "./init.js"; | ||
import nice from "./nice.js"; | ||
@@ -25,3 +25,3 @@ var durationSecond = 1000, | ||
export function calendar(year, month, week, day, hour, minute, second, millisecond, format) { | ||
var scale = continuous(identity, identity), | ||
var scale = continuous(), | ||
invert = scale.invert, | ||
@@ -28,0 +28,0 @@ domain = scale.domain; |
@@ -1,5 +0,5 @@ | ||
import {calendar} from "./time"; | ||
import {calendar} from "./time.js"; | ||
import {utcFormat} from "d3-time-format"; | ||
import {utcYear, utcMonth, utcWeek, utcDay, utcHour, utcMinute, utcSecond, utcMillisecond} from "d3-time"; | ||
import {initRange} from "./init"; | ||
import {initRange} from "./init.js"; | ||
@@ -6,0 +6,0 @@ export default function() { |
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
173146
29
2159
964