path.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2. var Geom = require('./base');
  3. var ShapeUtil = require('./shape/util');
  4. var Util = require('../util/common');
  5. require('./shape/line');
  6. var Path =
  7. /*#__PURE__*/
  8. function (_Geom) {
  9. _inheritsLoose(Path, _Geom);
  10. function Path() {
  11. return _Geom.apply(this, arguments) || this;
  12. }
  13. var _proto = Path.prototype;
  14. _proto.getDefaultCfg = function getDefaultCfg() {
  15. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  16. cfg.type = 'path';
  17. cfg.shapeType = 'line';
  18. return cfg;
  19. };
  20. _proto.getDrawCfg = function getDrawCfg(obj) {
  21. var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
  22. cfg.isStack = this.hasAdjust('stack');
  23. return cfg;
  24. };
  25. _proto.draw = function draw(data, shapeFactory) {
  26. var self = this;
  27. var container = self.get('container');
  28. var yScale = self.getYScale();
  29. var connectNulls = self.get('connectNulls');
  30. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  31. var cfg = this.getDrawCfg(data[0]);
  32. cfg.origin = data;
  33. Util.each(splitArray, function (subData, splitedIndex) {
  34. cfg.splitedIndex = splitedIndex;
  35. cfg.points = subData;
  36. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  37. });
  38. };
  39. return Path;
  40. }(Geom);
  41. Geom.Path = Path;
  42. module.exports = Path;