Skip to content

Repulsive labels #1159

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
allisonhorst opened this issue Dec 5, 2022 · 4 comments
Open

Repulsive labels #1159

allisonhorst opened this issue Dec 5, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@allisonhorst
Copy link

For charts with dense or overlapping labels, it would be useful to have a way to create repulsive labels to avoid overlap (similar to ggrepel for ggplot2).

@allisonhorst allisonhorst added the enhancement New feature or request label Dec 5, 2022
@Fil
Copy link
Contributor

Fil commented Dec 6, 2022

This might be needing an algorithm similar to Dorling cartograms, for example with a force simulation.

Among the notable differences/or features that we might want to support:

  • labels are closer to rects (or ellipses) rather than circles (ellipses can be achieved by upscaling y)
  • we prefer if label avoid occluding features of the map
  • sometimes we prefer if the labels are somehow "aligned" with the points of interest
  • sometimes if the label is small and the point is large, we will place it at the center; other times, connect it with a line to the point of interest.

@mbostock
Copy link
Member

mbostock commented Dec 7, 2022

Probably already covered by #27, but we could leave this open if there’s specifically demand for this type of labeling algorithm.

@Fil
Copy link
Contributor

Fil commented Dec 8, 2022

Or use a voronoi initializer transform: https://observablehq.com/@fil/plot-voronoi-labels

@mbostock
Copy link
Member

mbostock commented Jun 2, 2023

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

3 participants