1 | "use strict";
|
2 | var __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 | };
|
8 | var Diverging_1;
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.Diverging = void 0;
|
11 | const util_1 = require("@antv/util");
|
12 | const d3_ticks_1 = require("../tick-methods/d3-ticks");
|
13 | const utils_1 = require("../utils");
|
14 | const linear_1 = require("./linear");
|
15 | function rangeOf(interpolator) {
|
16 | return [interpolator(0), interpolator(0.5), interpolator(1)];
|
17 | }
|
18 | const normalizeDomain = (domain) => {
|
19 | const [d0, d1, d2] = domain;
|
20 |
|
21 | const normalizeLeft = (0, utils_1.compose)((0, utils_1.createInterpolateNumber)(0, 0.5), (0, utils_1.createNormalize)(d0, d1));
|
22 |
|
23 | const normalizeRight = (0, utils_1.compose)((0, utils_1.createInterpolateNumber)(0.5, 1), (0, utils_1.createNormalize)(d1, d2));
|
24 | return (x) => {
|
25 |
|
26 | if (d0 > d2) {
|
27 | return x < d1 ? normalizeRight(x) : normalizeLeft(x);
|
28 | }
|
29 | else {
|
30 | return x < d1 ? normalizeLeft(x) : normalizeRight(x);
|
31 | }
|
32 | };
|
33 | };
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | let Diverging = Diverging_1 = class Diverging extends linear_1.Linear {
|
40 | getDefaultOptions() {
|
41 | return {
|
42 | domain: [0, 0.5, 1],
|
43 | unknown: undefined,
|
44 | nice: false,
|
45 | clamp: false,
|
46 | round: false,
|
47 | interpolator: util_1.identity,
|
48 | tickMethod: d3_ticks_1.d3Ticks,
|
49 | tickCount: 5,
|
50 | };
|
51 | }
|
52 | constructor(options) {
|
53 | super(options);
|
54 | }
|
55 | clone() {
|
56 | return new Diverging_1(this.options);
|
57 | }
|
58 | };
|
59 | Diverging = Diverging_1 = __decorate([
|
60 | (0, utils_1.interpolatize)(rangeOf, normalizeDomain)
|
61 | ], Diverging);
|
62 | exports.Diverging = Diverging;
|
63 |
|
\ | No newline at end of file |