1 | import { __extends } from "tslib";
|
2 | import { isArray } from '@antv/util';
|
3 | import Geometry from './base';
|
4 |
|
5 | import './shape/polygon';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var Polygon = (function (_super) {
|
11 | __extends(Polygon, _super);
|
12 | function Polygon() {
|
13 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
14 | _this.type = 'polygon';
|
15 | _this.shapeType = 'polygon';
|
16 | _this.generatePoints = true;
|
17 | return _this;
|
18 | }
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | Polygon.prototype.createShapePointsCfg = function (obj) {
|
25 | var cfg = _super.prototype.createShapePointsCfg.call(this, obj);
|
26 | var x = cfg.x;
|
27 | var y = cfg.y;
|
28 | var temp;
|
29 |
|
30 | if (!(isArray(x) && isArray(y))) {
|
31 | var xScale = this.getXScale();
|
32 | var yScale = this.getYScale();
|
33 | var xCount = xScale.values.length;
|
34 | var yCount = yScale.values.length;
|
35 | var xOffset = (0.5 * 1) / xCount;
|
36 | var yOffset = (0.5 * 1) / yCount;
|
37 | if (xScale.isCategory && yScale.isCategory) {
|
38 |
|
39 | x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
|
40 | y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
|
41 | }
|
42 | else if (isArray(x)) {
|
43 |
|
44 | temp = x;
|
45 | x = [temp[0], temp[0], temp[1], temp[1]];
|
46 | y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
|
47 | }
|
48 | else if (isArray(y)) {
|
49 |
|
50 | temp = y;
|
51 | y = [temp[0], temp[1], temp[1], temp[0]];
|
52 | x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
|
53 | }
|
54 | cfg.x = x;
|
55 | cfg.y = y;
|
56 | }
|
57 | return cfg;
|
58 | };
|
59 | return Polygon;
|
60 | }(Geometry));
|
61 | export default Polygon;
|
62 |
|
\ | No newline at end of file |