UNPKG

1.6 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var __1 = require("..");
5var DIM_X = 'x';
6var DIM_Y = 'y';
7/**
8 * Scale translate
9 * @ignore
10 */
11var ScaleTranslate = /** @class */ (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));
52exports.default = ScaleTranslate;
53//# sourceMappingURL=scale-transform.js.map
\No newline at end of file