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