rect.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2. var Util = require('../../util/common');
  3. var GuideBase = require('./base');
  4. var Rect =
  5. /*#__PURE__*/
  6. function (_GuideBase) {
  7. _inheritsLoose(Rect, _GuideBase);
  8. function Rect() {
  9. return _GuideBase.apply(this, arguments) || this;
  10. }
  11. var _proto = Rect.prototype;
  12. _proto._initDefaultCfg = function _initDefaultCfg() {
  13. this.type = 'rect';
  14. this.start = [];
  15. this.end = [];
  16. this.style = {
  17. fill: '#CCD7EB',
  18. opacity: 0.4
  19. };
  20. };
  21. _proto.render = function render(coord, container) {
  22. var start = this.parsePoint(coord, this.start);
  23. var end = this.parsePoint(coord, this.end);
  24. if (!start || !end) {
  25. return;
  26. }
  27. var shape = container.addShape('rect', {
  28. className: 'guide-rect',
  29. attrs: Util.mix({
  30. x: Math.min(start.x, end.x),
  31. y: Math.min(start.y, end.y),
  32. width: Math.abs(end.x - start.x),
  33. height: Math.abs(start.y - end.y)
  34. }, this.style)
  35. });
  36. this.element = shape;
  37. return shape;
  38. };
  39. return Rect;
  40. }(GuideBase);
  41. GuideBase.Rect = Rect;
  42. module.exports = Rect;