Fix tick label rotation and layout issues#5961
Merged
simonbrunel merged 1 commit intochartjs:masterfrom Apr 30, 2019
Merged
Conversation
benmccann
reviewed
Jan 6, 2019
benmccann
reviewed
Jan 6, 2019
kurkle
reviewed
Jan 7, 2019
kurkle
reviewed
Jan 7, 2019
8e6bce3 to
eff623b
Compare
kurkle
reviewed
Jan 10, 2019
Member
kurkle
previously approved these changes
Jan 10, 2019
etimberg
previously approved these changes
Jan 11, 2019
Member
etimberg
left a comment
There was a problem hiding this comment.
I think I understand how this works. I haven't had a chance to test it out locally yet.
benmccann
reviewed
Jan 11, 2019
nagix
commented
Jan 11, 2019
benmccann
previously approved these changes
Jan 11, 2019
Member
|
Small performance increase in this PR, rendering 1M points on timescale. Master: {
"1 init": 1.8,
"2 update/ds/0": 782.6,
"2 update/ds/1": 1079.2,
"2 update/ds/2": 748.4,
"2 update/ds/3": 727.7,
"2 update/ds/total": 3338.3,
"2 update/layout": 4393.1,
"2 update/total": 8190.5,
"3 render/draw/ds/0": 105.6,
"3 render/draw/ds/1": 111.3,
"3 render/draw/ds/2": 119,
"3 render/draw/ds/3": 119.9,
"3 render/draw/ds/total": 456.2,
"3 render/draw/total": 458.1,
"3 render/total": 476.5,
"x from page load": 8673.9
}This PR: {
"1 init": 1.7,
"2 update/ds/0": 822.4,
"2 update/ds/1": 824,
"2 update/ds/2": 1046.8,
"2 update/ds/3": 794.2,
"2 update/ds/total": 3488,
"2 update/layout": 2910.7,
"2 update/total": 6803.2,
"3 render/draw/ds/0": 107,
"3 render/draw/ds/1": 108.6,
"3 render/draw/ds/2": 118,
"3 render/draw/ds/3": 123.2,
"3 render/draw/ds/total": 457,
"3 render/draw/total": 459.1,
"3 render/total": 477.9,
"x from page load": 7288.3
}250k ponts per dataset. something breaks in chrome (render process dies) when putting 300k points in a set. |
Contributor
Author
|
@kurkle Thanks for the analysis. It seems that the performance gain comes from "2 update/layout", so this is what I expected. Does the master even crash in Chrome? |
Member
|
@nagix both crash, so not an issue in this PR. I think maybe path becomes too long. |
kurkle
reviewed
Jan 16, 2019
b42285d to
21a6bb6
Compare
Closed
This was referenced Apr 14, 2020
exwm
pushed a commit
to exwm/Chart.js
that referenced
this pull request
Apr 30, 2021
This was referenced Jun 1, 2021
Open
This was referenced Jul 5, 2021
This was referenced Jul 27, 2021
This was referenced Oct 14, 2021
1 task
This was referenced Jan 21, 2022
This was referenced Feb 4, 2022
This was referenced Mar 7, 2022
Open
1 task
This was referenced Nov 29, 2022
1 task
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.

There are a few problems
ticks.minorandticks.majorconfiguration:scale.ticks.*options at runtime because the scale class copies the minor and major ticks options fromticks.*on the initial chart creation, and it doesn’t update them on the following update calls as the values already exist ([BUG] Can't update scale.ticks.* options at runtime since 2.7.0 #4896).ticks.major.enabledis set tofalseby default, butticks.majoroptions are effective. The behavior should be consistent with theticks.major.enabledsetting.ticks.minoroptions are used forcalculateTickRotation,fit,drawand_autoSkipcalculations, so major tick labels can overlap or be cropped.calculateTickRotationonly considers the first tick interval before fitting, and doesn’t take into account margins for the tick labels on the left and right.This PR fixes these problems as follows.
mergeTicksOptionsand addsparseTickFontOptionsto parse minor and major tick font options. Omitted options are inherited fromticksat runtime.ticks.major.enabledisfalse.computeTextSizeand addscomputeLabelSizesto measure tick labels and find the widest, highest, first and last labels at a time.calculateTickRotationso that it takes into account margins for the tick labels on the left and right.Edit: This PR fixes the following problems as well.
calculateTickRotationcalculates the maximum scale height using the scale label size, the tick mark size and the tick padding to remove the overlap with scale label ([BUG] Tick label overlaps axis label, long labels cropped #5906).calculateTickRotationhas a loop to determine the label rotation and it can be repeated 90 times at most. The proposed version eliminate the loop to improve performance.Edit2: Problem 1 and 2 are addressed in #6102.
Master: https://jsfiddle.net/nagix/amtLsdfb/

This PR: https://jsfiddle.net/nagix/mas98q17/

Fixes #5906
Fixes #2106