view.js 1.9 KB

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