label.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var tslib_1 = require("tslib");
  4. var g2_1 = require("@antv/g2");
  5. // Step 1
  6. // 自定义 Label 类
  7. // 需要继承 GeometryLabel 基类
  8. var VennLabel = /** @class */ (function (_super) {
  9. tslib_1.__extends(VennLabel, _super);
  10. function VennLabel() {
  11. return _super !== null && _super.apply(this, arguments) || this;
  12. }
  13. /**
  14. * 获取每个 label 的位置
  15. * @param labelCfg
  16. * @param mappingData
  17. * @param index
  18. * @returns label point
  19. */
  20. VennLabel.prototype.getLabelPoint = function (labelCfg, mappingData, index) {
  21. var _a = labelCfg.data, x = _a.x, y = _a.y;
  22. var _b = labelCfg.customLabelInfo, offsetX = _b.offsetX, offsetY = _b.offsetY;
  23. return {
  24. content: labelCfg.content[index],
  25. x: x + offsetX,
  26. y: y + offsetY,
  27. };
  28. };
  29. return VennLabel;
  30. }(g2_1.GeometryLabel));
  31. // Step 2: 注册 CustomLabel
  32. (0, g2_1.registerGeometryLabel)('venn', VennLabel);
  33. //# sourceMappingURL=label.js.map