maybeVisualPosition.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var __rest = (this && this.__rest) || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5. t[p] = s[p];
  6. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  7. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  8. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  9. t[p[i]] = s[p[i]];
  10. }
  11. return t;
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.MaybeVisualPosition = void 0;
  15. const util_1 = require("@antv/util");
  16. const helper_1 = require("./utils/helper");
  17. /**
  18. * Set visual position with style.x and style.y.
  19. * The priority of style.x, style.y is higher than data.
  20. */
  21. const MaybeVisualPosition = () => {
  22. return (I, mark) => {
  23. const { data, style = {} } = mark, restMark = __rest(mark, ["data", "style"]);
  24. const { x: x0, y: y0 } = style, rest = __rest(style, ["x", "y"]);
  25. if (x0 == undefined || y0 == undefined)
  26. return [I, mark];
  27. const x = x0 || 0;
  28. const y = y0 || 0;
  29. return [
  30. [0],
  31. (0, util_1.deepMix)({}, restMark, {
  32. data: [0],
  33. cartesian: true,
  34. encode: {
  35. x: (0, helper_1.column)([x]),
  36. y: (0, helper_1.column)([y]),
  37. },
  38. scale: {
  39. x: { type: 'identity', independent: true, guide: null },
  40. y: { type: 'identity', independent: true, guide: null }, // hide axis
  41. },
  42. style: rest,
  43. }),
  44. ];
  45. };
  46. };
  47. exports.MaybeVisualPosition = MaybeVisualPosition;
  48. exports.MaybeVisualPosition.props = {};
  49. //# sourceMappingURL=maybeVisualPosition.js.map