Improve label capacity calculation in time scale#6297
Closed
nagix wants to merge 2 commits intochartjs:masterfrom
Closed
Improve label capacity calculation in time scale#6297nagix wants to merge 2 commits intochartjs:masterfrom
nagix wants to merge 2 commits intochartjs:masterfrom
Conversation
benmccann
reviewed
May 24, 2019
benmccann
reviewed
May 24, 2019
Contributor
Author
|
Rebased and reverted some changes for size reduction. |
kurkle
previously approved these changes
Jun 22, 2019
etimberg
previously approved these changes
Jun 23, 2019
Contributor
|
@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 |
Contributor
|
@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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem 1
Currently
getLabelCapacityuses thedisplayFormatsfor'millisecond'ifunitis 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._majorUnitis not set whengetLabelCapacityis 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,determineUnitForAutoTickschecks the label capacity for each unit.Potential problem of this change is that more labels will be rotated because
getLabelCapacitycalculates the capacity using rotation. But I think this should be controlled by themaxRotationoption.Master: https://jsfiddle.net/nagix/zdkcaerb/

This PR: https://jsfiddle.net/nagix/5kersouy/

Fixes #5093