diff --git a/test/output/penguinCulmenVoronoiExcludeHex.svg b/test/output/penguinCulmenVoronoiExcludeHex.svg new file mode 100644 index 0000000000..01ba8833fe --- /dev/null +++ b/test/output/penguinCulmenVoronoiExcludeHex.svg @@ -0,0 +1,315 @@ + + + + + Adelie + + + Chinstrap + + + Gentoo + + + + species + + + + + + + + + + + + + + + + + + + + + 34 + 36 + 38 + 40 + 42 + 44 + 46 + 48 + 50 + 52 + 54 + 56 + 58 + + + + ↑ culmen_length_mm + + + + + + + + + + + + + + + + + + 15 + 20 + + + 15 + 20 + + + 15 + 20 + + + + culmen_depth_mm → + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/usStateCentroidVoronoi.svg b/test/output/usStateCentroidVoronoi.svg new file mode 100644 index 0000000000..b5849f8c54 --- /dev/null +++ b/test/output/usStateCentroidVoronoi.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/output/usStateGeoCentroidVoronoi.svg b/test/output/usStateGeoCentroidVoronoi.svg new file mode 100644 index 0000000000..7c85efe509 --- /dev/null +++ b/test/output/usStateGeoCentroidVoronoi.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plots/penguin-culmen-voronoi.ts b/test/plots/penguin-culmen-voronoi.ts index 4f3bd165a5..ecb99cf817 100644 --- a/test/plots/penguin-culmen-voronoi.ts +++ b/test/plots/penguin-culmen-voronoi.ts @@ -35,3 +35,20 @@ export async function penguinCulmenVoronoiExclude() { ] }); } + +export async function penguinCulmenVoronoiExcludeHex() { + const penguins = await d3.csv("data/penguins.csv", d3.autoType); + const xy = {fx: "species", x: "culmen_depth_mm", y: "culmen_length_mm"}; + return Plot.plot({ + inset: 20, + marks: [ + Plot.frame(), + Plot.dot(penguins, Plot.hexbin({}, {...xy, facet: "exclude", stroke: "species", fill: "species"})), + Plot.voronoiMesh(penguins, Plot.hexbin({}, {...xy, facet: "exclude", strokeOpacity: 1})), + Plot.voronoi( + penguins, + Plot.pointer(Plot.hexbin({}, {...xy, facet: "exclude", strokeWidth: 2, maxRadius: Infinity})) + ) + ] + }); +} diff --git a/test/plots/us-state-capitals-voronoi.ts b/test/plots/us-state-capitals-voronoi.ts index 0f72096b96..a2481cfa07 100644 --- a/test/plots/us-state-capitals-voronoi.ts +++ b/test/plots/us-state-capitals-voronoi.ts @@ -35,3 +35,46 @@ export async function usStateCapitalsVoronoi() { ] }); } + +async function voronoiMap(centroid) { + const [nation, states] = await d3 + .json("data/us-counties-10m.json") + .then((us) => [feature(us, us.objects.nation), feature(us, us.objects.states)]); + return Plot.plot({ + width: 640, + height: 640, + margin: 1, + projection: ({width, height}) => + d3.geoAzimuthalEqualArea().rotate([96, -40]).clipAngle(24).fitSize([width, height], {type: "Sphere"}), + marks: [ + Plot.geo(nation, {fill: "currentColor", fillOpacity: 0.2}), + Plot.dot(states.features, centroid({r: 2.5, fill: "currentColor"})), + Plot.voronoiMesh(states.features, centroid({clip: "sphere"})), + Plot.voronoi( + states.features, + Plot.pointer( + centroid({ + x: "longitude", + y: "latitude", + clip: "sphere", + title: "state", + stroke: "red", + fill: "red", + fillOpacity: 0.4, + pointerEvents: "all", + maxRadius: Infinity + }) + ) + ), + Plot.sphere({strokeWidth: 2}) + ] + }); +} + +export async function usStateCentroidVoronoi() { + return voronoiMap(Plot.centroid); +} + +export async function usStateGeoCentroidVoronoi() { + return voronoiMap(Plot.geoCentroid); +}