{
const width = 500;
const height = 300;
const marginTop = 25;
const marginRight = 20;
const marginBottom = 35;
const marginLeft = 40;
const x = d3.scaleUtc()
.domain(d3.extent(appleStockData, d => d.Date)).nice()
.range([0, width]);
const y = d3.scaleLinear()
.domain(d3.extent(appleStockData, d => d.Close)).nice()
.range([height, 0]);
const svg = d3.create("svg")
.attr("width", width + marginLeft + marginRight)
.attr("height", height + marginTop + marginBottom);
const g = svg.append("g")
.attr("transform", `translate(${marginLeft}, ${marginTop})`);
g.append("g")
.attr("transform", `translate(0,${height})`)
.call(d3.axisBottom(x).ticks(width / 80))
g.append("g")
.call(d3.axisLeft(y))
g.append("g")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr("fill", "none")
.selectAll("circle")
.data(appleStockData)
.join("circle")
.attr("cx", d => x(d.Date))
.attr("cy", d => y(d.Close))
.attr("r", 2);
return svg.node();
}