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 rect_1 = tslib_1.__importDefault(require("./rect"));
|
6 | function clampPoint(point) {
|
7 | point.x = util_1.clamp(point.x, 0, 1);
|
8 | point.y = util_1.clamp(point.y, 0, 1);
|
9 | }
|
10 |
|
11 |
|
12 |
|
13 | var DimRect = (function (_super) {
|
14 | tslib_1.__extends(DimRect, _super);
|
15 | function DimRect() {
|
16 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
17 | _this.dim = 'x';
|
18 | _this.inPlot = true;
|
19 | return _this;
|
20 | }
|
21 | DimRect.prototype.getRegion = function () {
|
22 | var start = null;
|
23 | var end = null;
|
24 | var points = this.points;
|
25 | var dim = this.dim;
|
26 | var coord = this.context.view.getCoordinate();
|
27 | var normalStart = coord.invert(util_1.head(points));
|
28 | var normalEnd = coord.invert(util_1.last(points));
|
29 | if (this.inPlot) {
|
30 |
|
31 | clampPoint(normalStart);
|
32 | clampPoint(normalEnd);
|
33 | }
|
34 | if (dim === 'x') {
|
35 |
|
36 | start = coord.convert({
|
37 | x: normalStart.x,
|
38 | y: 0,
|
39 | });
|
40 | end = coord.convert({
|
41 | x: normalEnd.x,
|
42 | y: 1,
|
43 | });
|
44 | }
|
45 | else {
|
46 |
|
47 | start = coord.convert({
|
48 | x: 0,
|
49 | y: normalStart.y,
|
50 | });
|
51 | end = coord.convert({
|
52 | x: 1,
|
53 | y: normalEnd.y,
|
54 | });
|
55 | }
|
56 | return {
|
57 | start: start,
|
58 | end: end,
|
59 | };
|
60 | };
|
61 | return DimRect;
|
62 | }(rect_1.default));
|
63 | exports.default = DimRect;
|
64 |
|
\ | No newline at end of file |