| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.copy = copy;
|
|---|
| 7 | exports.default = sequential;
|
|---|
| 8 | exports.sequentialLog = sequentialLog;
|
|---|
| 9 | exports.sequentialPow = sequentialPow;
|
|---|
| 10 | exports.sequentialSqrt = sequentialSqrt;
|
|---|
| 11 | exports.sequentialSymlog = sequentialSymlog;
|
|---|
| 12 | var _index = require("../../../lib-vendor/d3-interpolate/src/index.js");
|
|---|
| 13 | var _continuous = require("./continuous.js");
|
|---|
| 14 | var _init = require("./init.js");
|
|---|
| 15 | var _linear = require("./linear.js");
|
|---|
| 16 | var _log = require("./log.js");
|
|---|
| 17 | var _symlog = require("./symlog.js");
|
|---|
| 18 | var _pow = require("./pow.js");
|
|---|
| 19 | function transformer() {
|
|---|
| 20 | var x0 = 0,
|
|---|
| 21 | x1 = 1,
|
|---|
| 22 | t0,
|
|---|
| 23 | t1,
|
|---|
| 24 | k10,
|
|---|
| 25 | transform,
|
|---|
| 26 | interpolator = _continuous.identity,
|
|---|
| 27 | clamp = false,
|
|---|
| 28 | unknown;
|
|---|
| 29 | function scale(x) {
|
|---|
| 30 | return x == null || isNaN(x = +x) ? unknown : interpolator(k10 === 0 ? 0.5 : (x = (transform(x) - t0) * k10, clamp ? Math.max(0, Math.min(1, x)) : x));
|
|---|
| 31 | }
|
|---|
| 32 | scale.domain = function (_) {
|
|---|
| 33 | return arguments.length ? ([x0, x1] = _, t0 = transform(x0 = +x0), t1 = transform(x1 = +x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0), scale) : [x0, x1];
|
|---|
| 34 | };
|
|---|
| 35 | scale.clamp = function (_) {
|
|---|
| 36 | return arguments.length ? (clamp = !!_, scale) : clamp;
|
|---|
| 37 | };
|
|---|
| 38 | scale.interpolator = function (_) {
|
|---|
| 39 | return arguments.length ? (interpolator = _, scale) : interpolator;
|
|---|
| 40 | };
|
|---|
| 41 | function range(interpolate) {
|
|---|
| 42 | return function (_) {
|
|---|
| 43 | var r0, r1;
|
|---|
| 44 | return arguments.length ? ([r0, r1] = _, interpolator = interpolate(r0, r1), scale) : [interpolator(0), interpolator(1)];
|
|---|
| 45 | };
|
|---|
| 46 | }
|
|---|
| 47 | scale.range = range(_index.interpolate);
|
|---|
| 48 | scale.rangeRound = range(_index.interpolateRound);
|
|---|
| 49 | scale.unknown = function (_) {
|
|---|
| 50 | return arguments.length ? (unknown = _, scale) : unknown;
|
|---|
| 51 | };
|
|---|
| 52 | return function (t) {
|
|---|
| 53 | transform = t, t0 = t(x0), t1 = t(x1), k10 = t0 === t1 ? 0 : 1 / (t1 - t0);
|
|---|
| 54 | return scale;
|
|---|
| 55 | };
|
|---|
| 56 | }
|
|---|
| 57 | function copy(source, target) {
|
|---|
| 58 | return target.domain(source.domain()).interpolator(source.interpolator()).clamp(source.clamp()).unknown(source.unknown());
|
|---|
| 59 | }
|
|---|
| 60 | function sequential() {
|
|---|
| 61 | var scale = (0, _linear.linearish)(transformer()(_continuous.identity));
|
|---|
| 62 | scale.copy = function () {
|
|---|
| 63 | return copy(scale, sequential());
|
|---|
| 64 | };
|
|---|
| 65 | return _init.initInterpolator.apply(scale, arguments);
|
|---|
| 66 | }
|
|---|
| 67 | function sequentialLog() {
|
|---|
| 68 | var scale = (0, _log.loggish)(transformer()).domain([1, 10]);
|
|---|
| 69 | scale.copy = function () {
|
|---|
| 70 | return copy(scale, sequentialLog()).base(scale.base());
|
|---|
| 71 | };
|
|---|
| 72 | return _init.initInterpolator.apply(scale, arguments);
|
|---|
| 73 | }
|
|---|
| 74 | function sequentialSymlog() {
|
|---|
| 75 | var scale = (0, _symlog.symlogish)(transformer());
|
|---|
| 76 | scale.copy = function () {
|
|---|
| 77 | return copy(scale, sequentialSymlog()).constant(scale.constant());
|
|---|
| 78 | };
|
|---|
| 79 | return _init.initInterpolator.apply(scale, arguments);
|
|---|
| 80 | }
|
|---|
| 81 | function sequentialPow() {
|
|---|
| 82 | var scale = (0, _pow.powish)(transformer());
|
|---|
| 83 | scale.copy = function () {
|
|---|
| 84 | return copy(scale, sequentialPow()).exponent(scale.exponent());
|
|---|
| 85 | };
|
|---|
| 86 | return _init.initInterpolator.apply(scale, arguments);
|
|---|
| 87 | }
|
|---|
| 88 | function sequentialSqrt() {
|
|---|
| 89 | return sequentialPow.apply(null, arguments).exponent(0.5);
|
|---|
| 90 | } |
|---|