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.

27 lines
773 B
JavaScript

// SARS-CoV-2-Viz
// Animated COVID case count visualization
// Copyright 2022 Edward L. Platt <ed@elplatt.com>
function createChoropleth(us, msPerFrame, domain) {
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.sevenDayMeanPer100KCap,
domain: 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;
}