-
Notifications
You must be signed in to change notification settings - Fork 184
Labeling algorithms (e.g., occlusion)? #27
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
Comments
Related #139 for a transform that is useful for labeling lines. |
we have a nice solution for stacked series and bars thanks to stackXMid |
I really want an automatic algorithm for labeling scatterplots. And possibly stacked areas and other things. Something that considers only occlusion, like @fil/occlusion, would be a great place to start. |
I also like the "halo" (white stroke clone) strategy from https://observablehq.com/@mbostock/inequality-in-american-cities and think it should be available from Plot.text (and maybe occlusion as well!). Other refs:
|
Here's a prototype for a labelling strategy based on @fil/occlusion On this scatterplot, the occludeText function is able to avoid putting text on top of symbols. It's still not capable of finding a correct position to put the texts. It also needs to wait for the chart to be appended to the DOM before it can kick in, as it needs to measure the actual bounding boxes. |
Can we avoid getBoundingClientRect by using the same metrics approach that Plot.text uses? |
Yes it's one of the todos. Some challenges (probably not too hard):
|
Voronoi centroid initializer https://observablehq.com/@fil/plot-voronoi-labels |
A typical request is to limit occlusion of end-of-line labels, like in https://observablehq.com/@d3/cancer-survival-rates (unfinished Plot version: https://observablehq.com/@observablehq/plot-cancer-survival-rates). The dodgeY transform doesn't address this concern since by construction it disregards an initial y channel. I wonder if it would be fair for the dodgeY transform to switch to a different algorithm if y is already there? |
See also mapbox’s text-variable-anchor property |
Another example, in which the temptation was to use dodgeY (but that's not how it works) to avoid label occlusion |
Here's a hack for occluding axis ticks by combining |
In some line plots, if the cardinality of z is relatively low, it would be nice to label the lines say at the start or end. Similarly for dot plots, it would be lovely to have an automatic labeling strategy. Related vega-label.
The text was updated successfully, but these errors were encountered: