You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
926 lines
31 KiB
926 lines
31 KiB
// https://d3js.org/d3-scale/ Version 1.0.7. Copyright 2017 Mike Bostock.
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-collection'), require('d3-interpolate'), require('d3-format'), require('d3-time'), require('d3-time-format'), require('d3-color')) :
|
|
typeof define === 'function' && define.amd ? define(['exports', 'd3-array', 'd3-collection', 'd3-interpolate', 'd3-format', 'd3-time', 'd3-time-format', 'd3-color'], factory) :
|
|
(factory((global.d3 = global.d3 || {}),global.d3,global.d3,global.d3,global.d3,global.d3,global.d3,global.d3));
|
|
}(this, (function (exports,d3Array,d3Collection,d3Interpolate,d3Format,d3Time,d3TimeFormat,d3Color) { 'use strict';
|
|
|
|
var array = Array.prototype;
|
|
|
|
var map$1 = array.map;
|
|
var slice = array.slice;
|
|
|
|
var implicit = {name: "implicit"};
|
|
|
|
function ordinal(range$$1) {
|
|
var index = d3Collection.map(),
|
|
domain = [],
|
|
unknown = implicit;
|
|
|
|
range$$1 = range$$1 == null ? [] : slice.call(range$$1);
|
|
|
|
function scale(d) {
|
|
var key = d + "", i = index.get(key);
|
|
if (!i) {
|
|
if (unknown !== implicit) return unknown;
|
|
index.set(key, i = domain.push(d));
|
|
}
|
|
return range$$1[(i - 1) % range$$1.length];
|
|
}
|
|
|
|
scale.domain = function(_) {
|
|
if (!arguments.length) return domain.slice();
|
|
domain = [], index = d3Collection.map();
|
|
var i = -1, n = _.length, d, key;
|
|
while (++i < n) if (!index.has(key = (d = _[i]) + "")) index.set(key, domain.push(d));
|
|
return scale;
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (range$$1 = slice.call(_), scale) : range$$1.slice();
|
|
};
|
|
|
|
scale.unknown = function(_) {
|
|
return arguments.length ? (unknown = _, scale) : unknown;
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return ordinal()
|
|
.domain(domain)
|
|
.range(range$$1)
|
|
.unknown(unknown);
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
function band() {
|
|
var scale = ordinal().unknown(undefined),
|
|
domain = scale.domain,
|
|
ordinalRange = scale.range,
|
|
range$$1 = [0, 1],
|
|
step,
|
|
bandwidth,
|
|
round = false,
|
|
paddingInner = 0,
|
|
paddingOuter = 0,
|
|
align = 0.5;
|
|
|
|
delete scale.unknown;
|
|
|
|
function rescale() {
|
|
var n = domain().length,
|
|
reverse = range$$1[1] < range$$1[0],
|
|
start = range$$1[reverse - 0],
|
|
stop = range$$1[1 - reverse];
|
|
step = (stop - start) / Math.max(1, n - paddingInner + paddingOuter * 2);
|
|
if (round) step = Math.floor(step);
|
|
start += (stop - start - step * (n - paddingInner)) * align;
|
|
bandwidth = step * (1 - paddingInner);
|
|
if (round) start = Math.round(start), bandwidth = Math.round(bandwidth);
|
|
var values = d3Array.range(n).map(function(i) { return start + step * i; });
|
|
return ordinalRange(reverse ? values.reverse() : values);
|
|
}
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (domain(_), rescale()) : domain();
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (range$$1 = [+_[0], +_[1]], rescale()) : range$$1.slice();
|
|
};
|
|
|
|
scale.rangeRound = function(_) {
|
|
return range$$1 = [+_[0], +_[1]], round = true, rescale();
|
|
};
|
|
|
|
scale.bandwidth = function() {
|
|
return bandwidth;
|
|
};
|
|
|
|
scale.step = function() {
|
|
return step;
|
|
};
|
|
|
|
scale.round = function(_) {
|
|
return arguments.length ? (round = !!_, rescale()) : round;
|
|
};
|
|
|
|
scale.padding = function(_) {
|
|
return arguments.length ? (paddingInner = paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
|
|
};
|
|
|
|
scale.paddingInner = function(_) {
|
|
return arguments.length ? (paddingInner = Math.max(0, Math.min(1, _)), rescale()) : paddingInner;
|
|
};
|
|
|
|
scale.paddingOuter = function(_) {
|
|
return arguments.length ? (paddingOuter = Math.max(0, Math.min(1, _)), rescale()) : paddingOuter;
|
|
};
|
|
|
|
scale.align = function(_) {
|
|
return arguments.length ? (align = Math.max(0, Math.min(1, _)), rescale()) : align;
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return band()
|
|
.domain(domain())
|
|
.range(range$$1)
|
|
.round(round)
|
|
.paddingInner(paddingInner)
|
|
.paddingOuter(paddingOuter)
|
|
.align(align);
|
|
};
|
|
|
|
return rescale();
|
|
}
|
|
|
|
function pointish(scale) {
|
|
var copy = scale.copy;
|
|
|
|
scale.padding = scale.paddingOuter;
|
|
delete scale.paddingInner;
|
|
delete scale.paddingOuter;
|
|
|
|
scale.copy = function() {
|
|
return pointish(copy());
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
function point() {
|
|
return pointish(band().paddingInner(1));
|
|
}
|
|
|
|
var constant = function(x) {
|
|
return function() {
|
|
return x;
|
|
};
|
|
};
|
|
|
|
var number = function(x) {
|
|
return +x;
|
|
};
|
|
|
|
var unit = [0, 1];
|
|
|
|
function deinterpolateLinear(a, b) {
|
|
return (b -= (a = +a))
|
|
? function(x) { return (x - a) / b; }
|
|
: constant(b);
|
|
}
|
|
|
|
function deinterpolateClamp(deinterpolate) {
|
|
return function(a, b) {
|
|
var d = deinterpolate(a = +a, b = +b);
|
|
return function(x) { return x <= a ? 0 : x >= b ? 1 : d(x); };
|
|
};
|
|
}
|
|
|
|
function reinterpolateClamp(reinterpolate) {
|
|
return function(a, b) {
|
|
var r = reinterpolate(a = +a, b = +b);
|
|
return function(t) { return t <= 0 ? a : t >= 1 ? b : r(t); };
|
|
};
|
|
}
|
|
|
|
function bimap(domain, range$$1, deinterpolate, reinterpolate) {
|
|
var d0 = domain[0], d1 = domain[1], r0 = range$$1[0], r1 = range$$1[1];
|
|
if (d1 < d0) d0 = deinterpolate(d1, d0), r0 = reinterpolate(r1, r0);
|
|
else d0 = deinterpolate(d0, d1), r0 = reinterpolate(r0, r1);
|
|
return function(x) { return r0(d0(x)); };
|
|
}
|
|
|
|
function polymap(domain, range$$1, deinterpolate, reinterpolate) {
|
|
var j = Math.min(domain.length, range$$1.length) - 1,
|
|
d = new Array(j),
|
|
r = new Array(j),
|
|
i = -1;
|
|
|
|
// Reverse descending domains.
|
|
if (domain[j] < domain[0]) {
|
|
domain = domain.slice().reverse();
|
|
range$$1 = range$$1.slice().reverse();
|
|
}
|
|
|
|
while (++i < j) {
|
|
d[i] = deinterpolate(domain[i], domain[i + 1]);
|
|
r[i] = reinterpolate(range$$1[i], range$$1[i + 1]);
|
|
}
|
|
|
|
return function(x) {
|
|
var i = d3Array.bisect(domain, x, 1, j) - 1;
|
|
return r[i](d[i](x));
|
|
};
|
|
}
|
|
|
|
function copy(source, target) {
|
|
return target
|
|
.domain(source.domain())
|
|
.range(source.range())
|
|
.interpolate(source.interpolate())
|
|
.clamp(source.clamp());
|
|
}
|
|
|
|
// deinterpolate(a, b)(x) takes a domain value x in [a,b] and returns the corresponding parameter t in [0,1].
|
|
// reinterpolate(a, b)(t) takes a parameter t in [0,1] and returns the corresponding domain value x in [a,b].
|
|
function continuous(deinterpolate, reinterpolate) {
|
|
var domain = unit,
|
|
range$$1 = unit,
|
|
interpolate$$1 = d3Interpolate.interpolate,
|
|
clamp = false,
|
|
piecewise,
|
|
output,
|
|
input;
|
|
|
|
function rescale() {
|
|
piecewise = Math.min(domain.length, range$$1.length) > 2 ? polymap : bimap;
|
|
output = input = null;
|
|
return scale;
|
|
}
|
|
|
|
function scale(x) {
|
|
return (output || (output = piecewise(domain, range$$1, clamp ? deinterpolateClamp(deinterpolate) : deinterpolate, interpolate$$1)))(+x);
|
|
}
|
|
|
|
scale.invert = function(y) {
|
|
return (input || (input = piecewise(range$$1, domain, deinterpolateLinear, clamp ? reinterpolateClamp(reinterpolate) : reinterpolate)))(+y);
|
|
};
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (domain = map$1.call(_, number), rescale()) : domain.slice();
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (range$$1 = slice.call(_), rescale()) : range$$1.slice();
|
|
};
|
|
|
|
scale.rangeRound = function(_) {
|
|
return range$$1 = slice.call(_), interpolate$$1 = d3Interpolate.interpolateRound, rescale();
|
|
};
|
|
|
|
scale.clamp = function(_) {
|
|
return arguments.length ? (clamp = !!_, rescale()) : clamp;
|
|
};
|
|
|
|
scale.interpolate = function(_) {
|
|
return arguments.length ? (interpolate$$1 = _, rescale()) : interpolate$$1;
|
|
};
|
|
|
|
return rescale();
|
|
}
|
|
|
|
var tickFormat = function(domain, count, specifier) {
|
|
var start = domain[0],
|
|
stop = domain[domain.length - 1],
|
|
step = d3Array.tickStep(start, stop, count == null ? 10 : count),
|
|
precision;
|
|
specifier = d3Format.formatSpecifier(specifier == null ? ",f" : specifier);
|
|
switch (specifier.type) {
|
|
case "s": {
|
|
var value = Math.max(Math.abs(start), Math.abs(stop));
|
|
if (specifier.precision == null && !isNaN(precision = d3Format.precisionPrefix(step, value))) specifier.precision = precision;
|
|
return d3Format.formatPrefix(specifier, value);
|
|
}
|
|
case "":
|
|
case "e":
|
|
case "g":
|
|
case "p":
|
|
case "r": {
|
|
if (specifier.precision == null && !isNaN(precision = d3Format.precisionRound(step, Math.max(Math.abs(start), Math.abs(stop))))) specifier.precision = precision - (specifier.type === "e");
|
|
break;
|
|
}
|
|
case "f":
|
|
case "%": {
|
|
if (specifier.precision == null && !isNaN(precision = d3Format.precisionFixed(step))) specifier.precision = precision - (specifier.type === "%") * 2;
|
|
break;
|
|
}
|
|
}
|
|
return d3Format.format(specifier);
|
|
};
|
|
|
|
function linearish(scale) {
|
|
var domain = scale.domain;
|
|
|
|
scale.ticks = function(count) {
|
|
var d = domain();
|
|
return d3Array.ticks(d[0], d[d.length - 1], count == null ? 10 : count);
|
|
};
|
|
|
|
scale.tickFormat = function(count, specifier) {
|
|
return tickFormat(domain(), count, specifier);
|
|
};
|
|
|
|
scale.nice = function(count) {
|
|
if (count == null) count = 10;
|
|
|
|
var d = domain(),
|
|
i0 = 0,
|
|
i1 = d.length - 1,
|
|
start = d[i0],
|
|
stop = d[i1],
|
|
step;
|
|
|
|
if (stop < start) {
|
|
step = start, start = stop, stop = step;
|
|
step = i0, i0 = i1, i1 = step;
|
|
}
|
|
|
|
step = d3Array.tickIncrement(start, stop, count);
|
|
|
|
if (step > 0) {
|
|
start = Math.floor(start / step) * step;
|
|
stop = Math.ceil(stop / step) * step;
|
|
step = d3Array.tickIncrement(start, stop, count);
|
|
} else if (step < 0) {
|
|
start = Math.ceil(start * step) / step;
|
|
stop = Math.floor(stop * step) / step;
|
|
step = d3Array.tickIncrement(start, stop, count);
|
|
}
|
|
|
|
if (step > 0) {
|
|
d[i0] = Math.floor(start / step) * step;
|
|
d[i1] = Math.ceil(stop / step) * step;
|
|
domain(d);
|
|
} else if (step < 0) {
|
|
d[i0] = Math.ceil(start * step) / step;
|
|
d[i1] = Math.floor(stop * step) / step;
|
|
domain(d);
|
|
}
|
|
|
|
return scale;
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
function linear() {
|
|
var scale = continuous(deinterpolateLinear, d3Interpolate.interpolateNumber);
|
|
|
|
scale.copy = function() {
|
|
return copy(scale, linear());
|
|
};
|
|
|
|
return linearish(scale);
|
|
}
|
|
|
|
function identity() {
|
|
var domain = [0, 1];
|
|
|
|
function scale(x) {
|
|
return +x;
|
|
}
|
|
|
|
scale.invert = scale;
|
|
|
|
scale.domain = scale.range = function(_) {
|
|
return arguments.length ? (domain = map$1.call(_, number), scale) : domain.slice();
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return identity().domain(domain);
|
|
};
|
|
|
|
return linearish(scale);
|
|
}
|
|
|
|
var nice = function(domain, interval) {
|
|
domain = domain.slice();
|
|
|
|
var i0 = 0,
|
|
i1 = domain.length - 1,
|
|
x0 = domain[i0],
|
|
x1 = domain[i1],
|
|
t;
|
|
|
|
if (x1 < x0) {
|
|
t = i0, i0 = i1, i1 = t;
|
|
t = x0, x0 = x1, x1 = t;
|
|
}
|
|
|
|
domain[i0] = interval.floor(x0);
|
|
domain[i1] = interval.ceil(x1);
|
|
return domain;
|
|
};
|
|
|
|
function deinterpolate(a, b) {
|
|
return (b = Math.log(b / a))
|
|
? function(x) { return Math.log(x / a) / b; }
|
|
: constant(b);
|
|
}
|
|
|
|
function reinterpolate(a, b) {
|
|
return a < 0
|
|
? function(t) { return -Math.pow(-b, t) * Math.pow(-a, 1 - t); }
|
|
: function(t) { return Math.pow(b, t) * Math.pow(a, 1 - t); };
|
|
}
|
|
|
|
function pow10(x) {
|
|
return isFinite(x) ? +("1e" + x) : x < 0 ? 0 : x;
|
|
}
|
|
|
|
function powp(base) {
|
|
return base === 10 ? pow10
|
|
: base === Math.E ? Math.exp
|
|
: function(x) { return Math.pow(base, x); };
|
|
}
|
|
|
|
function logp(base) {
|
|
return base === Math.E ? Math.log
|
|
: base === 10 && Math.log10
|
|
|| base === 2 && Math.log2
|
|
|| (base = Math.log(base), function(x) { return Math.log(x) / base; });
|
|
}
|
|
|
|
function reflect(f) {
|
|
return function(x) {
|
|
return -f(-x);
|
|
};
|
|
}
|
|
|
|
function log() {
|
|
var scale = continuous(deinterpolate, reinterpolate).domain([1, 10]),
|
|
domain = scale.domain,
|
|
base = 10,
|
|
logs = logp(10),
|
|
pows = powp(10);
|
|
|
|
function rescale() {
|
|
logs = logp(base), pows = powp(base);
|
|
if (domain()[0] < 0) logs = reflect(logs), pows = reflect(pows);
|
|
return scale;
|
|
}
|
|
|
|
scale.base = function(_) {
|
|
return arguments.length ? (base = +_, rescale()) : base;
|
|
};
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (domain(_), rescale()) : domain();
|
|
};
|
|
|
|
scale.ticks = function(count) {
|
|
var d = domain(),
|
|
u = d[0],
|
|
v = d[d.length - 1],
|
|
r;
|
|
|
|
if (r = v < u) i = u, u = v, v = i;
|
|
|
|
var i = logs(u),
|
|
j = logs(v),
|
|
p,
|
|
k,
|
|
t,
|
|
n = count == null ? 10 : +count,
|
|
z = [];
|
|
|
|
if (!(base % 1) && j - i < n) {
|
|
i = Math.round(i) - 1, j = Math.round(j) + 1;
|
|
if (u > 0) for (; i < j; ++i) {
|
|
for (k = 1, p = pows(i); k < base; ++k) {
|
|
t = p * k;
|
|
if (t < u) continue;
|
|
if (t > v) break;
|
|
z.push(t);
|
|
}
|
|
} else for (; i < j; ++i) {
|
|
for (k = base - 1, p = pows(i); k >= 1; --k) {
|
|
t = p * k;
|
|
if (t < u) continue;
|
|
if (t > v) break;
|
|
z.push(t);
|
|
}
|
|
}
|
|
} else {
|
|
z = d3Array.ticks(i, j, Math.min(j - i, n)).map(pows);
|
|
}
|
|
|
|
return r ? z.reverse() : z;
|
|
};
|
|
|
|
scale.tickFormat = function(count, specifier) {
|
|
if (specifier == null) specifier = base === 10 ? ".0e" : ",";
|
|
if (typeof specifier !== "function") specifier = d3Format.format(specifier);
|
|
if (count === Infinity) return specifier;
|
|
if (count == null) count = 10;
|
|
var k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate?
|
|
return function(d) {
|
|
var i = d / pows(Math.round(logs(d)));
|
|
if (i * base < base - 0.5) i *= base;
|
|
return i <= k ? specifier(d) : "";
|
|
};
|
|
};
|
|
|
|
scale.nice = function() {
|
|
return domain(nice(domain(), {
|
|
floor: function(x) { return pows(Math.floor(logs(x))); },
|
|
ceil: function(x) { return pows(Math.ceil(logs(x))); }
|
|
}));
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return copy(scale, log().base(base));
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
function raise(x, exponent) {
|
|
return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent);
|
|
}
|
|
|
|
function pow() {
|
|
var exponent = 1,
|
|
scale = continuous(deinterpolate, reinterpolate),
|
|
domain = scale.domain;
|
|
|
|
function deinterpolate(a, b) {
|
|
return (b = raise(b, exponent) - (a = raise(a, exponent)))
|
|
? function(x) { return (raise(x, exponent) - a) / b; }
|
|
: constant(b);
|
|
}
|
|
|
|
function reinterpolate(a, b) {
|
|
b = raise(b, exponent) - (a = raise(a, exponent));
|
|
return function(t) { return raise(a + b * t, 1 / exponent); };
|
|
}
|
|
|
|
scale.exponent = function(_) {
|
|
return arguments.length ? (exponent = +_, domain(domain())) : exponent;
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return copy(scale, pow().exponent(exponent));
|
|
};
|
|
|
|
return linearish(scale);
|
|
}
|
|
|
|
function sqrt() {
|
|
return pow().exponent(0.5);
|
|
}
|
|
|
|
function quantile$1() {
|
|
var domain = [],
|
|
range$$1 = [],
|
|
thresholds = [];
|
|
|
|
function rescale() {
|
|
var i = 0, n = Math.max(1, range$$1.length);
|
|
thresholds = new Array(n - 1);
|
|
while (++i < n) thresholds[i - 1] = d3Array.quantile(domain, i / n);
|
|
return scale;
|
|
}
|
|
|
|
function scale(x) {
|
|
if (!isNaN(x = +x)) return range$$1[d3Array.bisect(thresholds, x)];
|
|
}
|
|
|
|
scale.invertExtent = function(y) {
|
|
var i = range$$1.indexOf(y);
|
|
return i < 0 ? [NaN, NaN] : [
|
|
i > 0 ? thresholds[i - 1] : domain[0],
|
|
i < thresholds.length ? thresholds[i] : domain[domain.length - 1]
|
|
];
|
|
};
|
|
|
|
scale.domain = function(_) {
|
|
if (!arguments.length) return domain.slice();
|
|
domain = [];
|
|
for (var i = 0, n = _.length, d; i < n; ++i) if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d);
|
|
domain.sort(d3Array.ascending);
|
|
return rescale();
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (range$$1 = slice.call(_), rescale()) : range$$1.slice();
|
|
};
|
|
|
|
scale.quantiles = function() {
|
|
return thresholds.slice();
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return quantile$1()
|
|
.domain(domain)
|
|
.range(range$$1);
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
function quantize() {
|
|
var x0 = 0,
|
|
x1 = 1,
|
|
n = 1,
|
|
domain = [0.5],
|
|
range$$1 = [0, 1];
|
|
|
|
function scale(x) {
|
|
if (x <= x) return range$$1[d3Array.bisect(domain, x, 0, n)];
|
|
}
|
|
|
|
function rescale() {
|
|
var i = -1;
|
|
domain = new Array(n);
|
|
while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1);
|
|
return scale;
|
|
}
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (x0 = +_[0], x1 = +_[1], rescale()) : [x0, x1];
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (n = (range$$1 = slice.call(_)).length - 1, rescale()) : range$$1.slice();
|
|
};
|
|
|
|
scale.invertExtent = function(y) {
|
|
var i = range$$1.indexOf(y);
|
|
return i < 0 ? [NaN, NaN]
|
|
: i < 1 ? [x0, domain[0]]
|
|
: i >= n ? [domain[n - 1], x1]
|
|
: [domain[i - 1], domain[i]];
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return quantize()
|
|
.domain([x0, x1])
|
|
.range(range$$1);
|
|
};
|
|
|
|
return linearish(scale);
|
|
}
|
|
|
|
function threshold() {
|
|
var domain = [0.5],
|
|
range$$1 = [0, 1],
|
|
n = 1;
|
|
|
|
function scale(x) {
|
|
if (x <= x) return range$$1[d3Array.bisect(domain, x, 0, n)];
|
|
}
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (domain = slice.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : domain.slice();
|
|
};
|
|
|
|
scale.range = function(_) {
|
|
return arguments.length ? (range$$1 = slice.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : range$$1.slice();
|
|
};
|
|
|
|
scale.invertExtent = function(y) {
|
|
var i = range$$1.indexOf(y);
|
|
return [domain[i - 1], domain[i]];
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return threshold()
|
|
.domain(domain)
|
|
.range(range$$1);
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
var durationSecond = 1000;
|
|
var durationMinute = durationSecond * 60;
|
|
var durationHour = durationMinute * 60;
|
|
var durationDay = durationHour * 24;
|
|
var durationWeek = durationDay * 7;
|
|
var durationMonth = durationDay * 30;
|
|
var durationYear = durationDay * 365;
|
|
|
|
function date(t) {
|
|
return new Date(t);
|
|
}
|
|
|
|
function number$1(t) {
|
|
return t instanceof Date ? +t : +new Date(+t);
|
|
}
|
|
|
|
function calendar(year, month, week, day, hour, minute, second, millisecond, format$$1) {
|
|
var scale = continuous(deinterpolateLinear, d3Interpolate.interpolateNumber),
|
|
invert = scale.invert,
|
|
domain = scale.domain;
|
|
|
|
var formatMillisecond = format$$1(".%L"),
|
|
formatSecond = format$$1(":%S"),
|
|
formatMinute = format$$1("%I:%M"),
|
|
formatHour = format$$1("%I %p"),
|
|
formatDay = format$$1("%a %d"),
|
|
formatWeek = format$$1("%b %d"),
|
|
formatMonth = format$$1("%B"),
|
|
formatYear = format$$1("%Y");
|
|
|
|
var tickIntervals = [
|
|
[second, 1, durationSecond],
|
|
[second, 5, 5 * durationSecond],
|
|
[second, 15, 15 * durationSecond],
|
|
[second, 30, 30 * durationSecond],
|
|
[minute, 1, durationMinute],
|
|
[minute, 5, 5 * durationMinute],
|
|
[minute, 15, 15 * durationMinute],
|
|
[minute, 30, 30 * durationMinute],
|
|
[ hour, 1, durationHour ],
|
|
[ hour, 3, 3 * durationHour ],
|
|
[ hour, 6, 6 * durationHour ],
|
|
[ hour, 12, 12 * durationHour ],
|
|
[ day, 1, durationDay ],
|
|
[ day, 2, 2 * durationDay ],
|
|
[ week, 1, durationWeek ],
|
|
[ month, 1, durationMonth ],
|
|
[ month, 3, 3 * durationMonth ],
|
|
[ year, 1, durationYear ]
|
|
];
|
|
|
|
function tickFormat(date) {
|
|
return (second(date) < date ? formatMillisecond
|
|
: minute(date) < date ? formatSecond
|
|
: hour(date) < date ? formatMinute
|
|
: day(date) < date ? formatHour
|
|
: month(date) < date ? (week(date) < date ? formatDay : formatWeek)
|
|
: year(date) < date ? formatMonth
|
|
: formatYear)(date);
|
|
}
|
|
|
|
function tickInterval(interval, start, stop, step) {
|
|
if (interval == null) interval = 10;
|
|
|
|
// If a desired tick count is specified, pick a reasonable tick interval
|
|
// based on the extent of the domain and a rough estimate of tick size.
|
|
// Otherwise, assume interval is already a time interval and use it.
|
|
if (typeof interval === "number") {
|
|
var target = Math.abs(stop - start) / interval,
|
|
i = d3Array.bisector(function(i) { return i[2]; }).right(tickIntervals, target);
|
|
if (i === tickIntervals.length) {
|
|
step = d3Array.tickStep(start / durationYear, stop / durationYear, interval);
|
|
interval = year;
|
|
} else if (i) {
|
|
i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
|
|
step = i[1];
|
|
interval = i[0];
|
|
} else {
|
|
step = Math.max(d3Array.tickStep(start, stop, interval), 1);
|
|
interval = millisecond;
|
|
}
|
|
}
|
|
|
|
return step == null ? interval : interval.every(step);
|
|
}
|
|
|
|
scale.invert = function(y) {
|
|
return new Date(invert(y));
|
|
};
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? domain(map$1.call(_, number$1)) : domain().map(date);
|
|
};
|
|
|
|
scale.ticks = function(interval, step) {
|
|
var d = domain(),
|
|
t0 = d[0],
|
|
t1 = d[d.length - 1],
|
|
r = t1 < t0,
|
|
t;
|
|
if (r) t = t0, t0 = t1, t1 = t;
|
|
t = tickInterval(interval, t0, t1, step);
|
|
t = t ? t.range(t0, t1 + 1) : []; // inclusive stop
|
|
return r ? t.reverse() : t;
|
|
};
|
|
|
|
scale.tickFormat = function(count, specifier) {
|
|
return specifier == null ? tickFormat : format$$1(specifier);
|
|
};
|
|
|
|
scale.nice = function(interval, step) {
|
|
var d = domain();
|
|
return (interval = tickInterval(interval, d[0], d[d.length - 1], step))
|
|
? domain(nice(d, interval))
|
|
: scale;
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return copy(scale, calendar(year, month, week, day, hour, minute, second, millisecond, format$$1));
|
|
};
|
|
|
|
return scale;
|
|
}
|
|
|
|
var time = function() {
|
|
return calendar(d3Time.timeYear, d3Time.timeMonth, d3Time.timeWeek, d3Time.timeDay, d3Time.timeHour, d3Time.timeMinute, d3Time.timeSecond, d3Time.timeMillisecond, d3TimeFormat.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]);
|
|
};
|
|
|
|
var utcTime = function() {
|
|
return calendar(d3Time.utcYear, d3Time.utcMonth, d3Time.utcWeek, d3Time.utcDay, d3Time.utcHour, d3Time.utcMinute, d3Time.utcSecond, d3Time.utcMillisecond, d3TimeFormat.utcFormat).domain([Date.UTC(2000, 0, 1), Date.UTC(2000, 0, 2)]);
|
|
};
|
|
|
|
var colors = function(s) {
|
|
return s.match(/.{6}/g).map(function(x) {
|
|
return "#" + x;
|
|
});
|
|
};
|
|
|
|
var category10 = colors("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");
|
|
|
|
var category20b = colors("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6");
|
|
|
|
var category20c = colors("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9");
|
|
|
|
var category20 = colors("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5");
|
|
|
|
var cubehelix$1 = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(300, 0.5, 0.0), d3Color.cubehelix(-240, 0.5, 1.0));
|
|
|
|
var warm = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(-100, 0.75, 0.35), d3Color.cubehelix(80, 1.50, 0.8));
|
|
|
|
var cool = d3Interpolate.interpolateCubehelixLong(d3Color.cubehelix(260, 0.75, 0.35), d3Color.cubehelix(80, 1.50, 0.8));
|
|
|
|
var rainbow = d3Color.cubehelix();
|
|
|
|
var rainbow$1 = function(t) {
|
|
if (t < 0 || t > 1) t -= Math.floor(t);
|
|
var ts = Math.abs(t - 0.5);
|
|
rainbow.h = 360 * t - 100;
|
|
rainbow.s = 1.5 - 1.5 * ts;
|
|
rainbow.l = 0.8 - 0.9 * ts;
|
|
return rainbow + "";
|
|
};
|
|
|
|
function ramp(range$$1) {
|
|
var n = range$$1.length;
|
|
return function(t) {
|
|
return range$$1[Math.max(0, Math.min(n - 1, Math.floor(t * n)))];
|
|
};
|
|
}
|
|
|
|
var viridis = ramp(colors("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));
|
|
|
|
var magma = ramp(colors("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));
|
|
|
|
var inferno = ramp(colors("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4"));
|
|
|
|
var plasma = ramp(colors("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));
|
|
|
|
function sequential(interpolator) {
|
|
var x0 = 0,
|
|
x1 = 1,
|
|
clamp = false;
|
|
|
|
function scale(x) {
|
|
var t = (x - x0) / (x1 - x0);
|
|
return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t);
|
|
}
|
|
|
|
scale.domain = function(_) {
|
|
return arguments.length ? (x0 = +_[0], x1 = +_[1], scale) : [x0, x1];
|
|
};
|
|
|
|
scale.clamp = function(_) {
|
|
return arguments.length ? (clamp = !!_, scale) : clamp;
|
|
};
|
|
|
|
scale.interpolator = function(_) {
|
|
return arguments.length ? (interpolator = _, scale) : interpolator;
|
|
};
|
|
|
|
scale.copy = function() {
|
|
return sequential(interpolator).domain([x0, x1]).clamp(clamp);
|
|
};
|
|
|
|
return linearish(scale);
|
|
}
|
|
|
|
exports.scaleBand = band;
|
|
exports.scalePoint = point;
|
|
exports.scaleIdentity = identity;
|
|
exports.scaleLinear = linear;
|
|
exports.scaleLog = log;
|
|
exports.scaleOrdinal = ordinal;
|
|
exports.scaleImplicit = implicit;
|
|
exports.scalePow = pow;
|
|
exports.scaleSqrt = sqrt;
|
|
exports.scaleQuantile = quantile$1;
|
|
exports.scaleQuantize = quantize;
|
|
exports.scaleThreshold = threshold;
|
|
exports.scaleTime = time;
|
|
exports.scaleUtc = utcTime;
|
|
exports.schemeCategory10 = category10;
|
|
exports.schemeCategory20b = category20b;
|
|
exports.schemeCategory20c = category20c;
|
|
exports.schemeCategory20 = category20;
|
|
exports.interpolateCubehelixDefault = cubehelix$1;
|
|
exports.interpolateRainbow = rainbow$1;
|
|
exports.interpolateWarm = warm;
|
|
exports.interpolateCool = cool;
|
|
exports.interpolateViridis = viridis;
|
|
exports.interpolateMagma = magma;
|
|
exports.interpolateInferno = inferno;
|
|
exports.interpolatePlasma = plasma;
|
|
exports.scaleSequential = sequential;
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
})));
|