-
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
Honour axis min/max settings #4522
Conversation
This |
ticks.push(cur.valueOf()); | ||
|
||
// last tick | ||
if (helpers.isNullOrUndef(options.max)) { |
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.
minor question. could we always just push realMax
at the end?
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.
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)) { |
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 agree that this if is dubious. I'm not sure why isoWeekday
is doing things here.
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 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
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'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.
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.
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).
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.
Then the docs are off: https://github.com/chartjs/Chart.js/blob/master/docs/axes/cartesian/time.md shows its boolean.
Fixed typo and corrected lower case for nested tests. Imho ready to merge. |
@andig this one needs a rebase |
Fix #4514