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

Marks, such as Plot.bar[XY], could implement (optional) labels directly to make it easier that using Plot.text. #81

Closed
Fil opened this issue Dec 30, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Dec 30, 2020

No description provided.

@Fil Fil mentioned this issue Dec 30, 2020
@mbostock mbostock added the enhancement New feature or request label Feb 24, 2021
@mbostock
Copy link
Member

This feels like a good, practical idea. I wonder if it should also apply to other marks such as lines and areas.

@Fil
Copy link
Contributor Author

Fil commented Feb 25, 2021

In #82 it's a bit complicated: the bar labels in this example "work" only because the domain is made of single letters. We also need to have a text fill that depends on whether the label is on the mark or above it.

Rather than try to solve all this for all cases from inside the barX mark (as suggested in #82), an interesting alternative might be to have a Plot.textBarX mark which would return the same (x,y) as the corresponding barX. Then the user could call the mark twice, one that filters the cases where the bar's height is too small, and add a negative dy and black fill, the other for large bars, with positive dy and white fill.

* * *

For areas we already have a few examples in the stack experiments.

The most complex example is at https://observablehq.com/@data-workflows/u-s-population-by-state-1790-1990: the label is indexed by z, and follows a textPath based on the "mid" range of the stack ((low+high)/2), with a basis curve, which is less wiggly than "cardinal" or "monotone-x". Plus a heuristic to avoid overlaps between two consecutive labels.

Related: #27

@Fil
Copy link
Contributor Author

Fil commented Mar 5, 2021

seems better to implement this as a composite mark (#171), in a "plugin"

@Fil Fil closed this as completed Mar 5, 2021
@Fil

This comment has been minimized.

@Fil Fil reopened this Mar 5, 2021
@Fil
Copy link
Contributor Author

Fil commented Apr 10, 2021

Here's a plugin that works well https://observablehq.com/d/0c2e2cbba57730d2

@Fil Fil closed this as completed Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants