link.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Link = void 0;
  4. const utils_1 = require("./utils");
  5. /**
  6. * Connect `start` to `end` with single line.
  7. */
  8. const Link = (options) => {
  9. return (index, scale, value, coordinate) => {
  10. const { x: X, y: Y, x1: X1 = X, y1: Y1 = Y } = value;
  11. const offset = (0, utils_1.createBandOffset)(scale, value, options);
  12. const P = index.map((i) => [
  13. coordinate.map(offset([+X[i], +Y[i]], i)),
  14. coordinate.map(offset([+X1[i], +Y1[i]], i)),
  15. ]);
  16. return [index, P];
  17. };
  18. };
  19. exports.Link = Link;
  20. const shapes = ['link', 'arc', 'vhv', 'smooth'];
  21. exports.Link.props = {
  22. defaultShape: 'link',
  23. defaultLabelShape: 'label',
  24. composite: false,
  25. channels: [
  26. ...(0, utils_1.baseGeometryChannels)({ shapes }),
  27. { name: 'x', required: true },
  28. { name: 'y', required: true },
  29. ],
  30. preInference: [
  31. ...(0, utils_1.basePreInference)(),
  32. { type: 'maybeIdentityY' },
  33. { type: 'maybeIdentityX' },
  34. ],
  35. postInference: [...(0, utils_1.basePostInference)(), ...(0, utils_1.tooltip2d)()],
  36. };
  37. //# sourceMappingURL=link.js.map