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 inconsistent aspect ratio #4079

Merged
merged 1 commit into from Jun 4, 2017

Conversation

jtblin
Copy link
Contributor

@jtblin jtblin commented Mar 26, 2017

Please consider the following before submitting a pull request:

Guidelines for contributing: https://github.com/chartjs/Chart.js/blob/master/CONTRIBUTING.md

Example of changes on an interactive website such as the following:

@jtblin jtblin force-pushed the jtblin/consistent-aspect-ratio branch 2 times, most recently from 3d8323f to ba78d9e Compare March 26, 2017 06:24
@jtblin
Copy link
Contributor Author

jtblin commented Mar 26, 2017

This PR makes the aspect ratio consistent between all chart types.

@etimberg
Copy link
Member

@simonbrunel thoughts? I'm ok with making this change, but we should probably add some documentation because otherwise users might complain about the change (we made this change very explicitly in response to a user filed issue about the pie/doughnut charts not using the entire canvas

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.

I'm not sure what users expect for these charts (square or rectangular default size) and can't find tickets about people complaining of the default aspect ratio (I might have missed it). It's a second breaking change that may certainly impact many projects. The first breaking change was a bug fix, this one looks more like a preference?

If everyone agree with it then I'm fine. Though, I'm curious why this change is needed in the lib instead of modifying defaults on the project side?

Chart.defaults.polarArea.aspectRatio = 2;
Chart.defaults.doughnut.aspectRatio = 2;
Chart.defaults.radar.aspectRatio = 2;

@@ -107,13 +107,13 @@ describe('Platform.dom', function() {
}
}, {
canvas: {
style: 'width: 425px'
style: 'width: 212px'
Copy link
Member

Choose a reason for hiding this comment

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

This test needs to verify the same values, defaults need to be changed before and after the test:

it('should use default "chart" aspect ratio for render and display sizes', function() {
    var ratio = Chart.defaults.doughnut.aspectRatio;
    Chart.defaults.doughnut.aspectRatio = 1;

    var chart = acquireChart({
        type: 'doughnut',
        // ...

    expect(chart).toBeChartOfSize({
        // ...
    });

    Chart.defaults.doughnut.aspectRatio = ratio;
});

@jtblin
Copy link
Contributor Author

jtblin commented May 29, 2017

@simonbrunel I've done the change you requested.

The first breaking change was a bug fix, this one looks more like a preference?

I disagree with this definition :) The bug fix (correcting handling aspect ratio) didn't need to introduce a breaking change (changing the aspect ratio of pie charts and family) and it now makes the charts look inconsistent. Here is how it looks like with the defaults:

charts-failed

As you can see, it looks really bad and each user of chartjs shouldn't have to play with aspect ratio, it should look great by default. We may want to document the aspect ratio prominently if not already done.

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.

You right, I should have changed the default aspect ratio to 2 for all charts when fixing that bug, so no breaking changes would have been introduced. I also agree with "... it should looks great by default.", but it seems that some users reported that these kind of charts doesn't look good with an aspect ratio of 2 (@etimberg do you remember tickets by any chance?).

Anyway, I'm good with these changes.

@etimberg
Copy link
Member

I don't recall the ticket unfortunately. I'm fine with these changes as well

@etimberg etimberg merged commit fa6be2f into chartjs:master Jun 4, 2017
@jtblin
Copy link
Contributor Author

jtblin commented Jun 4, 2017

Thanks guys! 👍

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.

None yet

3 participants