Skip to content

labelArrow option #1566

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

Merged
merged 2 commits into from
May 17, 2023
Merged

labelArrow option #1566

merged 2 commits into from
May 17, 2023

Conversation

mbostock
Copy link
Member

Fixes #510. Supersedes #702.

Plot now applies a directional arrow such as → or ↑ automatically, even if the scale label is specified explicitly, as long as the given label does not already include a directional arrow. The arrow can be suppressed by setting the labelArrow option to none, null, or false. In addition, the arrow can be forced in cases where it would not appear automatically, such as for ordinal scales, by setting the labelArrow option to true or one of the four orientations: up, right, bottom, or left.

Previously in our repo there were 175 instances of Unicode arrows in specified labels; with this change, there are now only 14 instances! (−92%) The remaining instances are solely for double-ended arrows such as ← Women · Men →.

@mbostock mbostock requested a review from Fil May 16, 2023 23:02
@mbostock mbostock mentioned this pull request May 16, 2023
1 task
@mbostock
Copy link
Member Author

As context, there are several benefits of removing the arrows:

  1. Arrows are hard to type. (You need to copy-paste an existing one, or bring up the special characters palette.)
  2. Arrows are context-dependent: they are appropriate for axes, but not for tips.
  3. Arrows are orientation-dependent, making it harder to update the plot (e.g., to reverse a scale or swap x and y).

Copy link
Contributor

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you!
I'm adding a suggestion for docs in #1568, I also figured we might appreciate an example with an explicit labelArrow where true would not do the right thing? Like a depth transect of some sort, where you'd want depth to ↓ to the negatives. (But I can't find a handy dataset to play with…)

mbostock and others added 2 commits May 17, 2023 08:21
* document labelArrow

* *up*, *right*, *down*, *left*

* axis options edits

* copy edits

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
@mbostock mbostock force-pushed the mbostock/label-arrow branch from 673e913 to 567f54c Compare May 17, 2023 15:21
@mbostock mbostock enabled auto-merge (squash) May 17, 2023 15:21
@mbostock mbostock merged commit 9bc3fb3 into main May 17, 2023
@mbostock mbostock deleted the mbostock/label-arrow branch May 17, 2023 15:24
@Fil Fil mentioned this pull request Jun 26, 2023
chaichontat pushed a commit to chaichontat/plot that referenced this pull request Jan 14, 2024
* labelArrow option

* labelArrow docs (observablehq#1568)

* document labelArrow

* *up*, *right*, *down*, *left*

* axis options edits

* copy edits

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>

---------

Co-authored-by: Philippe Rivière <fil@rezo.net>
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.

Axis label helper?
2 participants