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", "pink")
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
const tooltip = svg.append("g");
const rule = svg.append("g")
.append("line")
.attr("y1", height)
.attr("y2", 0)
.attr("stroke", "black");
svg.on("touchmove mousemove", function() {
const {date, value} = bisect(d3.mouse(this)[0]);
rule.attr("transform", `translate(${x(date) + 0.5}, 0)`);
tooltip
.attr("transform", `translate(${x(date) + 50},${y(value)})`)
.call(callout,
`${value.toLocaleString(undefined, {style: "currency", currency: "USD"})}
${date.toLocaleString(undefined, {month: "short", day: "numeric", year: "numeric"})}`
);
});
svg.on("touchend mouseleave", () => tooltip.call(callout, null));
return svg.node();
}