MCPcopy Index your code
hub / github.com/microsoft/SandDance / trellisLayout

Function trellisLayout

docs/app/js/sanddance-app.js:120511–120547  ·  view source on GitHub ↗
(view, group, opt)

Source from the content-addressed store, hash-verified

120509 return bounds;
120510}
120511function trellisLayout(view, group, opt) {
120512 var views = gridLayoutGroups(group), groups = views.marks, bbox = opt.bounds === Flush ? boundFlush : boundFull, off = opt.offset, ncols = opt.columns || groups.length, nrows = ncols <= 0 ? 1 : Math.ceil(groups.length / ncols), cells = nrows * ncols, x, y, x2, y2, anchor, band, offset; // -- initial grid layout
120513 const bounds = gridLayout(view, groups, opt);
120514 if (bounds.empty()) bounds.set(0, 0, 0, 0); // empty grid
120515 // -- layout grid headers and footers --
120516 // perform row header layout
120517 if (views.rowheaders) {
120518 band = get(opt.headerBand, Row, null);
120519 x = layoutHeaders(view, views.rowheaders, groups, ncols, nrows, -get(off, "rowHeader"), min, 0, bbox, "x1", 0, ncols, 1, band);
120520 } // perform column header layout
120521 if (views.colheaders) {
120522 band = get(opt.headerBand, Column, null);
120523 y = layoutHeaders(view, views.colheaders, groups, ncols, ncols, -get(off, "columnHeader"), min, 1, bbox, "y1", 0, 1, ncols, band);
120524 } // perform row footer layout
120525 if (views.rowfooters) {
120526 band = get(opt.footerBand, Row, null);
120527 x2 = layoutHeaders(view, views.rowfooters, groups, ncols, nrows, get(off, "rowFooter"), max, 0, bbox, "x2", ncols - 1, ncols, 1, band);
120528 } // perform column footer layout
120529 if (views.colfooters) {
120530 band = get(opt.footerBand, Column, null);
120531 y2 = layoutHeaders(view, views.colfooters, groups, ncols, ncols, get(off, "columnFooter"), max, 1, bbox, "y2", cells - ncols, 1, ncols, band);
120532 } // perform row title layout
120533 if (views.rowtitle) {
120534 anchor = get(opt.titleAnchor, Row);
120535 offset = get(off, "rowTitle");
120536 offset = anchor === End ? x2 + offset : x - offset;
120537 band = get(opt.titleBand, Row, 0.5);
120538 layoutTitle(view, views.rowtitle, offset, 0, bounds, band);
120539 } // perform column title layout
120540 if (views.coltitle) {
120541 anchor = get(opt.titleAnchor, Column);
120542 offset = get(off, "columnTitle");
120543 offset = anchor === End ? y2 + offset : y - offset;
120544 band = get(opt.titleBand, Column, 0.5);
120545 layoutTitle(view, views.coltitle, offset, 1, bounds, band);
120546 }
120547}
120548function boundFlush(item, field) {
120549 return field === "x1" ? item.x || 0 : field === "y1" ? item.y || 0 : field === "x2" ? (item.x || 0) + (item.width || 0) : field === "y2" ? (item.y || 0) + (item.height || 0) : undefined;
120550}

Callers 1

transformFunction · 0.70

Calls 6

gridLayoutGroupsFunction · 0.70
gridLayoutFunction · 0.70
getFunction · 0.70
layoutHeadersFunction · 0.70
layoutTitleFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected