@antv/f2
Version:
Charts for mobile visualization.
52 lines (51 loc) • 1.61 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _tslib = require("tslib");
var _math = require("../util/math");
var _base = _interopRequireDefault(require("./base"));
/**
* Pow 度量,处理非均匀分布
*/
var Pow = /** @class */function (_super) {
(0, _tslib.__extends)(Pow, _super);
function Pow() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = 'pow';
return _this;
}
/**
* @override
*/
Pow.prototype.invert = function (value) {
var percent = this.getInvertPercent(value);
var exponent = this.exponent;
var max = (0, _math.calBase)(exponent, this.max);
var min = (0, _math.calBase)(exponent, this.min);
var tmp = percent * (max - min) + min;
var factor = tmp >= 0 ? 1 : -1;
return Math.pow(tmp, exponent) * factor;
};
Pow.prototype.initCfg = function () {
this.tickMethod = 'pow';
this.exponent = 2;
this.tickCount = 5;
this.nice = true;
};
// 获取度量计算时,value占的定义域百分比
Pow.prototype.getScalePercent = function (value) {
var max = this.max;
var min = this.min;
if (max === min) {
return 0;
}
var exponent = this.exponent;
var percent = ((0, _math.calBase)(exponent, value) - (0, _math.calBase)(exponent, min)) / ((0, _math.calBase)(exponent, max) - (0, _math.calBase)(exponent, min));
return percent;
};
return Pow;
}(_base.default);
var _default = exports.default = Pow;
;