UNPKG

2.39 kBJavaScriptView Raw
1import { __assign, __extends } from "tslib";
2import { jsx } from '@antv/f-engine';
3import withLine from '../line/withLine';
4export default (function (View) {
5 return /** @class */function (_super) {
6 __extends(Area, _super);
7 function Area() {
8 return _super !== null && _super.apply(this, arguments) || this;
9 }
10 Area.prototype.getDefaultCfg = function () {
11 return {
12 geomType: 'area',
13 // 面积图默认设为从0开始
14 startOnZero: true,
15 // 点需要排序
16 sortable: true
17 };
18 };
19 Area.prototype.getBaseY = function () {
20 // 坐标轴 y0
21 var y0 = this.getY0Value();
22 var _a = this,
23 props = _a.props,
24 defaultStartOnZero = _a.startOnZero;
25 var coord = props.coord,
26 _b = props.startOnZero,
27 startOnZero = _b === void 0 ? defaultStartOnZero : _b;
28 if (startOnZero) {
29 // 零点映射到绝对坐标
30 var originCoord = coord.convertPoint({
31 x: 0,
32 y: y0
33 });
34 return originCoord.y;
35 }
36 return coord.y[0];
37 };
38 Area.prototype.mapping = function () {
39 var records = _super.prototype.mapping.call(this);
40 var baseY = this.getBaseY();
41 for (var i = 0, len = records.length; i < len; i++) {
42 var record = records[i];
43 var children = record.children;
44 for (var j = 0, len_1 = children.length; j < len_1; j++) {
45 var child = children[j];
46 var points = child.points,
47 bottomPoints = child.bottomPoints;
48 if (bottomPoints && bottomPoints.length) {
49 bottomPoints.reverse();
50 child.points = points.concat(bottomPoints);
51 } else {
52 points.unshift({
53 x: points[0].x,
54 y: baseY
55 });
56 points.unshift({
57 x: points[points.length - 1].x,
58 y: baseY
59 });
60 }
61 }
62 }
63 return records;
64 };
65 Area.prototype.render = function () {
66 var props = this.props;
67 var coord = props.coord;
68 var records = this.mapping();
69 var clip = this.getClip();
70 var baseY = this.getBaseY();
71 return jsx(View, __assign({}, props, {
72 baseY: baseY,
73 coord: coord,
74 records: records,
75 clip: clip
76 }));
77 };
78 return Area;
79 }(withLine(View));
80});
\No newline at end of file