UNPKG

1.5 kBJavaScriptView Raw
1import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3import _createClass from "@babel/runtime/helpers/esm/createClass";
4import { Rect, Polar } from '../coord';
5import { isString, isFunction } from '@antv/util';
6var coordMap = {
7 rect: Rect,
8 polar: Polar
9};
10
11var coordController = /*#__PURE__*/function () {
12 function coordController() {
13 _classCallCheck(this, coordController);
14 }
15
16 _createClass(coordController, [{
17 key: "getOption",
18 value: function getOption(cfg) {
19 if (isString(cfg)) {
20 return {
21 type: coordMap[cfg] || Rect
22 };
23 }
24
25 if (isFunction(cfg)) {
26 return {
27 type: cfg
28 };
29 }
30
31 var _ref = cfg || {},
32 type = _ref.type;
33
34 return _objectSpread(_objectSpread({}, cfg), {}, {
35 // 默认直角坐标系
36 type: isFunction(type) ? type : coordMap[type] || Rect
37 });
38 }
39 }, {
40 key: "create",
41 value: function create(cfg, layout) {
42 var option = this.getOption(cfg);
43 var type = option.type;
44 var coord = new type(_objectSpread(_objectSpread({}, option), layout));
45 this.coord = coord;
46 return coord;
47 }
48 }, {
49 key: "updateLayout",
50 value: function updateLayout(layout) {
51 this.coord.update(layout);
52 }
53 }, {
54 key: "update",
55 value: function update() {}
56 }]);
57
58 return coordController;
59}();
60
61export default coordController;
\No newline at end of file