mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 04:39:06 +02:00
Merge pull request #1854 from nnnick/fix/1853
Do not force resize if the size has not changed
This commit is contained in:
commit
8cfa60c04d
@ -63,6 +63,7 @@
|
|||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
this.resetElements();
|
this.resetElements();
|
||||||
this.initToolTip();
|
this.initToolTip();
|
||||||
|
this.draw();
|
||||||
this.update();
|
this.update();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@ -83,17 +84,19 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
resize: function resize(silent) {
|
resize: function resize(silent) {
|
||||||
this.stop();
|
|
||||||
var canvas = this.chart.canvas;
|
var canvas = this.chart.canvas;
|
||||||
var newWidth = helpers.getMaximumWidth(this.chart.canvas);
|
var newWidth = helpers.getMaximumWidth(this.chart.canvas);
|
||||||
var newHeight = (this.options.maintainAspectRatio && isNaN(this.chart.aspectRatio) === false && isFinite(this.chart.aspectRatio) && this.chart.aspectRatio !== 0) ? newWidth / this.chart.aspectRatio : helpers.getMaximumHeight(this.chart.canvas);
|
var newHeight = (this.options.maintainAspectRatio && isNaN(this.chart.aspectRatio) === false && isFinite(this.chart.aspectRatio) && this.chart.aspectRatio !== 0) ? newWidth / this.chart.aspectRatio : helpers.getMaximumHeight(this.chart.canvas);
|
||||||
|
|
||||||
|
var sizeChanged = this.chart.width !== newWidth || this.chart.height !== newHeight;
|
||||||
|
|
||||||
canvas.width = this.chart.width = newWidth;
|
canvas.width = this.chart.width = newWidth;
|
||||||
canvas.height = this.chart.height = newHeight;
|
canvas.height = this.chart.height = newHeight;
|
||||||
|
|
||||||
helpers.retinaScale(this.chart);
|
helpers.retinaScale(this.chart);
|
||||||
|
|
||||||
if (!silent) {
|
if (!silent && sizeChanged) {
|
||||||
|
this.stop();
|
||||||
this.update(this.options.responsiveAnimationDuration);
|
this.update(this.options.responsiveAnimationDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user