point.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 Geom = require('./base');
  10. require('./shape/point');
  11. var Point = /*#__PURE__*/function (_Geom) {
  12. (0, _inheritsLoose2["default"])(Point, _Geom);
  13. var _super = _createSuper(Point);
  14. function Point() {
  15. return _Geom.apply(this, arguments) || this;
  16. }
  17. var _proto = Point.prototype;
  18. _proto.getDefaultCfg = function getDefaultCfg() {
  19. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  20. cfg.type = 'point';
  21. cfg.shapeType = 'point';
  22. cfg.generatePoints = false;
  23. return cfg;
  24. };
  25. _proto.draw = function draw(data, shapeFactory) {
  26. var self = this;
  27. var container = self.get('container');
  28. Util.each(data, function (obj) {
  29. var shape = obj.shape;
  30. var cfg = self.getDrawCfg(obj);
  31. if (Util.isArray(obj.y)) {
  32. var hasStack = self.hasAdjust('stack');
  33. Util.each(obj.y, function (y, idx) {
  34. cfg.y = y;
  35. if (!hasStack || idx !== 0) {
  36. self.drawShape(shape, obj, cfg, container, shapeFactory);
  37. }
  38. });
  39. } else if (!Util.isNil(obj.y)) {
  40. self.drawShape(shape, obj, cfg, container, shapeFactory);
  41. }
  42. });
  43. };
  44. return Point;
  45. }(Geom);
  46. Geom.Point = Point;
  47. module.exports = Point;