{
const svg = d3.create("svg").attr("width", width).attr("height", height);
svg
.append("g")
.attr("transform", `translate(0,${height - margin.bottom})`)
.attr("class", "x-axis")
.call(xAxis);
svg
.append("g")
.attr("class", "y-axis")
.attr("transform", `translate(${margin.left}, 0)`)
.call(yAxis);
svg
.append("path")
.datum(data)
.attr("fill", "none")
.attr("stroke", "#8868cb")
.attr("stroke-width", 1.8)
.attr("d", line);
const lastValue = data[data.length - 1];
svg
.append("circle")
.attr("cx", width - margin.right)
.attr("cy", yScale(lastValue.price))
.attr("r", 5.8)
.attr("fill", "#8868cb")
.attr("stroke", "#fff")
.attr("stroke-width", 1);
d3.select("#price").text(`${format(lastValue.price)}`);
d3.select("#date").text(`${d3.timeFormat("%b %d, %Y")(lastValue.timestamp)}`);
return svg.node();
}