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

Method iterateLayouts

packages/sanddance-specs/src/specBuilder.ts:342–403  ·  view source on GitHub ↗
(globalScope: GlobalScope, onLayoutBuild: (i: number, innerScope: InnerScope) => void)

Source from the content-addressed store, hash-verified

340 }
341
342 private iterateLayouts(globalScope: GlobalScope, onLayoutBuild: (i: number, innerScope: InnerScope) => void) {
343 let specResult: SpecResult;
344 let parentScope: InnerScope = {
345 sizeSignals: globalScope.sizeSignals,
346 offsets: globalScope.offsets,
347 };
348 let firstScope: InnerScope;
349 let childScope: InnerScope;
350 const groupings: Grouping[] = [];
351 const { layouts, specCapabilities } = this.props;
352 const allGlobalScales: GlobalScales[] = [];
353 const allEncodingRules: { [key: string]: EncodingRule[] }[] = [];
354 for (let i = 0; i < layouts.length; i++) {
355 if (!parentScope) continue;
356 const buildProps: LayoutBuildProps = {
357 globalScope,
358 parentScope,
359 axesScales: this.props.axisScales,
360 groupings,
361 id: i,
362 };
363 const layout = this.createLayout(layouts[i], buildProps);
364 try {
365 childScope = layout.build();
366 childScope.id = i;
367 const groupby = layout.getGrouping();
368 if (groupby) {
369 groupings.push({
370 id: i,
371 groupby,
372 fieldOps: [
373 { field: null, op: 'count', as: FieldNames.Count },
374 ],
375 });
376 }
377 const sumOp = layout.getAggregateSumOp();
378 if (sumOp) {
379 groupings[groupings.length - 1].fieldOps.push(sumOp);
380 }
381 onLayoutBuild(i, childScope);
382 }
383 catch (e) {
384 specResult = {
385 errors: [e.stack],
386 specCapabilities,
387 vegaSpec: null,
388 };
389 break;
390 }
391 if (childScope && childScope.globalScales) {
392 allGlobalScales.push(childScope.globalScales);
393 }
394 if (childScope.encodingRuleMap) {
395 allEncodingRules.push(childScope.encodingRuleMap);
396 }
397 if (i === 0) {
398 firstScope = childScope;
399 }

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