UNPKG

1.59 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var math_1 = require("../util/math");
5var base_1 = require("./base");
6/**
7 * Pow 度量,处理非均匀分布
8 */
9var Pow = /** @class */ (function (_super) {
10 tslib_1.__extends(Pow, _super);
11 function Pow() {
12 var _this = _super !== null && _super.apply(this, arguments) || this;
13 _this.type = 'pow';
14 return _this;
15 }
16 /**
17 * @override
18 */
19 Pow.prototype.invert = function (value) {
20 var percent = this.getInvertPercent(value);
21 var exponent = this.exponent;
22 var max = math_1.calBase(exponent, this.max);
23 var min = math_1.calBase(exponent, this.min);
24 var tmp = percent * (max - min) + min;
25 var factor = tmp >= 0 ? 1 : -1;
26 return Math.pow(tmp, exponent) * factor;
27 };
28 Pow.prototype.initCfg = function () {
29 this.tickMethod = 'pow';
30 this.exponent = 2;
31 this.tickCount = 5;
32 this.nice = true;
33 };
34 // 获取度量计算时,value占的定义域百分比
35 Pow.prototype.getScalePercent = function (value) {
36 var max = this.max;
37 var min = this.min;
38 if (max === min) {
39 return 0;
40 }
41 var exponent = this.exponent;
42 var percent = (math_1.calBase(exponent, value) - math_1.calBase(exponent, min)) / (math_1.calBase(exponent, max) - math_1.calBase(exponent, min));
43 return percent;
44 };
45 return Pow;
46}(base_1.default));
47exports.default = Pow;
48//# sourceMappingURL=pow.js.map
\No newline at end of file