@antv/f2
Version:
Charts for mobile visualization.
80 lines • 2.39 kB
JavaScript
import { __assign, __extends } from "tslib";
import { jsx } from '@antv/f-engine';
import withLine from '../line/withLine';
export default (function (View) {
return /** @class */function (_super) {
__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 jsx(View, __assign({}, props, {
baseY: baseY,
coord: coord,
records: records,
clip: clip
}));
};
return Area;
}(withLine(View));
});