UNPKG

2.03 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var Sequential_1;
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.Sequential = void 0;
11const util_1 = require("@antv/util");
12const d3_ticks_1 = require("../tick-methods/d3-ticks");
13const utils_1 = require("../utils");
14const linear_1 = require("./linear");
15function rangeOf(interpolator) {
16 return [interpolator(0), interpolator(1)];
17}
18const normalizeDomain = (domain) => {
19 const [d0, d1] = domain;
20 // [d0, d1] => [0, 1]
21 const normalize = (0, utils_1.compose)((0, utils_1.createInterpolateNumber)(0, 1), (0, utils_1.createNormalize)(d0, d1));
22 return normalize;
23};
24/**
25 * Sequential 比例尺
26 *
27 * 构造可创建一个在输入和输出之间通过插值函数进行转换的比例尺
28 */
29// @Sequentialish
30let Sequential = Sequential_1 = class Sequential extends linear_1.Linear {
31 getDefaultOptions() {
32 return {
33 domain: [0, 1],
34 unknown: undefined,
35 nice: false,
36 clamp: false,
37 round: false,
38 interpolator: util_1.identity,
39 tickMethod: d3_ticks_1.d3Ticks,
40 tickCount: 5,
41 };
42 }
43 constructor(options) {
44 super(options);
45 }
46 clone() {
47 return new Sequential_1(this.options);
48 }
49};
50Sequential = Sequential_1 = __decorate([
51 (0, utils_1.interpolatize)(rangeOf, normalizeDomain)
52], Sequential);
53exports.Sequential = Sequential;
54//# sourceMappingURL=sequential.js.map
\No newline at end of file