Skip to content

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

Merged
merged 7 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,11 +806,11 @@ axes.autoTicks = function(ax, roughDTick) {
roughDTick /= ONEAVGMONTH;
ax.dtick = 'M' + roundDTick(roughDTick, 1, roundBase24);
} else if(roughX2 > ONEDAY) {
ax.dtick = roundDTick(roughDTick, ONEDAY, roundDays);

if(ax._hasDayOfWeekBreaks) {
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;
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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])?

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 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.

} else {
ax.dtick = roundDTick(roughDTick, ONEDAY, roundDays);
}

// get week ticks on sunday
Expand Down
Binary file modified test/image/baselines/axes_breaks-round-weekdays.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/image/mocks/axes_breaks-round-weekdays.json
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,8 @@
}
],
"range": [
"2015-11-07",
"2015-11-21"
"2015-11-06 12:00",
"2015-11-23 12:00"
]
},
"yaxis2": {
Expand Down