Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Place adjacent annotations side-by-side instead of stacking #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

efharkin
Copy link
Contributor

Side-by-side annotations

side_by_side

(Sun, Thur), (Thur, Fri), and (Fri, Sat) comparisons are all placed on the same line, saving vertical space.

Original

stacked

(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.

  • If we have categories A, B, C and we want to add an annotation to (A, B), we check the current height of A.right_baseline and B.left_baseline, draw the annotation, and increment those two values.
  • If we later want to add an annotation to (B, C), we check B.right_baseline which is independent of B.left_baseline.
  • Finally, if we want to add (A, C), we check the height of A.right_baseline, C.left_baseline, and B.max_baseline (where B.max_baseline == max(B.left_baseline, B.right_baseline)).

New objects

This PR introduced a couple of new objects _EligibleBaseline and _EligibleBaselineGroup to handle vertical annotation layout. In particular, _EligibleBaselineGroup abstracts the process of calculating the vertical baseline for an annotation based on its horizontal position.

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant