MCPcopy Create free account
hub / github.com/chartjs/Chart.js / addBox

Function addBox

src/core/core.layouts.js:291–311  ·  view source on GitHub ↗

* Register a box to a chart. * A box is simply a reference to an object that requires layout. eg. Scales, Legend, Title. * @param {Chart} chart - the chart to use * @param {LayoutItem} item - the item to add to be laid out

(chart, item)

Source from the content-addressed store, hash-verified

289 * @param {LayoutItem} item - the item to add to be laid out
290 */
291 addBox(chart, item) {
292 if (!chart.boxes) {
293 chart.boxes = [];
294 }
295
296 // initialize item with default values
297 item.fullSize = item.fullSize || false;
298 item.position = item.position || 'top';
299 item.weight = item.weight || 0;
300 // @ts-ignore
301 item._layers = item._layers || function() {
302 return [{
303 z: 0,
304 draw(chartArea) {
305 item.draw(chartArea);
306 }
307 }];
308 };
309
310 chart.boxes.push(item);
311 },
312
313 /**
314 * Remove a layoutItem from a chart

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected