choropleth = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.attr("transform", "translate(360,20)")
.append(() =>
legend({
color: color,
title: data.title,
width: 260,
tickFormat: ".3%"
})
);
svg.append("g")
.selectAll("path")
.data(counties.features)
.join("path")
.attr("stroke", "white")
.attr("stroke-linejoin", "round")
.attr("fill", function(d){
var org_fips = d.properties.CO_FIPS.toString()
var fips = d.properties.CO_FIPS.toString()
var numdigits = org_fips.length
if(numdigits == 1){
fips = "1700" + org_fips
}else if(numdigits == 2){
fips = "170" + org_fips
}
else if(numdigits == 3){
fips = "17" + org_fips
}
var mycolor = color(data.get(fips)[2])
return mycolor
})
.attr("d", path)
.append("title")
return svg.node();
}