Sahal Master
11/13/2024, 10:09 PMMike Bostock
11/13/2024, 10:39 PMPlot.plot({
projection: "albers",
color: {scheme: "YlGnBu"},
marks: [
Plot.density(walmarts, {
x: "longitude",
y: "latitude",
bandwidth: 10,
fill: "density",
render(index, scales, values, dimensions, context, next) {
const {document} = context;
const g = next(index, scales, values, dimensions, context);
const clipPath = document.createElementNS("<http://www.w3.org/2000/svg>", "clipPath");
const path = document.createElementNS("<http://www.w3.org/2000/svg>", "path");
const geoPath = d3.geoPath(context.projection);
path.setAttribute("d", geoPath(nation));
clipPath.setAttribute("id", "clip");
clipPath.appendChild(path);
context.ownerSVGElement.appendChild(clipPath);
g.setAttribute("clip-path", "url(#clip)");
return g;
}
}),
Plot.geo(statemesh, {strokeOpacity: 0.3}),
Plot.geo(nation),
Plot.dot(walmarts, {x: "longitude", y: "latitude", r: 1, fill: "currentColor"})
]
})Sahal Master
11/26/2024, 3:09 PM