view.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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.View = void 0;
  15. const util_1 = require("@antv/util");
  16. const utils_1 = require("./utils");
  17. /**
  18. * @todo Propagate more options to children.(e.g. filter)
  19. * @todo Propagate encode options to children. This is useful for Matrix composition.
  20. * @todo Move this to runtime, do not treat it as a composition to cause confusion.
  21. */
  22. const View = () => {
  23. return (options) => {
  24. const { children } = options, restOptions = __rest(options, ["children"]);
  25. if (!Array.isArray(children))
  26. return [];
  27. const { data: viewData, scale: viewScale = {}, axis: viewAxis = {}, legend: viewLegend = {}, encode: viewEncode = {}, transform: viewTransform = [] } = restOptions, rest = __rest(restOptions, ["data", "scale", "axis", "legend", "encode", "transform"]);
  28. const marks = children.map((_a) => {
  29. var { data, scale = {}, axis = {}, legend = {}, encode = {}, transform = [] } = _a, rest = __rest(_a, ["data", "scale", "axis", "legend", "encode", "transform"]);
  30. return (Object.assign({ data: (0, utils_1.mergeData)(data, viewData), scale: (0, util_1.deepMix)({}, viewScale, scale), encode: (0, util_1.deepMix)({}, viewEncode, encode), transform: [...viewTransform, ...transform], axis: axis && viewAxis ? (0, util_1.deepMix)({}, viewAxis, axis) : false, legend: legend && viewLegend ? (0, util_1.deepMix)({}, viewLegend, legend) : false }, rest));
  31. });
  32. return [Object.assign(Object.assign({}, rest), { marks, type: 'standardView' })];
  33. };
  34. };
  35. exports.View = View;
  36. exports.View.props = {};
  37. //# sourceMappingURL=view.js.map