plot
plot copied to clipboard
Voronoi initializer (for pointer interactions)
new description!
This PR chiefly addresses #1622, making the voronoi mark work with the tip option. A notable performance issue in the modified usStateCapitalsVoronoi test is that the clip path is created anew each time we rerender the mark (this is addressed separately, in #1624).
A secondary issue (#1858, making voronoi work with exclusive facets) was first addressed in an ad hoc fashion (in https://github.com/observablehq/plot/pull/1623/commits/71c49a2178bc8eb40db547f83665ac4087d3fe80). After this review comment suggesting that this should be centralized, I reverted the change in https://github.com/observablehq/plot/pull/1623/commits/70f23521a4deb48ab34726398e833b540d4b9580, then used the new exclusiveFacets transform (introduced in #1648) in https://github.com/observablehq/plot/pull/1623/commits/972558cdee4fcfb1f04e20411664f92006a93940 et sq.
Closes #1622 Closes #1858.
I couldn’t resist trying the Voronoi initializer idea… I dunno if we need to make similar changes to the Delaunay marks? I think maybe it doesn’t make sense there, though, because there’s a not a 1:1 correspondence between the data and the geometry.
https://github.com/observablehq/plot/assets/230541/067c54b5-801f-49cb-bea7-fabf355a0c3c
the voronoi cell now depends on i and fi (with a test showing facet: exclude)
~~It works!~~ ~~Applying the exclusiveFacets to the voronoi mark only for now (I saw that it didn't work with the voronoiMesh).~~
~~In the documentation there is a voronoi mark with the centroid initializer, and the reindexation logic fails in that case.~~
~~I'm not sure how to apply exclusiveFacets properly. At least we now have test cases. Rather than a transform as it is now, I wonder if it could be a (private?) option flag instead, that asks Plot to apply this before any other transform. It would feel less "ad hoc" for the voronoi marks.~~
I've updated the description of this PR. ~~I'd like to find a cleaner way to apply the exclusiveFacets transform~~ (DONE)