chart = {
const svg = d3
.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.style("background-color", maskColor);
const areaChart = svg
.append("g")
.selectAll("path")
.data(stackedData)
.join("path")
.attr("fill", (d, i) => colorScale(d.key))
.attr("d", areaGen)
.append("title")
.text(({ key }) => key);
svg.append("g").call(yGrid);
const annortationLine = svg
.append("line")
.attr("x1", xScale(new Date("2021-07-20")))
.attr("y1", yScale(59))
.attr("x2", xScale(new Date("2021-07-20")))
.attr("y2", yScale(2))
.style("stroke", "#888")
.style("stroke-width", 1);
const annotation1 = svg.append("g").attr("text-anchor", "start");
annotation1
.append("text")
.call(styleAnnotations)
.attr("x", xScale(new Date("2021-10-01")))
.attr("y", yScale(15))
.text("Trespassing arrests")
.style("fill", "#4E4F4F");
const annotation2 = svg.append("g").attr("text-anchor", "start");
annotation2
.append("text")
.call(styleAnnotations)
.attr("x", xScale(new Date("2021-10-01")))
.attr("y", yScale(75))
.text("All other arrests")
.style("fill", "#4E4F4F");
const annotation3 = svg.append("g").attr("text-anchor", "start");
annotation3
.append("text")
.call(styleAnnotations)
.attr("x", xScale(new Date("2021-07-19")))
.attr("y", yScale(65))
.text("Trespassing")
.attr("fill", "#000");
const annotation4 = svg.append("g").attr("text-anchor", "start");
annotation4
.append("text")
.call(styleAnnotations)
.attr("x", xScale(new Date("2021-07-19")))
.attr("y", yScale(60))
.text("operation begins")
.attr("fill", "#000");
const annotation5 = svg.append("g").attr("text-anchor", "start");
annotation5
.append("text")
.attr("x", xScale(new Date("2021-03-01")))
.attr("y", yScale(100) - 5)
.text("of arrests per month")
.attr("font-family", "PressuraLight, Courier, monospace")
.attr("font-size", `${fontSize - 2}px`)
.attr("letter-spacing", `-${fontSize * 0.01}px`)
.attr("fill", "#888")
.attr("class", "y-axis-top-label");
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}