chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.selectAll("g")
.data(d3.stack().keys(columns)(data2))
.join("g")
.attr("fill", e => color(e.key))
.selectAll("rect")
.data(e => e)
.join("rect")
.attr("x", (e, i) => x(e.data.year))
.attr("y", e => y(e[1]))
.attr("height", e => y(e[0]) - y(e[1]))
.attr("width", x.bandwidth());
svg.append("text")
.attr("x", width / 2)
.attr("y", height - margin.bottom / 2)
.attr("text-anchor", "middle")
.text("Year");
svg.append("text")
.attr("x", -height / 2)
.attr("y", margin.left / 2)
.attr("text-anchor", "middle")
.attr("transform", "rotate(-90)")
.text("Net Energy Generated");
return svg.node();
}