spider.js 1.5 KB

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