@antv/f2
Version:
Charts for mobile visualization.
87 lines (86 loc) • 2.67 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _tslib = require("tslib");
var _fEngine = require("@antv/f-engine");
var _withLine = _interopRequireDefault(require("../line/withLine"));
var _default = exports.default = function _default(View) {
return /** @class */function (_super) {
(0, _tslib.__extends)(Area, _super);
function Area() {
return _super !== null && _super.apply(this, arguments) || this;
}
Area.prototype.getDefaultCfg = function () {
return {
geomType: 'area',
// 面积图默认设为从0开始
startOnZero: true,
// 点需要排序
sortable: true
};
};
Area.prototype.getBaseY = function () {
// 坐标轴 y0
var y0 = this.getY0Value();
var _a = this,
props = _a.props,
defaultStartOnZero = _a.startOnZero;
var coord = props.coord,
_b = props.startOnZero,
startOnZero = _b === void 0 ? defaultStartOnZero : _b;
if (startOnZero) {
// 零点映射到绝对坐标
var originCoord = coord.convertPoint({
x: 0,
y: y0
});
return originCoord.y;
}
return coord.y[0];
};
Area.prototype.mapping = function () {
var records = _super.prototype.mapping.call(this);
var baseY = this.getBaseY();
for (var i = 0, len = records.length; i < len; i++) {
var record = records[i];
var children = record.children;
for (var j = 0, len_1 = children.length; j < len_1; j++) {
var child = children[j];
var points = child.points,
bottomPoints = child.bottomPoints;
if (bottomPoints && bottomPoints.length) {
bottomPoints.reverse();
child.points = points.concat(bottomPoints);
} else {
points.unshift({
x: points[0].x,
y: baseY
});
points.unshift({
x: points[points.length - 1].x,
y: baseY
});
}
}
}
return records;
};
Area.prototype.render = function () {
var props = this.props;
var coord = props.coord;
var records = this.mapping();
var clip = this.getClip();
var baseY = this.getBaseY();
return (0, _fEngine.jsx)(View, (0, _tslib.__assign)({}, props, {
baseY: baseY,
coord: coord,
records: records,
clip: clip
}));
};
return Area;
}((0, _withLine.default)(View));
};
;