shape.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Shape = void 0;
  4. const utils_1 = require("./utils");
  5. /**
  6. * @todo Unify with text, image and point.
  7. */
  8. const Shape = (options) => {
  9. const { cartesian } = options;
  10. if (cartesian)
  11. return utils_1.visualMark;
  12. return (index, scale, value, coordinate) => {
  13. const { x: X, y: Y } = value;
  14. const offset = (0, utils_1.createBandOffset)(scale, value, options);
  15. const P = Array.from(index, (i) => {
  16. const p = [+X[i], +Y[i]];
  17. return [coordinate.map(offset(p, i))];
  18. });
  19. return [index, P];
  20. };
  21. };
  22. exports.Shape = Shape;
  23. exports.Shape.props = {
  24. defaultShape: 'shape',
  25. defaultLabelShape: 'label',
  26. composite: false,
  27. channels: [
  28. { name: 'x', required: true },
  29. { name: 'y', required: true },
  30. ],
  31. preInference: [
  32. ...(0, utils_1.basePreInference)(),
  33. { type: 'maybeTuple' },
  34. { type: 'maybeVisualPosition' },
  35. { type: 'maybeFunctionAttribute' },
  36. ],
  37. };
  38. //# sourceMappingURL=shape.js.map