chart1 = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
svg.append("g")
.style("font", "0.8em sans-serif")
.call(xAxis);
svg.append("g")
.style("font", "0.8em sans-serif")
.call(y1Axis);
svg.append("path")
.datum(data)
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
const tooltip = svg.append("g");
svg.on("touchmove mousemove", function() {
const {year, population} = bisect(d3.mouse(this)[0]);
tooltip
.attr("transform", `translate(${x(year)},${y1(population)})`)
.call(callout, `${formatValue(d3.format(".2s")(population))}
${(year)}`);
});
svg.on("touchend mouseleave", () => tooltip.call(callout, null));
return svg.node();
}