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

Honour axis min/max settings #4522

Merged
merged 2 commits into from
Jul 22, 2017
Merged

Honour axis min/max settings #4522

merged 2 commits into from
Jul 22, 2017

Conversation

andig
Copy link
Contributor

@andig andig commented Jul 18, 2017

Fix #4514

@andig andig changed the title Honor axis min/max settings Honour axis min/max settings Jul 18, 2017
@andig
Copy link
Contributor Author

andig commented Jul 18, 2017

This if statement here https://github.com/chartjs/Chart.js/pull/4522/files#diff-e4b810d743d51c0b308df72d4788703aR67 is still dubious, especially why isoWeekDays should influence tick generation but thats another issue.

ticks.push(cur.valueOf());

// last tick
if (helpers.isNullOrUndef(options.max)) {
Copy link
Member

Choose a reason for hiding this comment

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

minor question. could we always just push realMax at the end?

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 can't because cur.valueOf() > niceRange.max in this case, meaning that the last tick will be too early. Begs the question what niceRangeMax really is and where it comes from. Didn't look into this- the current change is minimally invasive.

if (startFraction && majorUnit && !options.timeOpts.round && !options.timeOpts.isoWeekday) {

// first tick
if (startFraction && majorUnit && !options.timeOpts.round && !options.timeOpts.isoWeekday && helpers.isNullOrUndef(options.min)) {
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this if is dubious. I'm not sure why isoWeekday is doing things here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't quite tell what the isoWeekday option is supposed to do from the docs. Looking at the code it seems that perhaps that setting isoWeekday makes every tick a Monday. If you're manually setting each tick to a Monday then it'd make sense not to do smart alignment here, but it's quite difficult to tell what this option is. I tried to build a sample to test it out, but the time samples seem to be currently broken on master. After #4507 is merged I imagine the samples will be working again and then we can take a stab at better documenting that feature and seeing if we should remove isoWeekday here

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'd leave it unchanged for now as removing it breaks this https://github.com/chartjs/Chart.js/blob/master/test/specs/scale.time.tests.js#L331 test. The test itself is odd as isoWeekDay should be a boolean but the tests uses numerical value.

Copy link
Member

Choose a reason for hiding this comment

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

My understanding of isoWeekDay is that's a number representing the day (1: Monday - 7: Sunday) that should be considered the first day of the week and I guess that isoWeekDay: true is an alias to 1 (Monday).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andig
Copy link
Contributor Author

andig commented Jul 18, 2017

Fixed typo and corrected lower case for nested tests. Imho ready to merge.

@benmccann
Copy link
Contributor

@andig this one needs a rebase

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