-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Implement ticklabelstep
on 2D axes & colorbars
#6088
Conversation
src/plots/cartesian/axes.js
Outdated
|
||
var jump = ax.ticklabeljump; | ||
var vals = jump ? | ||
opts.vals.filter(function(_, i) { return i % (jump + 1) === 0; }) : |
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.
If I'm understanding this correctly, this way we're always going to get the first label that appears in the range, then every nth after that. But what we really want is to always get the label corresponding to tick0
if that's within the range, otherwise start n ticks away from tick0
. An important consequence of this is that as you pan around on a graph the same label will remain displayed or not displayed as long as it's in range.
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.
Certain filtering logic is now moved from drawLabels
to calcTicks
by 29ab444.
Next I'd try to improve on that to keep the same labels around...
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.
This is now addressed by 3b259ed.
editType: 'ticks', | ||
description: [ | ||
'Sets the step between ticklabels.', | ||
'Could be used to hide labels between every n-th ticks.' |
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're right that dticklabel
isn't a good name as it implies it should have the same units as dtick
instead of being an integer multiplying dtick
. I don't love jump
though. Some thoughts:
ticksperlabel
(feels to me like the most precise name, and it's fairly concise, but it sort of makes it look like the ticks are modified rather than the labels)skipticklabels
(but then it should mean "how many do we skip," ie 1 should mean "show every 2nd" and 0 should be the default behavior - add one to get the current meaning)- any other suggestions?
If we keep the current meaning, the default and min should be 1 instead of 0. Either way the description could be made more explicit, something like:
Sets the spacing between tick labels as compared to the spacing between ticks. A value of 1 (default) means each tick gets a label. A larger value n means only every nth tick is labeled.
tick0
determines which labels are shown.
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 uses skipticklabels
in 2676d24.
But how about ticklabelpace
?
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.
Alright, let's stick with skipticklabels
- I still don't love it but it's the best we have so far.
ticklabeljump
on 2D axes & colorbarsskipticklabels
on 2D axes & colorbars
Behavior looks correct to me for linear and category axes 🎉 but needs some work on date axes 🚧 It doesn't look like we're honoring Also when I drag these axes around the displayed ticks are NOT stable, in quite a few cases we flip to displaying the alternate set of labels. Finally, if the removed labels are the only ones that showed the second line of the label, the second line should be shown for the remaining labels using the same logic as we would normally use if the labeled ticks were the only ticks on the graph. You can see this on |
Good calls! |
skipticklabels
on 2D axes & colorbarsticklabelstep
on 2D axes & colorbars
@alexcjohnson this PR is ready for another round of review 🙏 SVP. |
Co-authored-by: Alex Johnson <johnson.alex.c@gmail.com>
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.
💃 Fantastic!
It sets the step between tick labels as an integer number.
This feature can help hide labels between every n-th ticks.
@plotly/plotly_js