polygon.js 1.3 KB

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