repelY initializer
https://github.com/observablehq/plot/assets/7001/76810a97-44c4-4caf-afb9-2519e5ed7ada
quoting @visnup: I always need some occlusionX or Y 😅
For #27
TODO:
- [x] fix the display of y in the tip (if using tip: true), it should be the unscaled value.
- [x] decide whether we keep the deduplication of (y, text) pairs—this could be achieved by combining occlusionY and a group transform, resulting in cleaner code and a better separation of concerns (but more user code to write for that particular case) [code removed and replaced by group]
- [x] rename ("occlusion" says the opposite of what it does, and the name should be a verb)
examples:
I wonder if we could instead incorporate this into the dodge transform rather than making a new transform.
Yes I had the same feeling, but didn't want to complicate things at first. It might mean renaming minDistance (to r, with a default of 5.5 instead of 11, but then it's not the same default as dodge…), and applying it on the opposite direction too? I can investigate whether that's possible. Now that we have this baseline, maybe it's worth doing this extra step.
I like "repel" a lot.
Other verbs: Fan out, Spread, Stretch, Radiate, Unfold...
I had to check but disocclude is an actual word. https://en.wiktionary.org/wiki/disocclude
That's a lot of syllables though.
I would love to unify this with the dodge transform, unfortunately I'm not seeing a lot of common ground. Maybe this needs more work.
What's different:
| dodgeY | occlusionY | |
|---|---|---|
| y channel | not supported | required |
| x channel | required | optional |
| spread | x + y | y only |
| default | r 3, channel | minDist 11, constant |
| anchor | supported | not supported |
A way to unify them would be to let dodgeY switch to the occlusionY algo when a y channel is specified, but this would mean that almost everything changes meaning:
- what to do when x is a channel? Can we support disoccluding more (by pushing the point higher?)?
- minDist could become r (at the price of not having the best default for text labels), but then what to do when r is a channel?
- anchor could be ignored in that case, since we could argue that the point is anchored to its y value