Published
Edited
Sep 21, 2020
2 forks
Importers
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
function randomPoint() {
return [
(Math.random() * 2 - 1) * 180,
Math.asin(Math.random() * 2 - 1) / Math.PI * 180,
];
}
Insert cell
Insert cell
Insert cell
function randomPointUncorrected() {
return [
(Math.random() * 2 - 1) * 180,
(Math.random() * 2 - 1) * 90
];
}
Insert cell
Insert cell
function* chart(randomPoint) {
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context).pointRadius(0.75);
context.beginPath();
path(graticule);
context.strokeStyle = "#ccc";
context.stroke();
context.beginPath();
path(sphere);
context.strokeStyle = "#000";
context.lineWidth = 1.5;
context.stroke();
context.globalAlpha = 0.5;
for (let i = 0; i < 3e5; ++i) {
context.beginPath();
path({type: "Point", coordinates: randomPoint()});
context.fill();
if (i % 1000 === 0) yield context.canvas;
}
}
Insert cell
projection = d3.geoOrthographic()
.fitExtent([[1, 1], [width - 1, height - 1]], sphere)
.rotate([0, -30])
.precision(0.1)
Insert cell
height = 640
Insert cell
sphere = ({type: "Sphere"})
Insert cell
graticule = d3.geoGraticule10()
Insert cell
d3 = require("d3@6")
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