renderMap = (config = {}) => {
const features = config.features || cartoData.features;
const field = config.field || "";
const race = config.race || "";
const color = colorScale.copy().range(config.color);
const title = `${race} cases per 10,000`;
const chart = html`
<div class="chart-container">
<div style="width: 110px; margin: 0 auto;">
${legend({
color,
title,
width: 110,
tickSize: 5,
height: 45
})}
</div>
<svg viewBox="0 0 ${dims.width} ${dims.height}">
<g stroke="#999" stroke-linejoin="round" stroke-linecap="round">
<!-- background -->
<path fill="#F5F5F5" stroke-width="0" d="${path(
topojson.feature(us, us.objects.nation)
)}"></path>
<!-- counties -->
${features.map(
d =>
`<path class="county" fill="${color(
d.properties[field]
)}" stroke-width="0" d=${path(d)}>
<title>${d.properties[field]}</title>
</path>`
)}
<path fill="none" stroke="#f1f1f1" stroke-width="0.5" d="${path(
topojson.mesh(
us,
us.objects.counties,
(a, b) => a !== b && ((a.id / 1000) | 0) === ((b.id / 1000) | 0)
)
)}"></path>
<path fill="none" stroke-width="0.5" d="${path(
topojson.mesh(us, us.objects.states, (a, b) => a !== b)
)}"></path>
</g>
</svg>
</div>`;
return chart;
}