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

Function placeBoxes

src/core/core.layouts.js:218–259  ·  view source on GitHub ↗
(boxes, chartArea, params, stacks)

Source from the content-addressed store, hash-verified

216}
217
218function placeBoxes(boxes, chartArea, params, stacks) {
219 const userPadding = params.padding;
220 let {x, y} = chartArea;
221
222 for (const layout of boxes) {
223 const box = layout.box;
224 const stack = stacks[layout.stack] || {count: 1, placed: 0, weight: 1};
225 const weight = (layout.stackWeight / stack.weight) || 1;
226 if (layout.horizontal) {
227 const width = chartArea.w * weight;
228 const height = stack.size || box.height;
229 if (defined(stack.start)) {
230 y = stack.start;
231 }
232 if (box.fullSize) {
233 setBoxDims(box, userPadding.left, y, params.outerWidth - userPadding.right - userPadding.left, height);
234 } else {
235 setBoxDims(box, chartArea.left + stack.placed, y, width, height);
236 }
237 stack.start = y;
238 stack.placed += width;
239 y = box.bottom;
240 } else {
241 const height = chartArea.h * weight;
242 const width = stack.size || box.width;
243 if (defined(stack.start)) {
244 x = stack.start;
245 }
246 if (box.fullSize) {
247 setBoxDims(box, x, userPadding.top, width, params.outerHeight - userPadding.bottom - userPadding.top);
248 } else {
249 setBoxDims(box, x, chartArea.top + stack.placed, width, height);
250 }
251 stack.start = x;
252 stack.placed += height;
253 x = box.right;
254 }
255 }
256
257 chartArea.x = x;
258 chartArea.y = y;
259}
260
261/**
262 * @interface LayoutItem

Callers 1

updateFunction · 0.85

Calls 2

definedFunction · 0.85
setBoxDimsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…