chart = {
const svg = d3
.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.style("background-color", maskColor);
svg.append("g").call(yGrid);
const g = svg
.selectAll("g")
.data(barsData)
.join("g")
.attr("fill", (d) => colorScale(d.key));
const stackedBarChart = g
.selectAll("rect")
.data((d) => d)
.join("rect")
.attr("x", (d) => xScale(d.data.year))
.attr("y", (d) => yScale(d[1]))
.attr("height", (d) => yScale(d[0]) - yScale(d[1]))
.attr("width", xScale.bandwidth());
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}