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

add check on overwriting canvas height/width #4874

Merged
merged 3 commits into from
Nov 22, 2017

Conversation

andersponders
Copy link
Contributor

@benmccann
Copy link
Contributor

@andersponders sorry about the test flakiness. If you rebase against the latest master hopefully it should be fixed

@benmccann
Copy link
Contributor

@andersponders would you be able to add a unit test for this issue?

@andersponders
Copy link
Contributor Author

yea i can do that

@@ -544,8 +544,10 @@ module.exports = function(Chart) {
// If no style has been set on the canvas, the render size is used as display size,
// making the chart visually bigger, so let's enforce it to the "correct" values.
// See https://github.com/chartjs/Chart.js/issues/3575
canvas.style.height = height + 'px';
canvas.style.width = width + 'px';
if (!canvas.style.height && !canvas.style.width) {
Copy link
Member

Choose a reason for hiding this comment

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

@andersponders shouldn't we split this check in case only one dimension is set in the style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You could, but I would say if the user is explicitly setting one through CSS, it seems more natural to let the other get handled that way too. im too lazy to make an example, but in my case I was setting height to be 70% of the container, and in that case i probably don't want the library to set width to be static 200px

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i should add this is with responsive=false, another option is instead check if responsive is set

Copy link
Member

Choose a reason for hiding this comment

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

This method should not be aware about the responsive stuff, let's keep it the way you did.

@simonbrunel
Copy link
Member

+1 for unit tests, but also please make sure that doesn't break #3575

@simonbrunel simonbrunel added this to the Version 2.8 milestone Oct 22, 2017
@andersponders
Copy link
Contributor Author

added simple test case

Copy link
Member

@simonbrunel simonbrunel left a comment

Choose a reason for hiding this comment

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

@andersponders sorry for the delay, was waiting to release 2.7.1, then forgot about that PR. It looks good to me.

Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

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

Looks good to me

@etimberg etimberg merged commit 6b824d9 into chartjs:master Nov 22, 2017
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
* add check on overwriting canvas height/width

* unit test for this
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
* add check on overwriting canvas height/width

* unit test for this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants