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

Method _updateLayout

src/core/core.controller.js:611–641  ·  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

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