Skip to content
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

tip preferredAnchor #1872

Merged
merged 3 commits into from
Oct 12, 2023
Merged

tip preferredAnchor #1872

merged 3 commits into from
Oct 12, 2023

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Sep 24, 2023

Introduces a preferredAnchor option for the tip mark, setting the desired anchor when the tip fits. (As opposed to the anchor option, which always uses the specified anchor regardless of whether it fits.) This causes the tip mark to prefer the bottom orientation, except when using the tip option with the y pointer mode, in which case it prefers the left orientation.

This example scatterplot now prefers bottom instead of top-left:
Screenshot 2023-09-24 at 9 20 53 AM

This example horizontal bar chart now prefers left instead of top-left:
Screenshot 2023-09-24 at 9 20 35 AM

I think this is what most people will prefer, and avoids the default “comic book” appearance that Gregor mentioned.

Fixes #1876.

@mbostock mbostock requested a review from Fil September 24, 2023 16:23
@mbostock mbostock force-pushed the mbostock/preferred-tip-anchor branch from 9992c6e to 7bfa337 Compare September 24, 2023 16:27
@Fil
Copy link
Contributor

Fil commented Sep 25, 2023

In the tiplineX example, for some values we select an anchor that doesn't fit. (Most probably not related to this PR, since it doesn't change the measurements, so I'll open a new issue)
Capture d’écran 2023-09-25 à 08 43 58

@mbostock mbostock force-pushed the mbostock/preferred-tip-anchor branch from 439b331 to b29648c Compare October 12, 2023 04:07
@mbostock mbostock enabled auto-merge (squash) October 12, 2023 04:20
@mbostock mbostock merged commit febdf62 into main Oct 12, 2023
@mbostock mbostock deleted the mbostock/preferred-tip-anchor branch October 12, 2023 04:21
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* tip preferredAnchor

* fix fit tests

* document tip options

---------

Co-authored-by: Philippe Rivière <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tip measurement too optimistic
2 participants