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

Method _updateLayout

src/core/core.controller.js:615–645  ·  view source on GitHub ↗

* Updates the chart layout unless a plugin returns `false` to the `beforeLayout` * hook, in which case, plugins will not be called on `afterLayout`. * @private

(minPadding)

Source from the content-addressed store, hash-verified

613 * @private
614 */
615 _updateLayout(minPadding) {
616 if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) {
617 return;
618 }
619
620 layouts.update(this, this.width, this.height, minPadding);
621
622 const area = this.chartArea;
623 const noArea = area.width <= 0 || area.height <= 0;
624
625 this._layers = [];
626 each(this.boxes, (box) => {
627 if (noArea && box.position === 'chartArea') {
628 // Skip drawing and configuring chartArea boxes when chartArea is zero or negative
629 return;
630 }
631
632 // configure is called twice, once in core.scale.update and once here.
633 // Here the boxes are fully updated and at their final positions.
634 if (box.configure) {
635 box.configure();
636 }
637 this._layers.push(...box._layers());
638 }, this);
639
640 this._layers.forEach((item, index) => {
641 item._idx = index;
642 });
643
644 this.notifyPlugins('afterLayout');
645 }
646
647 /**
648 * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate`

Callers 1

updateMethod · 0.95

Calls 5

notifyPluginsMethod · 0.95
eachFunction · 0.85
_layersMethod · 0.80
updateMethod · 0.65
configureMethod · 0.65

Tested by

no test coverage detected