{
const width = 1000;
const height = 500;
const margin = {top: 30, right: 100, bottom: 40, left: 80};
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const x = d3.scaleLinear()
.domain(d3.extent(dataByYear, d => d.year))
.range([margin.left, width - margin.right]);
const y = d3.scaleLinear()
.domain([0, d3.max(dataByYear, d => Math.max(d.donated, d.received))]).nice()
.range([height - margin.bottom, margin.top]);
const lineDonated = d3.line()
.x(d => x(d.year))
.y(d => y(d.donated));
const lineReceived = d3.line()
.x(d => x(d.year))
.y(d => y(d.received));
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));
svg.append("path")
.datum(dataByYear)
.attr("fill", "none")
.attr("stroke", "#d73027")
.attr("stroke-width", 2)
.attr("d", lineDonated);
svg.append("path")
.datum(dataByYear)
.attr("fill", "none")
.attr("stroke", "#4575b4")
.attr("stroke-width", 2)
.attr("d", lineReceived);
return svg.node();
}