Public
Edited
Aug 1, 2023
18 forks
Importers
55 stars
Also listed in…
Gallery
d3-delaunay
Maps
Insert cell
Insert cell
chart = {
const context = DOM.context2d(width, height);
const path = d3.geoPath(mutable projection, context).pointRadius(1.5);

function render() {
context.clearRect(0, 0, width, height);

context.beginPath();
path(graticule);
context.lineWidth = 0.5;
context.strokeStyle = "#aaa";
context.stroke();

context.beginPath();
path(mesh);
context.lineWidth = 0.5;
context.strokeStyle = "#000";
context.stroke();

context.beginPath();
path(sphere);
context.lineWidth = 1.5;
context.strokeStyle = "#000";
context.stroke();

context.beginPath();
path({type: "MultiPoint", coordinates: points});
context.fillStyle = "#f00";
context.fill();
}
function dragged() {
mutable projection = mutable projection;
render();
}

return d3.select(context.canvas)
.call(drag(mutable projection).on("drag.render", dragged))
.call(render)
.node();
}
Insert cell
mutable projection = d3.geoOrthographic()
.fitExtent([[1, 1], [width - 1, height - 1]], sphere)
.rotate([0, -30])
Insert cell
height = width
Insert cell
sphere = ({type: "Sphere"})
Insert cell
graticule = d3.geoGraticule10()
Insert cell
points = (await FileAttachment("airports.csv").csv({typed: true})).map(({longitude, latitude}) => [longitude, latitude])
Insert cell
mesh = d3.geoVoronoi(points).cellMesh()
Insert cell
d3 = require("d3@7", "d3-geo-voronoi@2")
Insert cell
import {drag} with {d3} from "@d3/versor-dragging"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more