Published
Edited
Jun 4, 2020
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
usSpikesSVG = usSpikes.node()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// confirmedUSLatest = {
// const data = Array.from(
// d3.group(confirmedUSRaw, d => d.date),
// ([key, value]) => value
// ).sort((a, b) => b.date - a.date);
// const _data = data.filter((d, i) => i === data.length - 1).flat();
// return _data;
// }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
polylines = topojson
.feature(usMap, usMap.objects.counties)
.features.filter(d => !isNaN(path.centroid(d)[1]))
.sort((a, b) => path.centroid(a)[1] - path.centroid(b)[1])
.map(d => {
d.properties.centroid = path.centroid(d);
return d;
})
Insert cell
Insert cell
index = new Map(confirmedUSOnDay.map(d => [d.fips, d]))
Insert cell
nation = topojson.feature(usMap, "nation")
Insert cell
countiesMesh = topojson.mesh(usMap, usMap.objects.counties, (a, b) => a !== b)
Insert cell
statesMesh = topojson.mesh(usMap, usMap.objects.states, (a, b) => a !== b)
Insert cell
counties = topojson.feature(usMap, usMap.objects.counties).features
Insert cell
async function drawUSMap(svg) {
const g = svg.append('g').attr('id', 'usmap');
g.append("path")
.datum(nation)
.attr("fill", "#f3f3f3")
.attr("d", path);

g.append("path")
.datum(countiesMesh)
.attr("fill", "none")
.attr("stroke", '#e6e6e6')
.attr("stroke-width", .5)
.attr("stroke-linejoin", "round")
.attr("d", path);

g.append("path")
.datum(statesMesh)
.attr("fill", "none")
.attr("stroke", '#bdbdbd')
.attr("stroke-width", .5)
.attr("stroke-linejoin", "round")
.attr("d", path);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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