UNPKG

suoqiu-f2

Version:

Charts for mobile visualization.

97 lines (96 loc) 3.42 kB
"use strict"; exports.__esModule = true; exports["default"] = void 0; var _common = require("../../util/common"); var _rect = _interopRequireDefault(require("./shape/rect")); var _container = _interopRequireDefault(require("./container")); var _vector = _interopRequireDefault(require("../util/vector2")); 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 Group = /*#__PURE__*/function (_Rect) { function Group() { return _Rect.apply(this, arguments) || this; } _inheritsLoose(Group, _Rect); var _proto = Group.prototype; _proto._initProperties = function _initProperties() { this._attrs = { type: 'group', zIndex: 0, visible: true, destroyed: false, isGroup: true, canFill: true, canStroke: true, attrs: {}, children: [] }; }; _proto.getBBox = function getBBox() { var self = this; var minX = Infinity; var maxX = -Infinity; var minY = Infinity; var maxY = -Infinity; var children = self.get('children'); for (var i = 0, length = children.length; i < length; i++) { var child = children[i]; if (child.get('visible')) { var box = child.getBBox(); if (!box) { continue; } var leftTop = [box.minX, box.minY]; var leftBottom = [box.minX, box.maxY]; var rightTop = [box.maxX, box.minY]; var rightBottom = [box.maxX, box.maxY]; var matrix = child.attr('matrix'); _vector["default"].transformMat2d(leftTop, leftTop, matrix); _vector["default"].transformMat2d(leftBottom, leftBottom, matrix); _vector["default"].transformMat2d(rightTop, rightTop, matrix); _vector["default"].transformMat2d(rightBottom, rightBottom, matrix); minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX); maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX); minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY); maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY); } } return { minX: minX, minY: minY, maxX: maxX, maxY: maxY, x: minX, y: minY, width: maxX - minX, height: maxY - minY }; }; _proto.createPath = function createPath(context) { var attrs = this.get('attrs'); // 只有在有fillStyle或strokeStyle 时才需要绘制 if (!attrs.fillStyle && !attrs.strokeStyle) { return; } _Rect.prototype.createPath.call(this, context); }; _proto.drawInner = function drawInner(context) { _Rect.prototype.drawInner.call(this, context); this.drawChildren(context); }; _proto.destroy = function destroy() { if (this.get('destroyed')) { return; } this.clear(); _Rect.prototype.destroy.call(this); }; return Group; }(_rect["default"]); (0, _common.mix)(Group.prototype, _container["default"], { getGroupClass: function getGroupClass() { return Group; } }); var _default = exports["default"] = Group;