chart = {
const svg = d3.select(DOM.svg(width, height))
.style("-webkit-tap-highlight-color", "transparent")
.style("overflow", "visible");
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
svg.append("path")
.datum(data)
.attr("fill", "none")
.attr("stroke", color)
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
svg
.append("path")
.datum(data)
.style("fill", `url(#mygrad-${color})`)
.style("stroke", "none")
.attr("d", area);
const tooltip = svg.append("g");
svg.on("touchmove mousemove", function(event) {
const {date, value} = bisect(d3.pointer(event, this)[0]);
tooltip
.attr("transform", `translate(${x(date)},${y(value)})`)
.call(callout, `${formatValue(value)}\n${formatDate(date)}`);
});
svg.on("touchend mouseleave", () => tooltip.call(callout, null));
const lg = svg
.append("defs")
.append("linearGradient")
.attr("id", `mygrad-${color}`)
.attr("x1", "0%")
.attr("x2", "0%")
.attr("y1", "0%")
.attr("y2", "100%");
lg.append("stop")
.attr("offset", "0%")
.style("stop-color", color)
.style("stop-opacity", 0.75);
lg.append("stop")
.attr("offset", "100%")
.style("stop-color", color)
.style("stop-opacity", 0.01);
return svg.node();
}