spider.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. var __rest = (this && this.__rest) || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5. t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  7. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  8. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  9. t[p[i]] = s[p[i]];
  10. }
  11. return t;
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.spider = void 0;
  15. const coordinate_1 = require("../../../utils/coordinate");
  16. const outside_1 = require("./outside");
  17. /**
  18. * Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
  19. */
  20. function spider(position, points, value, coordinate) {
  21. if (!(0, coordinate_1.isCircular)(coordinate))
  22. return {};
  23. const { connectorLength, connectorLength2, connectorDistance } = value;
  24. const style = __rest((0, outside_1.inferOutsideCircularStyle)('outside', points, value, coordinate), []);
  25. const center = coordinate.getCenter();
  26. const radius = (0, outside_1.radiusOf)(points, value, coordinate);
  27. const angle = (0, outside_1.angleOf)(points, value, coordinate);
  28. const radius1 = radius + connectorLength + connectorLength2;
  29. const sign = Math.sin(angle) > 0 ? 1 : -1;
  30. const newX = center[0] + (radius1 + +connectorDistance) * sign;
  31. const { x: originX } = style;
  32. const dx = newX - originX;
  33. style.x += dx;
  34. style.connectorPoints[0][0] -= dx;
  35. return style;
  36. }
  37. exports.spider = spider;
  38. //# sourceMappingURL=spider.js.map