Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Chart shrinking uncontrollably on browser zoom (#11089) #11132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/helpers.dom.ts
Expand Up @@ -200,7 +200,7 @@ export function getMaximumSize(
const maintainHeight = bbWidth !== undefined || bbHeight !== undefined;

if (maintainHeight && aspectRatio && containerSize.height && height > containerSize.height) {
height = containerSize.height;
height = Math.round(containerSize.height);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if round1 would be enough to fix the issue..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if removing the width rounding too would sctually fix it :)

width = round1(Math.floor(height * aspectRatio));
}

Expand Down
17 changes: 17 additions & 0 deletions test/specs/helpers.dom.tests.js
Expand Up @@ -545,4 +545,21 @@ describe('DOM helpers tests', function() {

document.body.removeChild(container);
});

it('should respect aspect ratio and container height and return height as integer', () => {
const container = document.createElement('div');
container.style.width = '500px';
container.style.height = '200px';

document.body.appendChild(container);

const target = document.createElement('div');
target.style.width = '500px';
target.style.height = '500px';
container.appendChild(target);

expect(helpers.getMaximumSize(target, 500, 199.975, 1)).toEqual(jasmine.objectContaining({width: 200, height: 200}));

document.body.removeChild(container);
});
});