Published
Edited
Apr 5, 2021
4 stars
Insert cell
Insert cell
viewof searched_counties = Search(await d3.csv(counties_csv))
Insert cell
viewof selected_counties = Table(searched_counties)
Insert cell
Insert cell
path = d3.geoPath(projection)
Insert cell
projection = d3
.geoIdentity()
.reflectY(true)
.fitWidth(width, data)
Insert cell
data = {
if (selected_counties.length == 1) {
return (await (await fetch(
`https://us-counties.datasette.io/counties.json?sql=select+AsGeoJSON(geometry)+as+g+from+counties+where+id+%3D+:id&_shape=arrayfirst&_json=g&id=${selected_counties[0].id}`
)).json())[0];
} else {
return null;
}
}
Insert cell
height = Math.ceil(path.bounds(data)[1][1])
Insert cell
max_to_show = 5
Insert cell
counties_csv = 'https://us-counties.datasette.io/counties/counties.csv?_stream=on&_size=max'
Insert cell
d3 = require("d3")
Insert cell
import { Search, Table } from "@observablehq/inputs"
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