Published unlisted
Edited
May 20, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
anim_frame_year
Insert cell
anim_data_pre["2010"]
Insert cell
update = chart.update(anim_data_pre.get(anim_frame_year));
Insert cell
viewof anim_frame_year = Scrubber(d3.ticks(2000, 2020, 20), {
autoplay: false,
loop: false,
initial: 50,
format: x => `Year: ${x.toFixed(0)}`
})
Insert cell
Insert cell
Insert cell
outline = ({type: "Sphere"})
Insert cell
width = 1500;
Insert cell
height = {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline);
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
year = 2019
Insert cell
indicators = d3.csvParse(await FileAttachment("Basic Global Birthright Indicators 2000-2020a Feb 25.csv").text())
Insert cell
selected_indicator
Insert cell
indicators.filter(d => d.Year == "2020")
Insert cell
anim_data = indicators.filter(d => d.Year == anim_frame_year)
Insert cell
Insert cell
anim_data_pre.get(2001);
Insert cell
anim_data_pre = {
let data_by_year = new Map();
for(let year = 2000; year <= 2020; year++) {
let mymap = new Map();
indicators.filter(d => d.Year == year).forEach(d => {
mymap.set(rename.get(d.Country) || d.Country, d[selected_indicator]);
})
data_by_year.set(year, mymap);
}
return data_by_year;
}
Insert cell
data.get("Australia")
Insert cell
Insert cell
rename.get("Congo - Kinshasa");
Insert cell
rename.get("Afghanistan");
Insert cell
Insert cell
Insert cell
color = d3.scaleQuantize([0.0, 1], d3.schemeYlGn[9])
Insert cell
projection = d3.geoEqualEarth()
Insert cell
path = d3.geoPath(projection)
Insert cell
format = d => `${d}%`
Insert cell
world = FileAttachment("countries-50m.json").json()
Insert cell
topojson = require("topojson-client@3")
Insert cell
d3 = require("d3@6")
Insert cell
import {legend} from "@d3/color-legend"
Insert cell
import {Select} from "@observablehq/inputs"
Insert cell
import {Scrubber} from "@mbostock/scrubber"
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