chart = {
const width = 640;
const height = 400;
const margin = { top: 20, right: 30, bottom: 30, left: 40 };
const x = d3
.scaleUtc()
.domain(d3.extent(aapl, (d) => d.Date))
.range([margin.left, width - margin.right]);
const y = d3
.scaleLinear()
.domain([0, d3.max(aapl, (d) => d.Close)])
.range([height - margin.bottom, margin.top]);
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));
svg
.append("g")
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y));
svg
.append("path")
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-width", 1.5)
.attr(
"d",
d3
.line()
.x((d) => x(d.Date))
.y((d) => y(d.Close))(aapl)
);
return svg.node();
}