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

Function fitBoxes

src/core/core.layouts.js:179–207  ·  src/core/core.layouts.js::fitBoxes
(boxes, chartArea, params, stacks)

Source from the content-addressed store, hash-verified

177}
178
179function fitBoxes(boxes, chartArea, params, stacks) {
180 const refitBoxes = [];
181 let i, ilen, layout, box, refit, changed;
182
183 for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) {
184 layout = boxes[i];
185 box = layout.box;
186
187 box.update(
188 layout.width || chartArea.w,
189 layout.height || chartArea.h,
190 getMargins(layout.horizontal, chartArea)
191 );
192 const {same, other} = updateDims(chartArea, params, layout, stacks);
193
194 class="cm">// Dimensions changed and there were non full width boxes before this
195 class="cm">// -> we have to refit those
196 refit |= same && refitBoxes.length;
197
198 class="cm">// Chart area changed in the opposite direction
199 changed = changed || other;
200
201 if (!box.fullSize) { class="cm">// fullSize boxes don't need to be re-fitted in any case
202 refitBoxes.push(layout);
203 }
204 }
205
206 return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;
207}
208
209function setBoxDims(box, left, top, width, height) {
210 box.top = top;

Callers 1

updateFunction · 0.85

Calls 3

getMarginsFunction · 0.85
updateDimsFunction · 0.85
updateMethod · 0.65

Tested by

no test coverage detected