chart = {
const width = 1000;
const height = 400;
const margin = {top: 20, right: 30, bottom: 30, left: 40};
const data = mlbSheet12;
const x = d3.scaleLinear()
.domain(d3.extent(data, d => d.year))
.range([margin.left, width - margin.right]);
const y = d3.scaleLinear()
.domain([0, d3.max(data, d => d.w_s_r/1000000)])
.range([height - margin.bottom, margin.top]).nice();
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
svg.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).tickFormat(d3.format('d')));
svg.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y).ticks(5))
.call(g=> g.selectAll(".tick line")
.attr("x2", width - margin.left - margin.right)
.attr("opacity", .45))
.call(g => g.selectAll(".tick text")
.attr("x", -14))
.call(g=> g.select('.domain').attr('opacity',.00));
svg.append("path")
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-width", 4)
.attr("d", d3.line()
.x(d => x(d.year))
.y(d => y(d.w_s_r/1000000))
(data));
svg.append("path")
.attr("fill", "none")
.attr("stroke", "red")
.attr("stroke-width", 2.5)
.attr("d", d3.line()
.x(d => x(d.year))
.y(d => y(d.w_s_r/1000000))
(data));
svg.append("g")
.selectAll('.rev-circles')
.data(data)
.join("circle")
.attr("class", "rev-circles")
.attr("r", "5")
.attr("stroke", "white")
.attr("cx", d=>x(d.year))
.attr("cy",d => y(d.w_s_r/1000000))
.attr("fill", "red");
svg.append("path")
.attr("fill", "none")
.attr("stroke", "white")
.attr("stroke-width", 4)
.attr("d", d3.line()
.x(d => x(d.year))
.y(d => y(d.rev))
(data));
svg.append("path")
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 2.5)
.attr("d", d3.line()
.x(d => x(d.year))
.y(d => y(d.rev))
(data));
svg.append("g")
.selectAll('.w_s_r-circles')
.data(data)
.join("circle")
.attr("class", "rev-circles")
.attr("r", "5")
.attr("stroke", "white")
.attr("cx", d=>x(d.year))
.attr("cy",d => y(d.rev))
.attr("fill", "steelblue");
svg.append("g")
.selectAll('.w_s_r-text')
.data(data)
.join("text")
.attr("class", "w_s_r-text")
.attr("stroke", "white")
.attr("stroke-width", "1")
.attr("x", d=>x(d.year) -10)
.attr("y",d => y(d.w_s_r/1000000)-7)
.attr('font-size','12px')
.text(d=>d3.format(".1f")(d.w_s_r/1000000))
svg.append("g")
.selectAll('.w_s_r-text')
.data(data)
.join("text")
.attr("class", "w_s_r-text")
.attr("stroke", "lightblack")
.attr("stroke-width", "0.75")
.attr("x", d=>x(d.year) -10)
.attr("y",d => y(d.w_s_r/1000000)-7)
.attr('font-size','12px')
.text(d=>d3.format(".1f")(d.w_s_r/1000000))
svg.append("g")
.selectAll('.rev-text')
.data([data[0],data[11], data[data.length-1]])
.join("text")
.attr("class", "rev-text")
.attr("stroke", "white")
.attr("stroke-width", "1")
.attr("x", d=>x(d.year) -10)
.attr("y",d => y(d.rev)-7)
.attr('font-size','12px')
.text(d=>d3.format(".1f")(d.rev))
svg.append("g")
.selectAll('.rev-text')
.data([data[0], data[11], data[data.length-1]])
.join("text")
.attr("class", "rev-text")
.attr("stroke", "#4682B4")
.attr("stroke-width", "0.5")
.attr("x", d=>x(d.year) -10)
.attr("y",d => y(d.rev)-7)
.attr('font-size','12px')
.text(d=>d3.format(".1f")(d.rev))
return svg.node();
}