-
-
Couldn't load subscription status.
- Fork 1.9k
Avoid tight daily labels on axes with rangebreaks when using "day of week" pattern #4695
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
Conversation
@nicolaskruchten thanks very much for posting the image related to the ( old ) undesirable behaviour. |
src/plots/cartesian/axes.js
Outdated
| if(ax.dtick === 2 * ONEDAY) ax.dtick = ONEDAY; | ||
| else if(ax.dtick === 3 * ONEDAY) ax.dtick = 7 * ONEDAY; | ||
| ax.dtick = roundDTick(roughDTick, ONEDAY, [1, 1.001, 7, 14]); | ||
| if(ax.dtick !== ONEDAY) ax.dtick = 7 * ONEDAY; |
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.
Is this different from just saying roundDTick(roughDTick, ONEDAY, [1, 7, 14])? The underlying function is Lib.roundUp so I'd expect anything too big for 1 would already bump up to 7. Also I think this would convert 2-week ticks into 1-week?
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.
Also I think this would convert 2-week ticks into 1-week?
Doog eye. Fixed in 79b6d95.
But we still need to fix something possibly in Lib.dateTick0 to compute dtick on those reversed cases.
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.
again though, is this different from just roundDTick(roughDTick, ONEDAY, [1, 7, 14])?
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 think that is different. The issue was almost related to numbers close to 1 (e.g. 2) not those close to 7. Anyway it seems there is no more need for that hacy roundingSet as the logic is changed in the commits below.
|
@nicolaskruchten would you mind testing the updated demo in the PR description. |
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.
💃 sometimes the simple solution is the best 😅

Demo
Follow up of #4614 and #4688:
Commit c340efc exercised 2 -> 7 rounding which leads to following commits.
As a result we only round
dtickto 1 if it is really close to 1.@plotly/plotly_js