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

Method _resize

src/core/core.controller.js:282–311  ·  view source on GitHub ↗
(width, height)

Source from the content-addressed store, hash-verified

280 }
281
282 _resize(width, height) {
283 const options = this.options;
284 const canvas = this.canvas;
285 const aspectRatio = options.maintainAspectRatio && this.aspectRatio;
286 const newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio);
287 const newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();
288 const mode = this.width ? 'resize' : 'attach';
289
290 this.width = newSize.width;
291 this.height = newSize.height;
292 this._aspectRatio = this.aspectRatio;
293 if (!retinaScale(this, newRatio, true)) {
294 return;
295 }
296
297 this.notifyPlugins('resize', {size: newSize});
298
299 callCallback(options.onResize, [this, newSize], this);
300
301 if (this.attached && this.canvas) {
302 if (mode === 'attach' || !this.chartArea) {
303 // A delayed update is preceded by a draw of the current state. There is no such state
304 // before the first update or after the chart was detached, so update right away.
305 this.update(mode);
306 } else if (this._doResize(mode)) {
307 // The resize update is delayed, only draw without updating.
308 this.render();
309 }
310 }
311 }
312
313 ensureScalesHaveIDs() {
314 const options = this.options;

Callers 3

resizeMethod · 0.95
drawMethod · 0.95
bindResponsiveEventsMethod · 0.95

Calls 6

notifyPluginsMethod · 0.95
updateMethod · 0.95
renderMethod · 0.95
retinaScaleFunction · 0.85
getMaximumSizeMethod · 0.45
getDevicePixelRatioMethod · 0.45

Tested by

no test coverage detected