1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.interpolatize = void 0;
|
4 | const util_1 = require("@antv/util");
|
5 | const compose_1 = require("./compose");
|
6 | const createInterpolatorRound = (interpolator) => {
|
7 | return (t) => {
|
8 |
|
9 | const res = interpolator(t);
|
10 | return (0, util_1.isNumber)(res) ? Math.round(res) : res;
|
11 | };
|
12 | };
|
13 | function interpolatize(rangeOf, normalizeDomain) {
|
14 | return (Scale) => {
|
15 | Scale.prototype.rescale = function () {
|
16 | this.initRange();
|
17 | this.nice();
|
18 | const [transform] = this.chooseTransforms();
|
19 | this.composeOutput(transform, this.chooseClamp(transform));
|
20 | };
|
21 | Scale.prototype.initRange = function () {
|
22 | const { interpolator } = this.options;
|
23 | this.options.range = rangeOf(interpolator);
|
24 | };
|
25 | Scale.prototype.composeOutput = function (transform, clamp) {
|
26 | const { domain, interpolator, round } = this.getOptions();
|
27 | const normalize = normalizeDomain(domain.map(transform));
|
28 | const interpolate = round ? createInterpolatorRound(interpolator) : interpolator;
|
29 | this.output = (0, compose_1.compose)(interpolate, normalize, clamp, transform);
|
30 | };
|
31 | Scale.prototype.invert = undefined;
|
32 | };
|
33 | }
|
34 | exports.interpolatize = interpolatize;
|
35 |
|
\ | No newline at end of file |