Published
Edited
May 14, 2020
Insert cell
Insert cell
Insert cell
Insert cell
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
outline = ({type: "Sphere"})
Insert cell
width = 975
Insert cell
path_points = d3.geoPath().projection(projection)
Insert cell
path_basemap = d3.geoPath().projection(projection)
Insert cell
projection = d3.geoEqualEarth()
Insert cell
format = d3.format(".2s")
Insert cell
//proportional symbols
//radius = d3.scaleSqrt([0, d3.max(attribute)], [0, 10])
Insert cell
radius = d3.scaleThreshold()
.domain(naturalbreaks)
.range(radiusArray)
Insert cell
sizeArrayForLegend = Array.from(radiusArray, d=>Math.PI*Math.pow(d, 2))
Insert cell
radiusArray = [1, 3.3, 7, 11]
Insert cell
circleLabels = Array.from(naturalbreaks, d=> format(Math.pow(d, 2)))
Insert cell
colors = d3.scaleThreshold()
.domain(naturalbreaks)
.range(GnBlu)
Insert cell
GnBlu = ["#ffffcc", "#a1dab4", "#41b6c4", "#225ea8"]
Insert cell
naturalbreaks = simple.ckmeans(attribute, 4).map(v => v.pop())
Insert cell
d3.max(attribute)
Insert cell
attribute = Array.from(points.features, d=>Math.sqrt(Number(d.properties[attributeName])))
Insert cell
attributeName = "globalDemocracyData_democracy_duration"
Insert cell
idName = "name"
Insert cell
//import the point data (geojson)
points = FileAttachment("countries_points.geojson").json()
Insert cell
//import the polygon base map data
basepolygons = FileAttachment("countries-50m.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
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