mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-15 04:36:51 +01:00
Ensure that chart dimensions are always >= 0
Elements were resizing incorrectly if they were regenerated while the chart was in a div that was display:none. Added a check to avoid this issue. Resolves #4397
This commit is contained in:
committed by
Evert Timberg
parent
b548d1a689
commit
bef44ccb46
@@ -169,8 +169,10 @@ module.exports = function(Chart) {
|
||||
|
||||
// the canvas render width and height will be casted to integers so make sure that
|
||||
// the canvas display style uses the same integer values to avoid blurring effect.
|
||||
var newWidth = Math.floor(helpers.getMaximumWidth(canvas));
|
||||
var newHeight = Math.floor(aspectRatio? newWidth / aspectRatio : helpers.getMaximumHeight(canvas));
|
||||
|
||||
// Set to 0 instead of canvas.size because the size defaults to 300x150 if the element is collased
|
||||
var newWidth = Math.max(0, Math.floor(helpers.getMaximumWidth(canvas)));
|
||||
var newHeight = Math.max(0, Math.floor(aspectRatio ? newWidth / aspectRatio : helpers.getMaximumHeight(canvas)));
|
||||
|
||||
if (me.width === newWidth && me.height === newHeight) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user