MCPcopy Create free account
hub / github.com/microsoft/SandDance / iterateLayouts

Method iterateLayouts

docs/app/js/sanddance-app.js:2849–2911  ·  view source on GitHub ↗
(globalScope, onLayoutBuild)

Source from the content-addressed store, hash-verified

2847 };
2848 }
2849 iterateLayouts(globalScope, onLayoutBuild) {
2850 let specResult;
2851 let parentScope = {
2852 sizeSignals: globalScope.sizeSignals,
2853 offsets: globalScope.offsets
2854 };
2855 let firstScope;
2856 let childScope;
2857 const groupings = [];
2858 let { layouts , specCapabilities } = this.props;
2859 const allGlobalScales = [];
2860 const allEncodingRules = [];
2861 for(let i = 0; i < layouts.length; i++){
2862 if (!parentScope) continue;
2863 let buildProps = {
2864 globalScope,
2865 parentScope,
2866 axesScales: this.props.axisScales,
2867 groupings,
2868 id: i
2869 };
2870 let layout = this.createLayout(layouts[i], buildProps);
2871 try {
2872 childScope = layout.build();
2873 childScope.id = i;
2874 let groupby = layout.getGrouping();
2875 if (groupby) groupings.push({
2876 id: i,
2877 groupby,
2878 fieldOps: [
2879 {
2880 field: null,
2881 op: "count",
2882 as: (0, _constants.FieldNames).Count
2883 }
2884 ]
2885 });
2886 let sumOp = layout.getAggregateSumOp();
2887 if (sumOp) groupings[groupings.length - 1].fieldOps.push(sumOp);
2888 onLayoutBuild(i, childScope);
2889 } catch (e) {
2890 specResult = {
2891 errors: [
2892 e.stack
2893 ],
2894 specCapabilities,
2895 vegaSpec: null
2896 };
2897 break;
2898 }
2899 if (childScope && childScope.globalScales) allGlobalScales.push(childScope.globalScales);
2900 if (childScope.encodingRuleMap) allEncodingRules.push(childScope.encodingRuleMap);
2901 if (i === 0) firstScope = childScope;
2902 parentScope = childScope;
2903 }
2904 return {
2905 firstScope,
2906 finalScope: parentScope,

Callers 1

buildMethod · 0.95

Calls 4

createLayoutMethod · 0.95
buildMethod · 0.45
getGroupingMethod · 0.45
getAggregateSumOpMethod · 0.45

Tested by

no test coverage detected