1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslib_1 = require("tslib");
|
4 | var __1 = require("..");
|
5 | var DIM_X = 'x';
|
6 | var DIM_Y = 'y';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | var ScaleTranslate = (function (_super) {
|
12 | tslib_1.__extends(ScaleTranslate, _super);
|
13 | function ScaleTranslate() {
|
14 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
15 | _this.dims = [DIM_X, DIM_Y];
|
16 | _this.cfgFields = ['dims'];
|
17 | _this.cacheScaleDefs = {};
|
18 | return _this;
|
19 | }
|
20 |
|
21 | ScaleTranslate.prototype.hasDim = function (dim) {
|
22 | return this.dims.includes(dim);
|
23 | };
|
24 | ScaleTranslate.prototype.getScale = function (dim) {
|
25 | var view = this.context.view;
|
26 | if (dim === 'x') {
|
27 | return view.getXScale();
|
28 | }
|
29 | else {
|
30 | return view.getYScales()[0];
|
31 | }
|
32 | };
|
33 | ScaleTranslate.prototype.resetDim = function (dim) {
|
34 | var view = this.context.view;
|
35 | if (this.hasDim(dim) && this.cacheScaleDefs[dim]) {
|
36 | var scale = this.getScale(dim);
|
37 | view.scale(scale.field, this.cacheScaleDefs[dim]);
|
38 | this.cacheScaleDefs[dim] = null;
|
39 | }
|
40 | };
|
41 | |
42 |
|
43 |
|
44 | ScaleTranslate.prototype.reset = function () {
|
45 | this.resetDim(DIM_X);
|
46 | this.resetDim(DIM_Y);
|
47 | var view = this.context.view;
|
48 | view.render(true);
|
49 | };
|
50 | return ScaleTranslate;
|
51 | }(__1.Action));
|
52 | exports.default = ScaleTranslate;
|
53 |
|
\ | No newline at end of file |