You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
833 B
JavaScript
30 lines
833 B
JavaScript
// SARS-CoV-2-Viz
|
|
// Animated COVID case count visualization
|
|
// Copyright 2022 Edward L. Platt <ed@elplatt.com>
|
|
|
|
function createChoropleth(us, msPerFrame) {
|
|
|
|
const counties = topojson.feature(us, us.objects.counties);
|
|
const states = topojson.feature(us, us.objects.states)
|
|
const statemesh = topojson.mesh(
|
|
us, us.objects.states, (a, b) => a !== b)
|
|
const statemap = new Map(states.features.map(d => [d.id, d]));
|
|
|
|
let chart = Choropleth({
|
|
id: d => d.FIPS,
|
|
value: d => d.sevenDayMean,
|
|
domain: d => {
|
|
let domain = [0, Math.max(1, d["00000"].dayMax)];
|
|
return domain;
|
|
},
|
|
title: (f, d) => `${f.properties.name}, ${statemap.get(f.id.slice(0, 2)).properties.name}\n${d?.sevenDayMean}`,
|
|
features: counties,
|
|
borders: statemesh,
|
|
width: 975,
|
|
height: 610,
|
|
duration: msPerFrame
|
|
});
|
|
|
|
return chart;
|
|
}
|