UNPKG

@antv/f2

Version:

Charts for mobile visualization.

63 lines (62 loc) 1.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _util = require("@antv/util"); var Base = /** @class */function () { function Base(options) { (0, _util.mix)(this, options); var _a = this, scale = _a.scale, field = _a.field, data = _a.data; if (!scale && data) { var values = (0, _util.valuesOfKey)(data, field); this.scale = this.createScale({ values: values, field: field }); } } Base.prototype.createScale = function (_scaleConfig) { return null; }; // 数据映射方法 Base.prototype._mapping = function (value) { return value; }; Base.prototype.update = function (options) { (0, _util.mix)(this, options); }; Base.prototype.setRange = function (range) { this.range = range; }; // 归一化,参数是原始数据,返回是归一化的数据 Base.prototype.normalize = function (value) { var scale = this.scale; if ((0, _util.isArray)(value)) { return value.map(function (v) { return scale.scale(v); }); } return scale.scale(value); }; // convert 参数是归一化的数据,返回定义域的值 Base.prototype.convert = function (value) { return value; }; // 等于 normalize + convert, 参数是原始数据,返回是定义域的值 Base.prototype.mapping = function (value, child) { if (child === void 0) { child = null; } var rst = (0, _util.isFunction)(this.callback) ? this.callback(value, child) : null; if (!(0, _util.isNil)(rst)) { return rst; } return this._mapping(value); }; return Base; }(); var _default = exports.default = Base;