-
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
Improve label capacity calculation in time scale #6297
Conversation
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.
Looks good to me.
Rebased and reverted some changes for size reduction. |
@nagix I finished my other work on the time scale and auto-skipping. Thanks for letting me get those PRs in first. I really appreciate it. This one can be rebased now |
@nagix I'm going to close this since we haven't heard anything on it for awhile, but please feel free to reopen if you're still interested in pursuing |
Problem 1
Currently
getLabelCapacity
uses thedisplayFormats
for'millisecond'
ifunit
is not specified. This results in less label capacity than actual (and this often happens). The example below shows that the unit is automatically set to'month'
when there are two labels['2015-01-01', '2015-02-01']
.Problem 2
#6265 changed to compute the capacity using the major unit if applicable, but
me._majorUnit
is not set whengetLabelCapacity
is called. Furthermore, it is not always true that the label width of a major tick is larger than that of a minor tick or vise versa.Solution
This PR takes into account the label capacity of both minor and major ticks in
getLabelCapacity
. And,determineUnitForAutoTicks
checks the label capacity for each unit.Potential problem of this change is that more labels will be rotated because
getLabelCapacity
calculates the capacity using rotation. But I think this should be controlled by themaxRotation
option.Master: https://jsfiddle.net/nagix/zdkcaerb/
This PR: https://jsfiddle.net/nagix/5kersouy/
Fixes #5093