UNPKG

1.27 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Log = void 0;
4const continuous_1 = require("./continuous");
5const utils_1 = require("../utils");
6const d3_log_1 = require("../tick-methods/d3-log");
7const d3_log_nice_1 = require("../utils/d3-log-nice");
8/**
9 * Linear 比例尺
10 *
11 * 构造一个线性的对数比例尺
12 */
13class Log extends continuous_1.Continuous {
14 getDefaultOptions() {
15 return {
16 domain: [1, 10],
17 range: [0, 1],
18 base: 10,
19 interpolate: utils_1.createInterpolateValue,
20 tickMethod: d3_log_1.d3Log,
21 tickCount: 5,
22 };
23 }
24 chooseNice() {
25 return d3_log_nice_1.d3LogNice;
26 }
27 getTickMethodOptions() {
28 const { domain, tickCount, base } = this.options;
29 const min = domain[0];
30 const max = domain[domain.length - 1];
31 return [min, max, tickCount, base];
32 }
33 chooseTransforms() {
34 const { base, domain } = this.options;
35 const shouldReflect = domain[0] < 0;
36 return [(0, utils_1.logs)(base, shouldReflect), (0, utils_1.pows)(base, shouldReflect)];
37 }
38 clone() {
39 return new Log(this.options);
40 }
41}
42exports.Log = Log;
43//# sourceMappingURL=log.js.map
\No newline at end of file