-
Notifications
You must be signed in to change notification settings - Fork 24
fix: prevent Dot Plot overlaps and restore X-axis context menus #110
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
Open
Ansagan Islamgali (ansaganie)
wants to merge
7
commits into
microsoft:master
Choose a base branch
from
ansaganie:fix/reproduced-bugs-from-prev-version
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a494dd
fix: prevent X-axis category labels from overlapping and add tests fo…
ansaganie e793e3e
fix: add context menu support for X-axis ticks and update tests
ansaganie 12ab4c0
fix: prevent overlapping labels and dots in DotPlot visualization
ansaganie d3a4960
fix: update version to 2.1.4.0 and address overlapping data labels an…
ansaganie ec8df6b
fix: improve label overlap detection by grouping dots and checking ne…
ansaganie f3f4e53
fix: add tooltip for truncated X-axis labels and improve label overla…
ansaganie 6072d07
fix: update context menu handling for invalid category indices and im…
ansaganie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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 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.
getBoundingClientRect()is called once per circle, and every label is then tested against everydot. With
diameter = 2 * radius + 1andmaxDots = floor(dotsTotalHeight / diameter), the circlecount is roughly
categories * viewportHeight / (2 * radius + 1)- at radius 1 and many categoriesthat is thousands of layout reads plus an O(labels x dots) scan on every
update().Dots in a column share the same x-range and form a single vertical stack, so one rect per column
group is usually enough:
That brings it down to O(labels x categories). Caveat: the group box also covers the ~1px
ExtraDiametergaps between stacked dots, so the check becomes marginally stricter.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.
Done - swapped the per-circle rects for one rect per column group, exactly as you sketched.
I kept it testing every label against every group rect rather than only the label's own column. I did try the narrower version, and it does bring a couple of labels back, but those labels then sit on the neighbouring column's dots - which is the thing this function exists to prevent in the first place.
While I was in here I measured where the labels actually go, since "labels disappear even where there is room" had been pointed at this function. On the large-value case (10 categories, radius 15, no display units, precision 5):
hideCollidedLabels(label vs label) takes it down to 5So most of the culling does not happen here at all - it is the label-to-label pass inside chartutils. Worth knowing before anyone tries to make this function less eager, because that alone cannot get past 5.
I also tried capping the label text to the column pitch so labels stop reaching into their neighbours. It genuinely works on paper: all 10 labels come back and every overlap check stays clean. But the rendered result is
$9...$8...$7...across the board, every value truncated to its first digit. For a value label that is worse than showing fewer of them, so I backed it out. Ellipsising is the right answer for the category axis, which already does it, and the wrong answer for the numbers.