point.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
  4. var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
  5. var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
  6. function _createSuper(Derived) { return function () { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
  7. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  8. var Util = require('../../util/common');
  9. var GuideBase = require('./base');
  10. var Point = /*#__PURE__*/function (_GuideBase) {
  11. (0, _inheritsLoose2["default"])(Point, _GuideBase);
  12. var _super = _createSuper(Point);
  13. function Point() {
  14. return _GuideBase.apply(this, arguments) || this;
  15. }
  16. var _proto = Point.prototype;
  17. _proto._initDefaultCfg = function _initDefaultCfg() {
  18. this.type = 'point';
  19. this.position = null;
  20. this.offsetX = 0;
  21. this.offsetY = 0;
  22. this.style = {
  23. fill: '#1890FF',
  24. r: 3,
  25. lineWidth: 1,
  26. stroke: '#fff'
  27. };
  28. };
  29. _proto.render = function render(coord, container) {
  30. var position = this.parsePoint(coord, this.position);
  31. if (!position) return null;
  32. var shape = container.addShape('Circle', {
  33. className: 'guide-point',
  34. attrs: Util.mix({
  35. x: position.x + this.offsetX,
  36. y: position.y + this.offsetY
  37. }, this.style)
  38. });
  39. this.element = shape;
  40. return shape;
  41. };
  42. return Point;
  43. }(GuideBase);
  44. GuideBase.Point = Point;
  45. module.exports = Point;