polygon.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import { __extends } from "tslib";
  2. /**
  3. * @fileoverview polygon
  4. * @author dengfuping_develop@163.com
  5. */
  6. import { each, isArray } from '@antv/util';
  7. import { SVG_ATTR_MAP } from '../constant';
  8. import ShapeBase from './base';
  9. var Polygon = /** @class */ (function (_super) {
  10. __extends(Polygon, _super);
  11. function Polygon() {
  12. var _this = _super !== null && _super.apply(this, arguments) || this;
  13. _this.type = 'polygon';
  14. _this.canFill = true;
  15. _this.canStroke = true;
  16. return _this;
  17. }
  18. Polygon.prototype.createPath = function (context, targetAttrs) {
  19. var attrs = this.attr();
  20. var el = this.get('el');
  21. each(targetAttrs || attrs, function (value, attr) {
  22. if (attr === 'points' && isArray(value) && value.length >= 2) {
  23. el.setAttribute('points', value.map(function (point) { return point[0] + "," + point[1]; }).join(' '));
  24. }
  25. else if (SVG_ATTR_MAP[attr]) {
  26. el.setAttribute(SVG_ATTR_MAP[attr], value);
  27. }
  28. });
  29. };
  30. return Polygon;
  31. }(ShapeBase));
  32. export default Polygon;
  33. //# sourceMappingURL=polygon.js.map