* @param {number} maxWidth - the max width in pixels * @param {number} maxHeight - the max height in pixels * @param {{top: number, left: number, bottom: number, right: number}} margins - the space between the edge of the other scales and edge of the chart * This space comes from two sources
(maxWidth, maxHeight, margins)
| 391 | * - thickness of scales or legends in another orientation |
| 392 | */ |
| 393 | update(maxWidth, maxHeight, margins) { |
| 394 | const {beginAtZero, grace, ticks: tickOpts} = this.options; |
| 395 | const sampleSize = tickOpts.sampleSize; |
| 396 | |
| 397 | // Update Lifecycle - Probably don't want to ever extend or overwrite this function ;) |
| 398 | this.beforeUpdate(); |
| 399 | |
| 400 | // Absorb the master measurements |
| 401 | this.maxWidth = maxWidth; |
| 402 | this.maxHeight = maxHeight; |
| 403 | this._margins = margins = Object.assign({ |
| 404 | left: 0, |
| 405 | right: 0, |
| 406 | top: 0, |
| 407 | bottom: 0 |
| 408 | }, margins); |
| 409 | |
| 410 | this.ticks = null; |
| 411 | this._labelSizes = null; |
| 412 | this._gridLineItems = null; |
| 413 | this._labelItems = null; |
| 414 | |
| 415 | // Dimensions |
| 416 | this.beforeSetDimensions(); |
| 417 | this.setDimensions(); |
| 418 | this.afterSetDimensions(); |
| 419 | |
| 420 | this._maxLength = this.isHorizontal() |
| 421 | ? this.width + margins.left + margins.right |
| 422 | : this.height + margins.top + margins.bottom; |
| 423 | |
| 424 | // Data min/max |
| 425 | if (!this._dataLimitsCached) { |
| 426 | this.beforeDataLimits(); |
| 427 | this.determineDataLimits(); |
| 428 | this.afterDataLimits(); |
| 429 | this._range = _addGrace(this, grace, beginAtZero); |
| 430 | this._dataLimitsCached = true; |
| 431 | } |
| 432 | |
| 433 | this.beforeBuildTicks(); |
| 434 | |
| 435 | this.ticks = this.buildTicks() || []; |
| 436 | |
| 437 | // Allow modification of ticks in callback. |
| 438 | this.afterBuildTicks(); |
| 439 | |
| 440 | // Compute tick rotation and fit using a sampled subset of labels |
| 441 | // We generally don't need to compute the size of every single label for determining scale size |
| 442 | const samplingEnabled = sampleSize < this.ticks.length; |
| 443 | this._convertTicksToLabels(samplingEnabled ? sample(this.ticks, sampleSize) : this.ticks); |
| 444 | |
| 445 | // configure is called twice, once here, once from core.controller.updateLayout. |
| 446 | // Here we haven't been positioned yet, but dimensions are correct. |
| 447 | // Variables set in configure are needed for calculateLabelRotation, and |
| 448 | // it's ok that coordinates are not correct there, only dimensions matter. |
| 449 | this.configure(); |
| 450 |
nothing calls this directly
no test coverage detected