* 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)
| 688 | * @private |
| 689 | */ |
| 690 | _updateLayout(minPadding) { |
| 691 | if (this.notifyPlugins('beforeLayout', {cancelable: true}) === false) { |
| 692 | return; |
| 693 | } |
| 694 | |
| 695 | layouts.update(this, this.width, this.height, minPadding); |
| 696 | |
| 697 | const area = this.chartArea; |
| 698 | const noArea = area.width <= 0 || area.height <= 0; |
| 699 | |
| 700 | this._layers = []; |
| 701 | each(this.boxes, (box) => { |
| 702 | if (noArea && box.position === 'chartArea') { |
| 703 | // Skip drawing and configuring chartArea boxes when chartArea is zero or negative |
| 704 | return; |
| 705 | } |
| 706 | |
| 707 | // configure is called twice, once in core.scale.update and once here. |
| 708 | // Here the boxes are fully updated and at their final positions. |
| 709 | if (box.configure) { |
| 710 | box.configure(); |
| 711 | } |
| 712 | this._layers.push(...box._layers()); |
| 713 | }, this); |
| 714 | |
| 715 | this._layers.forEach((item, index) => { |
| 716 | item._idx = index; |
| 717 | }); |
| 718 | |
| 719 | this.notifyPlugins('afterLayout'); |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Updates all datasets unless a plugin returns `false` to the `beforeDatasetsUpdate` |