chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
svg.append("g")
.call(grid);
svg.append("g")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr("fill", "none")
.selectAll("circle")
.data(coronaData)
.join("circle")
.attr("cx", d => x(d.total_cases))
.attr("cy", d => y(d.total_deaths))
.attr("r", 3)
.attr("title", d => d.title);
svg.append("g")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.selectAll("text")
.data(coronaData)
.join("text")
.attr("dy", "0.35em")
.attr("x", d => x(d.total_cases) + 7)
.attr("y", d => y(d.total_deaths))
.text(d => { const diff = Math.round(100*d.total_deaths/regressor.predict(d.total_cases)); return `${d.code} (%${diff})`});
svg.append("path")
.attr("class", "regression")
.datum(regressor)
.attr("d", lineGenerator);
return svg.node();
}