Public
Edited
Mar 12, 2024
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function copy(text) {
const fakeElem = document.body.appendChild(document.createElement("input"));
fakeElem.style.position = "absolute";
fakeElem.style.left = "-9999px";
fakeElem.setAttribute("readonly", "");
fakeElem.value = "" + text;
fakeElem.select();
try {
return document.execCommand("copy");
} catch (err) {
return false;
} finally {
fakeElem.parentNode.removeChild(fakeElem);
}
}
Insert cell
counties = topojson
.feature(us, us.objects.counties)
.features.filter(d => d.id.startsWith(state.id))
.map(feature => {
const id = feature.id;
const properties = feature.properties;
const bounds = d3
.geoPath()
.bounds(feature)
.map(bound => {
return bound.map(d => +d.toFixed(6));
});

return {
id,
name: properties.name,
bounds
};
})
.sort((a, b) => d3.ascending(a.name, b.name))
Insert cell
us = d3.json(geography_url)
Insert cell
geography_url = "https://unpkg.com/us-atlas@3.0.1/counties-10m.json"
Insert cell
topojson = require('topojson-client@3')
Insert cell
html`<style>.bounds-table tbody tr:hover { background-color: #efefef; }<style>`
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