UNPKG

@antv/f2

Version:

Charts for mobile visualization.

57 lines 1.57 kB
import { mix, isFunction, isNil, isArray, valuesOfKey } from '@antv/util'; var Base = /** @class */function () { function Base(options) { mix(this, options); var _a = this, scale = _a.scale, field = _a.field, data = _a.data; if (!scale && data) { var values = 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) { mix(this, options); }; Base.prototype.setRange = function (range) { this.range = range; }; // 归一化,参数是原始数据,返回是归一化的数据 Base.prototype.normalize = function (value) { var scale = this.scale; if (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 = isFunction(this.callback) ? this.callback(value, child) : null; if (!isNil(rst)) { return rst; } return this._mapping(value); }; return Base; }(); export default Base;