init 3
This commit is contained in:
104
node_modules/d3-scale/src/diverging.js
generated
vendored
Normal file
104
node_modules/d3-scale/src/diverging.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
import {interpolate, interpolateRound, piecewise} from "d3-interpolate";
|
||||
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";
|
||||
|
||||
function transformer() {
|
||||
var x0 = 0,
|
||||
x1 = 0.5,
|
||||
x2 = 1,
|
||||
s = 1,
|
||||
t0,
|
||||
t1,
|
||||
t2,
|
||||
k10,
|
||||
k21,
|
||||
interpolator = identity,
|
||||
transform,
|
||||
clamp = false,
|
||||
unknown;
|
||||
|
||||
function scale(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), s = t1 < t0 ? -1 : 1, scale) : [x0, x1, x2];
|
||||
};
|
||||
|
||||
scale.clamp = function(_) {
|
||||
return arguments.length ? (clamp = !!_, scale) : clamp;
|
||||
};
|
||||
|
||||
scale.interpolator = function(_) {
|
||||
return arguments.length ? (interpolator = _, scale) : interpolator;
|
||||
};
|
||||
|
||||
function range(interpolate) {
|
||||
return function(_) {
|
||||
var r0, r1, r2;
|
||||
return arguments.length ? ([r0, r1, r2] = _, interpolator = piecewise(interpolate, [r0, r1, r2]), scale) : [interpolator(0), interpolator(0.5), interpolator(1)];
|
||||
};
|
||||
}
|
||||
|
||||
scale.range = range(interpolate);
|
||||
|
||||
scale.rangeRound = range(interpolateRound);
|
||||
|
||||
scale.unknown = function(_) {
|
||||
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), s = t1 < t0 ? -1 : 1;
|
||||
return scale;
|
||||
};
|
||||
}
|
||||
|
||||
export default function diverging() {
|
||||
var scale = linearish(transformer()(identity));
|
||||
|
||||
scale.copy = function() {
|
||||
return copy(scale, diverging());
|
||||
};
|
||||
|
||||
return initInterpolator.apply(scale, arguments);
|
||||
}
|
||||
|
||||
export function divergingLog() {
|
||||
var scale = loggish(transformer()).domain([0.1, 1, 10]);
|
||||
|
||||
scale.copy = function() {
|
||||
return copy(scale, divergingLog()).base(scale.base());
|
||||
};
|
||||
|
||||
return initInterpolator.apply(scale, arguments);
|
||||
}
|
||||
|
||||
export function divergingSymlog() {
|
||||
var scale = symlogish(transformer());
|
||||
|
||||
scale.copy = function() {
|
||||
return copy(scale, divergingSymlog()).constant(scale.constant());
|
||||
};
|
||||
|
||||
return initInterpolator.apply(scale, arguments);
|
||||
}
|
||||
|
||||
export function divergingPow() {
|
||||
var scale = powish(transformer());
|
||||
|
||||
scale.copy = function() {
|
||||
return copy(scale, divergingPow()).exponent(scale.exponent());
|
||||
};
|
||||
|
||||
return initInterpolator.apply(scale, arguments);
|
||||
}
|
||||
|
||||
export function divergingSqrt() {
|
||||
return divergingPow.apply(null, arguments).exponent(0.5);
|
||||
}
|
||||
56
node_modules/d3-scale/src/quantize.js
generated
vendored
Normal file
56
node_modules/d3-scale/src/quantize.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import {bisect} from "d3-array";
|
||||
import {linearish} from "./linear.js";
|
||||
import {initRange} from "./init.js";
|
||||
|
||||
export default function quantize() {
|
||||
var x0 = 0,
|
||||
x1 = 1,
|
||||
n = 1,
|
||||
domain = [0.5],
|
||||
range = [0, 1],
|
||||
unknown;
|
||||
|
||||
function scale(x) {
|
||||
return x != null && x <= x ? range[bisect(domain, x, 0, n)] : unknown;
|
||||
}
|
||||
|
||||
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, x1] = _, x0 = +x0, x1 = +x1, rescale()) : [x0, x1];
|
||||
};
|
||||
|
||||
scale.range = function(_) {
|
||||
return arguments.length ? (n = (range = Array.from(_)).length - 1, rescale()) : range.slice();
|
||||
};
|
||||
|
||||
scale.invertExtent = function(y) {
|
||||
var i = range.indexOf(y);
|
||||
return i < 0 ? [NaN, NaN]
|
||||
: i < 1 ? [x0, domain[0]]
|
||||
: i >= n ? [domain[n - 1], x1]
|
||||
: [domain[i - 1], domain[i]];
|
||||
};
|
||||
|
||||
scale.unknown = function(_) {
|
||||
return arguments.length ? (unknown = _, scale) : scale;
|
||||
};
|
||||
|
||||
scale.thresholds = function() {
|
||||
return domain.slice();
|
||||
};
|
||||
|
||||
scale.copy = function() {
|
||||
return quantize()
|
||||
.domain([x0, x1])
|
||||
.range(range)
|
||||
.unknown(unknown);
|
||||
};
|
||||
|
||||
return initRange.apply(linearish(scale), arguments);
|
||||
}
|
||||
71
node_modules/d3-scale/src/time.js
generated
vendored
Normal file
71
node_modules/d3-scale/src/time.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import {timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeTicks, timeTickInterval} from "d3-time";
|
||||
import {timeFormat} from "d3-time-format";
|
||||
import continuous, {copy} from "./continuous.js";
|
||||
import {initRange} from "./init.js";
|
||||
import nice from "./nice.js";
|
||||
|
||||
function date(t) {
|
||||
return new Date(t);
|
||||
}
|
||||
|
||||
function number(t) {
|
||||
return t instanceof Date ? +t : +new Date(+t);
|
||||
}
|
||||
|
||||
export function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) {
|
||||
var scale = continuous(),
|
||||
invert = scale.invert,
|
||||
domain = scale.domain;
|
||||
|
||||
var formatMillisecond = format(".%L"),
|
||||
formatSecond = format(":%S"),
|
||||
formatMinute = format("%I:%M"),
|
||||
formatHour = format("%I %p"),
|
||||
formatDay = format("%a %d"),
|
||||
formatWeek = format("%b %d"),
|
||||
formatMonth = format("%B"),
|
||||
formatYear = format("%Y");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
scale.invert = function(y) {
|
||||
return new Date(invert(y));
|
||||
};
|
||||
|
||||
scale.domain = function(_) {
|
||||
return arguments.length ? domain(Array.from(_, number)) : domain().map(date);
|
||||
};
|
||||
|
||||
scale.ticks = function(interval) {
|
||||
var d = domain();
|
||||
return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
||||
};
|
||||
|
||||
scale.tickFormat = function(count, specifier) {
|
||||
return specifier == null ? tickFormat : format(specifier);
|
||||
};
|
||||
|
||||
scale.nice = function(interval) {
|
||||
var d = domain();
|
||||
if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
||||
return interval ? domain(nice(d, interval)) : scale;
|
||||
};
|
||||
|
||||
scale.copy = function() {
|
||||
return copy(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format));
|
||||
};
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
export default function time() {
|
||||
return initRange.apply(calendar(timeTicks, timeTickInterval, timeYear, timeMonth, timeWeek, timeDay, timeHour, timeMinute, timeSecond, timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments);
|
||||
}
|
||||
Reference in New Issue
Block a user