maybeVisualPosition.js 1.6 KB

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