-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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 aspect ratio and add responsive unit tests #3356
Conversation
Add the --inputs command switch to the unittest and unittestWatch tasks, to be able to run unit tests from the specified files only (e.g. gulp unittest --inputs=test/core.element.tests.js;test/core.helpers.tests.js).
When responsive is false and no canvas height explicitly set, the aspectRatio option wasn't applied because of the canvas default height. Prevent the retinaScale method to change the canvas display size since this method is called for none responsive charts, but instead make the resize() responsible of these changes. Also, as discussed some time ago, moved most of the core.js logic into core.controller.js. Clean up the destroy process and make sure that initial canvas values are properly saved and restored.
Now that the aspect ratio is correctly handled, fix samples for charts with aspect ratio of 1 which was vertically too large. Also fix the default aspect ratio for radar charts which wasn't applied when creating a chart directly using new Chart(ctx, { type: 'radar' }).
4728bd5
to
5c8d98b
Compare
5c8d98b
to
7d65bd3
Compare
Finally stabilized unit tests (was actually failing because of #3152) ... so ready for @chartjs/maintainers review :) |
Looks good to me
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
var renderWidth = canvas.getAttribute('width'); | ||
|
||
// Chart.js modifies some canvas values that we want to restore on destroy | ||
canvas._chartjs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this
Fix aspect ratio and add responsive unit tests
Should have been only unit tests but then I realized that aspect ratio for none responsive chart was totally broken. So I decided to clean up the whole canvas initialization process and I hope to not have broken too many things :)
This PR includes:
aspectRatio
for radar chart and associated samplescore.controller.js
test/core.controller.tests.js
currently testing AR and responsiveness (see screenshot below)gulp unittest --inputs=test/core.controller.tests.js
)More details in commit messages