Public
Edited
Jul 30, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
map = {
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
context.save();
context.beginPath(),
path(outline),
context.clip(),
(context.fillStyle = "#fff"),
context.fillRect(0, 0, width, height);
context.beginPath(),
path(graticule),
(context.strokeStyle = "#ccc"),
context.stroke();
// Draw the land layer with an opacity setting
//////////////////////////////////////////////
context.beginPath();
path(land);
// This is set in the pull down at the top
context.globalCompositeOperation = operation;
// This is calculated in the function in the next box down
context.fillStyle = rbga;
context.fill();
//////////////////////////////////////////////
context.restore();
context.beginPath(),
path(outline),
(context.strokeStyle = "#000"),
context.stroke();
return context.canvas;
}
Insert cell
rbga = {
const rgba = d3.color(color);
rgba.opacity = alpha;
return rgba.toString();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more