Published
Edited
Nov 14, 2020
5 stars
Insert cell
Insert cell
Insert cell
spike = (length, width = 7) => `M${-width / 2},0L0,${-length}L${width / 2},0`
Insert cell
length = d3.scaleLinear([0, d3.max(data_raw, d => d.value)], [0, 200])
Insert cell
// data = Object.assign(new Map(d3.csvParse(await FileAttachment("unemployment-x.csv").text(), ({id, rate}) => [id, +rate])), {title: "Unemployment rate (%)"})
Insert cell
Insert cell
data = {
// Create empty object for holding dataset
const vote = {};
// Create property for each ID, give it value from rate
data_raw.forEach(d => (vote[d.id] = +d.gopv));

return vote;
}
Insert cell
Insert cell
// colorDEM = d3.scaleQuantile([d3.min(data_raw, d => d.demv), d3.max(data_raw, d => d.demv)], d3.schemeBlues[9])
colorDEM = d3.scaleQuantile([0,1], d3.schemeBlues[5])
Insert cell
path = d3.geoPath()
Insert cell
format = d => `${d}`
Insert cell
features = new Map(topojson.feature(us, us.objects.counties).features.map(d => [d.id, d]))
Insert cell
states = new Map(us.objects.states.geometries.map(d => [d.id, d.properties]))
Insert cell
us = FileAttachment("counties-albers-10m.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

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