This repository was archived by the owner on Aug 1, 2022. It is now read-only.
Place adjacent annotations side-by-side instead of stacking #49
Open
efharkin wants to merge 1 commit intowebermarcolivier:masterfrom
Open
Place adjacent annotations side-by-side instead of stacking #49efharkin wants to merge 1 commit intowebermarcolivier:masterfrom
efharkin wants to merge 1 commit intowebermarcolivier:masterfrom
Conversation
Given three side-by-side categories A, B, C, if we are making comparisons (A, B), (B, C), then draw these alongside eachother instead of on top of eachother.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Side-by-side annotations
(Sun, Thur), (Thur, Fri), and (Fri, Sat) comparisons are all placed on the same line, saving vertical space.
Original
(Thur, Fri) annotation is on a different line from (Sun, Thur) and (Fri, Sat) in the current master.
How does it work?
The current master vertically arranges annotations by creating a stack of vertical offsets over the center of each category. When an annotation is added, statannot checks the height of all the stacks between each of the categories being compared (inclusively) and uses/pushes an offset based on the height of the tallest stack. (If I remember correctly---I actually wrote the code in this PR months ago because I needed some really compact graphs in a hurry.)
This PR basically works the same way, but creates sub-stacks slightly to the left and right of the center of each category.
A.right_baselineandB.left_baseline, draw the annotation, and increment those two values.B.right_baselinewhich is independent ofB.left_baseline.A.right_baseline,C.left_baseline, andB.max_baseline(whereB.max_baseline == max(B.left_baseline, B.right_baseline)).New objects
This PR introduced a couple of new objects
_EligibleBaselineand_EligibleBaselineGroupto handle vertical annotation layout. In particular,_EligibleBaselineGroupabstracts the process of calculating the vertical baseline for an annotation based on its horizontal position.