line.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = void 0;
  4. var _common = require("../../util/common");
  5. var _base = _interopRequireDefault(require("./base"));
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8. var Line = /*#__PURE__*/function (_GuideBase) {
  9. _inheritsLoose(Line, _GuideBase);
  10. function Line() {
  11. return _GuideBase.apply(this, arguments) || this;
  12. }
  13. var _proto = Line.prototype;
  14. _proto._initDefaultCfg = function _initDefaultCfg() {
  15. this.type = 'line';
  16. this.start = [];
  17. this.end = [];
  18. this.style = {
  19. stroke: '#000',
  20. lineWidth: 1
  21. };
  22. };
  23. _proto.render = function render(coord, container) {
  24. var points = [];
  25. points[0] = this.parsePoint(coord, this.start);
  26. points[1] = this.parsePoint(coord, this.end);
  27. if (!points[0] || !points[1]) {
  28. return;
  29. }
  30. var shape = container.addShape('Line', {
  31. className: 'guide-line',
  32. attrs: (0, _common.mix)({
  33. x1: points[0].x,
  34. y1: points[0].y,
  35. x2: points[1].x,
  36. y2: points[1].y
  37. }, this.style)
  38. });
  39. this.element = shape;
  40. return shape;
  41. };
  42. return Line;
  43. }(_base["default"]);
  44. _base["default"].Line = Line;
  45. var _default = Line;
  46. exports["default"] = _default;