chart2 = {
let data = chart2_data;
let x = d3
.scaleLinear()
.domain(d3.extent(data['United States'], d => d.cases_per_mil))
.range([margin.left, width - margin.right]);
let y = d3
.scaleLinear()
.domain([60, d3.max(data['Japan'], d => d.rates)])
.nice()
.range([height - margin.bottom, margin.top]);
let line = d3
.line()
.curve(d3.curveCatmullRom)
.x(d => x(d.cases_per_mil))
.y(d => y(d.rates));
let xAxis = g =>
g.attr("transform", `translate(0,${height - margin.bottom})`).call(
d3
.axisBottom(x)
.ticks(width / 80)
.tickSizeOuter(0)
);
let yAxis = g =>
g.attr("transform", `translate(${margin.left},0)`).call(d3.axisLeft(y));
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
svg
.append("path")
.datum(data['United States'])
.attr("fill", "none")
.attr("stroke", "Maroon")
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
svg
.append("path")
.datum(data['Canada'])
.attr("fill", "none")
.attr("stroke", "orange")
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
svg
.append("path")
.datum(data['Japan'])
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
svg
.append("text")
.attr("x", 95)
.attr("y", 65)
.text("Japan")
.style("font-size", "15px")
.style("fill", "steelblue")
.attr("alignment-baseline", "middle");
svg
.append("text")
.attr("x", 148)
.attr("y", 320)
.text("Canada")
.style("font-size", "15px")
.style("fill", "orange")
.attr("alignment-baseline", "middle");
svg
.append("text")
.attr("x", 370)
.attr("y", 323)
.text("United States")
.style("font-size", "15px")
.style("fill", "Maroon")
.attr("alignment-baseline", "middle");
svg
.append("text")
.attr("x", width / 2)
.attr("y", 40)
.style('text-anchor', 'middle')
.style("font-size", "20px")
.text("Relationship Between Cases per Million & Unemployment Rate");
svg
.append("text")
.attr("x", width / 2)
.attr("y", height - 20)
.style('text-anchor', 'middle')
.text('#Cases per Million');
svg
.append("text")
.attr("x", -(height / 2))
.attr("y", Math.floor(margin.left / 2))
.style("text-anchor", "middle")
.attr('transform', "rotate(-90)")
.text("Employment Rate %");
return svg.node();
}