link.js 1.1 KB

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