MCPcopy
hub / github.com/chartjs/Chart.js / setLayoutDims

Function setLayoutDims

src/core/core.layouts.js:65–83  ·  view source on GitHub ↗

* store dimensions used instead of available chartArea in fitBoxes

(layouts, params)

Source from the content-addressed store, hash-verified

63 * store dimensions used instead of available chartArea in fitBoxes
64 **/
65function setLayoutDims(layouts, params) {
66 const stacks = buildStacks(layouts);
67 const {vBoxMaxWidth, hBoxMaxHeight} = params;
68 let i, ilen, layout;
69 for (i = 0, ilen = layouts.length; i < ilen; ++i) {
70 layout = layouts[i];
71 const {fullSize} = layout.box;
72 const stack = stacks[layout.stack];
73 const factor = stack && layout.stackWeight / stack.weight;
74 if (layout.horizontal) {
75 layout.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;
76 layout.height = hBoxMaxHeight;
77 } else {
78 layout.width = vBoxMaxWidth;
79 layout.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;
80 }
81 }
82 return stacks;
83}
84
85function buildLayoutBoxes(boxes) {
86 const layoutBoxes = wrapBoxes(boxes);

Callers 1

updateFunction · 0.85

Calls 1

buildStacksFunction · 0.85

Tested by

no test coverage detected