Published
Edited
Jan 16, 2022
1 fork
Importers
11 stars
Insert cell
Insert cell
Insert cell
projection = d3.geoAirocean()
Insert cell
step = 4
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function renderHatches(m) {
d3.select(m)
.select("path.lines")
.remove();

const poly = polygons(m.projection);

const lines = [];

for (let y = 0; y < width; y += step) {
let A = intersections(poly, y);
for (let i = 0; i < A.length - 1; i += 2) {
if (A[i + 1] - A[i] > 1 * step)
lines.push({
x1: A[i] + step * 0.75,
x2: A[i + 1] - step * 0.75,
y1: y,
y2: y
});
}
}

d3.select(m)
.append("path")
.attr("d", lines.map(d => `M${[d.x1, d.y1]}L${[d.x2, d.y2]}`).join(""))
.classed("lines", true)
.attr("stroke", "brown");
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
graticule = null
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