Published
Edited
Mar 2, 2022
1 fork
11 stars
Insert cell
Insert cell
Insert cell
{
const height = width / 2;
const projection = d3
.geoEqualEarth()
.fitExtent(
[
[2, 2],
[width - 2, height - 2]
],
{ type: "Sphere" }
)
.rotate([-10, 0]);
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);

const path = d3.geoPath(projection);

svg
.append("g")
.append("path")
.datum({ type: "Sphere" })
.attr("d", path)
.attr("stroke", "black")
.attr("stroke-width", 2)
.attr("fill", "beige");

svg
.append("g")
.selectAll("path")
.data(world.features)
.join("path")
.attr("d", path)
.style("fill", (d) => color(d.properties.NAME))
.style("fill-opacity", 0.75)
.style("stroke", "black")
.style("stroke-width", 1.3)
.append("title")
.text((d) => d.properties.NAME);

svg
.append("text")
.attr("transform", "translate(10, 40)")
.style("font-size", "32px")
.text(year);

return svg.node();
}
Insert cell
Insert cell
world = historic(year)
Insert cell
historic = async (year) => {
const shp = await shapes[`f${year.toLowerCase()}`];
return await shapefile.read(
await shp
.file(shp.filenames.find((d) => d.toLowerCase().endsWith(".shp")))
.stream(),
await shp
.file(shp.filenames.find((d) => d.toLowerCase().endsWith(".dbf")))
.stream()
);
}
Insert cell
shapefile = require("shapefile")
Insert cell
Insert cell
shapes = ({
f2000bc,
f1000bc,
f500bc,
f323bc,
f200bc,
f1bc,
f400,
f600,
f800,
f1000,
f1279,
f1492,
f1530,
f1650,
f1715,
f1783,
f1815,
f1880,
f1914,
f1920,
f1938,
f1945,
f1994
})
Insert cell
f2000bc = FileAttachment("2000BC.zip").zip()
Insert cell
f1000bc = FileAttachment("1000BC.zip").zip()
Insert cell
f500bc = FileAttachment("500BC.zip").zip()
Insert cell
f323bc = FileAttachment("323BC.zip").zip()
Insert cell
f200bc = FileAttachment("200BC.zip").zip()
Insert cell
f1bc = FileAttachment("1BC.zip").zip()
Insert cell
f400 = FileAttachment("400.zip").zip()
Insert cell
f600 = FileAttachment("600.zip").zip()
Insert cell
f800 = FileAttachment("800.zip").zip()
Insert cell
f1000 = FileAttachment("1000.zip").zip()
Insert cell
f1279 = FileAttachment("1279.zip").zip()
Insert cell
f1492 = FileAttachment("1492.zip").zip()
Insert cell
f1530 = FileAttachment("1530.zip").zip()
Insert cell
f1650 = FileAttachment("1650.zip").zip()
Insert cell
f1715 = FileAttachment("1715.zip").zip()
Insert cell
f1783 = FileAttachment("1783.zip").zip()
Insert cell
f1815 = FileAttachment("1815.zip").zip()
Insert cell
f1880 = FileAttachment("1880.zip").zip()
Insert cell
f1914 = FileAttachment("1914.zip").zip()
Insert cell
f1920 = FileAttachment("1920.zip").zip()
Insert cell
f1938 = FileAttachment("1938.zip").zip()
Insert cell
f1945 = FileAttachment("1945.zip").zip()
Insert cell
f1994 = FileAttachment("1994.zip").zip()
Insert cell
Insert cell
color = d3.scaleOrdinal(
["unclaimed", "Antarctica", "Africa"],
[
"#e5e5bb",
"#e5e5bb",
"#e5e5bb",
...d3.shuffle(d3.quantize(d3.interpolateWarm, 100))
]
)
Insert cell
import { Scrubber } from "@mbostock/scrubber"
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