UNPKG

suoqiu-f2

Version:

Charts for mobile visualization.

57 lines (56 loc) 2.35 kB
"use strict"; exports.__esModule = true; exports["default"] = void 0; var _base = _interopRequireDefault(require("./base")); var _common = require("../util/common"); require("./shape/polygon"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function _inheritsLoose(t, o) { t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } var Polygon = /*#__PURE__*/function (_Geom) { function Polygon() { return _Geom.apply(this, arguments) || this; } _inheritsLoose(Polygon, _Geom); var _proto = Polygon.prototype; _proto.getDefaultCfg = function getDefaultCfg() { var cfg = _Geom.prototype.getDefaultCfg.call(this); cfg.type = 'polygon'; cfg.shapeType = 'polygon'; cfg.generatePoints = true; return cfg; }; _proto.createShapePointsCfg = function createShapePointsCfg(obj) { var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj); var self = this; var x = cfg.x; var y = cfg.y; var temp; if (!((0, _common.isArray)(x) && (0, _common.isArray)(y))) { var xScale = self.getXScale(); var yScale = self.getYScale(); var xCount = xScale.values ? xScale.values.length : xScale.ticks.length; var yCount = yScale.values ? yScale.values.length : yScale.ticks.length; var xOffset = 0.5 * 1 / xCount; var yOffset = 0.5 * 1 / yCount; if (xScale.isCategory && yScale.isCategory) { x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset]; y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset]; } else if ((0, _common.isArray)(x)) { temp = x; x = [temp[0], temp[0], temp[1], temp[1]]; y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2]; } else if ((0, _common.isArray)(y)) { temp = y; y = [temp[0], temp[1], temp[1], temp[0]]; x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2]; } cfg.x = x; cfg.y = y; } return cfg; }; return Polygon; }(_base["default"]); _base["default"].Polygon = Polygon; var _default = exports["default"] = Polygon;