chart = {
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
const line = d3
.line()
.x(d => xScale(d.year))
.y(d => yScale(d.value));
const area = d3
.area()
.x(d => xScale(d.year))
.y0(d => yScale(d.value - d.halfwidth))
.y1(d => yScale(d.value + d.halfwidth));
svg
.append("path")
.attr("fill", "pink")
.attr("d", area(fitted));
svg
.append("path")
.attr("fill", "none")
.attr("stroke", "black")
.attr("d", line(data));
svg
.append("path")
.attr("fill", "black")
.attr("d", line.curve(curvePoints(2))(data));
svg
.append("path")
.attr("fill", "none")
.attr("stroke", "red")
.attr("d", line.curve(d3.curveLinear)(fitted));
return svg.node();
}