area.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2. /**
  3. * @fileOverview area geometry
  4. * @author dxq613 @gmail.com
  5. * @author sima.zhang1990@gmail.com
  6. */
  7. var Geom = require('./base');
  8. var ShapeUtil = require('./shape/util');
  9. var Util = require('../util/common');
  10. require('./shape/area');
  11. var Area =
  12. /*#__PURE__*/
  13. function (_Geom) {
  14. _inheritsLoose(Area, _Geom);
  15. function Area() {
  16. return _Geom.apply(this, arguments) || this;
  17. }
  18. var _proto = Area.prototype;
  19. /**
  20. * get the default configuration
  21. * @protected
  22. * @return {Object} return the result
  23. */
  24. _proto.getDefaultCfg = function getDefaultCfg() {
  25. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  26. cfg.type = 'area';
  27. cfg.shapeType = 'area';
  28. cfg.generatePoints = true;
  29. cfg.sortable = true;
  30. return cfg;
  31. };
  32. _proto.draw = function draw(data, shapeFactory) {
  33. var self = this;
  34. var container = self.get('container');
  35. var cfg = this.getDrawCfg(data[0]);
  36. var yScale = self.getYScale();
  37. var connectNulls = self.get('connectNulls');
  38. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  39. cfg.origin = data;
  40. Util.each(splitArray, function (subData, splitedIndex) {
  41. cfg.splitedIndex = splitedIndex;
  42. var points = subData.map(function (obj) {
  43. return obj.points;
  44. });
  45. cfg.points = points;
  46. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  47. });
  48. };
  49. return Area;
  50. }(Geom);
  51. Geom.Area = Area;
  52. module.exports = Area;