text.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.Text = void 0;
  4. const utils_1 = require("./utils");
  5. const Text = (options) => {
  6. const { cartesian = false } = options;
  7. if (cartesian)
  8. return utils_1.visualMark;
  9. return ((index, scale, value, coordinate) => {
  10. const { x: X, y: Y } = value;
  11. const offset = (0, utils_1.createBandOffset)(scale, value, options);
  12. const P = Array.from(index, (i) => {
  13. const p = [+X[i], +Y[i]];
  14. return [coordinate.map(offset(p, i))];
  15. });
  16. return [index, P];
  17. });
  18. };
  19. exports.Text = Text;
  20. const shapes = ['text', 'badge'];
  21. exports.Text.props = {
  22. defaultShape: 'text',
  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. { name: 'text', scale: 'identity' },
  30. { name: 'fontSize' },
  31. { name: 'rotate' },
  32. ],
  33. preInference: [
  34. ...(0, utils_1.basePreInference)(),
  35. { type: 'maybeTuple' },
  36. { type: 'maybeVisualPosition' },
  37. ],
  38. postInference: [...(0, utils_1.basePostInference)(), ...(0, utils_1.tooltip2d)()],
  39. };
  40. //# sourceMappingURL=text.js.map