makeMap = (year, { w = width / 4, h = width / 4, grouped = false } = {}) => {
const maxYear = year === 2016 ? 2021 : year + 4;
const yearFormat = d3.format("");
return Plot.plot({
width: w,
insetTop: 30,
height: h,
marks: [
Plot.geo(boundariesProj, {
stroke: "#f3f3f3",
strokeWidth: 0.5,
strokeOpacity: 0.3,
fill: "#f3f3f3",
fillOpacity: 0.1
}),
Plot.geo(fires, {
filter: (d) =>
year === "all"
? true
: grouped
? d.id > year && d.id <= maxYear
: +d.id === year,
strokeWidth: 1,
stroke: (d) => +d.id,
fill: (d) => +d.id
}),
Plot.text([year], {
frameAnchor: "top",
dy: 10,
fontSize: 14,
fontFamily: "sans-serif",
text: (d) =>
year === "all"
? "Wildfies, 1986 - 2021"
: grouped
? `${yearFormat(year)} - ${yearFormat(maxYear)}`
: yearFormat(year),
fill: "white"
}),
Plot.frame({ stroke: "#f3f3f3" })
],
x: { axis: null },
y: { axis: null },
color: {
scheme: "Reds"
},
style: {
backgroundColor: "black"
}
});
}