line.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 Line =
  5. /*#__PURE__*/
  6. function (_GuideBase) {
  7. _inheritsLoose(Line, _GuideBase);
  8. function Line() {
  9. return _GuideBase.apply(this, arguments) || this;
  10. }
  11. var _proto = Line.prototype;
  12. _proto._initDefaultCfg = function _initDefaultCfg() {
  13. this.type = 'line';
  14. this.start = [];
  15. this.end = [];
  16. this.style = {
  17. stroke: '#000',
  18. lineWidth: 1
  19. };
  20. };
  21. _proto.render = function render(coord, container) {
  22. var points = [];
  23. points[0] = this.parsePoint(coord, this.start);
  24. points[1] = this.parsePoint(coord, this.end);
  25. if (!points[0] || !points[1]) {
  26. return;
  27. }
  28. var shape = container.addShape('Line', {
  29. className: 'guide-line',
  30. attrs: Util.mix({
  31. x1: points[0].x,
  32. y1: points[0].y,
  33. x2: points[1].x,
  34. y2: points[1].y
  35. }, this.style)
  36. });
  37. this.element = shape;
  38. return shape;
  39. };
  40. return Line;
  41. }(GuideBase);
  42. GuideBase.Line = Line;
  43. module.exports = Line;