Public
Edited
Oct 10, 2023
12 forks
44 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("fill", "none")
.attr("stroke", "currentColor");

const outline = svg.append("path");

const feature = svg.append("path");

function render() {
outline.attr("d", path(sphere));
feature.attr("d", path(land));
}

return svg
.call(zoom(projection).on("zoom.render end.render", render))
.call(render)
.node();
}
Insert cell
path = geoCurvePath(curve, projection)
Insert cell
height = {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, sphere)).bounds(sphere);
const dy = Math.ceil(y1 - y0), l = Math.min(Math.ceil(x1 - x0), dy);
projection.scale(projection.scale() * (l - 1) / l).precision(0.2);
return dy;
}
Insert cell
sphere = ({type: "Sphere"})
Insert cell
land = {
let topology = world;
topology = topojson.presimplify(topology);
topology = topojson.simplify(topology, minArea);
return topojson.feature(topology, topology.objects.land);
}
Insert cell
world = FileAttachment("land-110m.json").json()
Insert cell
topojson = require("topojson@3")
Insert cell
import {zoom} from "@d3/versor-zooming"
Insert cell
import {geoCurvePath} from "@d3/context-to-curve"
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