// SARS-CoV-2-Viz // Animated COVID case count visualization // Copyright 2022 Edward L. Platt 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.sevenDayMeanPer100KCap, domain: d => { let domain = [0, Math.max(1, d["10001"].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; }