(mode)
| 483 | } |
| 484 | |
| 485 | update(mode) { |
| 486 | const config = this.config; |
| 487 | |
| 488 | config.update(); |
| 489 | const options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext()); |
| 490 | const animsDisabled = this._animationsDisabled = !options.animation; |
| 491 | |
| 492 | this._updateScales(); |
| 493 | this._checkEventBindings(); |
| 494 | this._updateHiddenIndices(); |
| 495 | |
| 496 | // plugins options references might have change, let's invalidate the cache |
| 497 | // https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 |
| 498 | this._plugins.invalidate(); |
| 499 | |
| 500 | if (this.notifyPlugins('beforeUpdate', {mode, cancelable: true}) === false) { |
| 501 | return; |
| 502 | } |
| 503 | |
| 504 | // Make sure dataset controllers are updated and new controllers are reset |
| 505 | const newControllers = this.buildOrUpdateControllers(); |
| 506 | |
| 507 | this.notifyPlugins('beforeElementsUpdate'); |
| 508 | |
| 509 | // Make sure all dataset controllers have correct meta data counts |
| 510 | let minPadding = 0; |
| 511 | for (let i = 0, ilen = this.data.datasets.length; i < ilen; i++) { |
| 512 | const {controller} = this.getDatasetMeta(i); |
| 513 | const reset = !animsDisabled && newControllers.indexOf(controller) === -1; |
| 514 | // New controllers will be reset after the layout pass, so we only want to modify |
| 515 | // elements added to new datasets |
| 516 | controller.buildOrUpdateElements(reset); |
| 517 | minPadding = Math.max(+controller.getMaxOverflow(), minPadding); |
| 518 | } |
| 519 | minPadding = this._minPadding = options.layout.autoPadding ? minPadding : 0; |
| 520 | this._updateLayout(minPadding); |
| 521 | |
| 522 | // Only reset the controllers if we have animations |
| 523 | if (!animsDisabled) { |
| 524 | // Can only reset the new controllers after the scales have been updated |
| 525 | // Reset is done to get the starting point for the initial animation |
| 526 | each(newControllers, (controller) => { |
| 527 | controller.reset(); |
| 528 | }); |
| 529 | } |
| 530 | |
| 531 | this._deactivateHidden(); |
| 532 | this._updateDatasets(mode); |
| 533 | |
| 534 | // Do this before render so that any plugins that need final scale updates can use it |
| 535 | this.notifyPlugins('afterUpdate', {mode}); |
| 536 | |
| 537 | this._layers.sort(compare2Level('z', '_idx')); |
| 538 | |
| 539 | this._replayActive(); |
| 540 | |
| 541 | this.render(); |
| 542 | } |
no test coverage detected