point.js 1.3 KB

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