povertyMap = {
const svg = d3.create("svg").attr("viewBox", [0, 0, 1000, 630]);
svg
.append("g")
.selectAll("path")
.data(features)
.join("path")
.attr("fill", d => povertyColor(d.properties.percent_below_poverty))
.attr("stroke-linejoin", "round")
.attr("stroke-width", "0")
.attr("d", path);
if (selectedLevel === "chicago") {
svg
.append("g")
.selectAll("path")
.data(
topojson.feature(
CommunityAreas,
CommunityAreas.objects.chicago_community_areas
).features
)
.join("path")
.attr("fill", "none")
.attr("stroke", "#444444")
.attr("stroke-width", ".9")
.attr("d", path);
}
svg
.append("g")
.attr("transform", "translate(500,50),scale(1.25)")
.append(() =>
legend({
color: povertyColor,
ticks: 6,
tickValues: [
minPovertyTract.properties.percent_below_poverty,
BelowPoverty[selectedLevel][selectedYear],
maxPovertyTract.properties.percent_below_poverty
],
tickFormat: ".1f",
title: `% of families below poverty ${selectedYear -
4}-${selectedYear}`,
width: 200
})
);
return svg.node();
}