{
const width = 600;
const height = 300;
const padding = {top: 20, left: 40, right: 40, bottom: 50};
const graph = d3.select(DOM.svg(width, height));
const formatTime = d3.timeFormat("%b %e");
const data = timeData;
const [startDate, endDate] = d3.extent(data, d => d.date);
const xScale = d3.scaleTime()
.domain([d3.timeDay.offset(startDate, -1), d3.timeDay.offset(endDate, 1)])
.range([padding.left, width - padding.right]);
const yScale = d3.scaleLinear()
.domain([0, d3.max(data, d => d.amount)])
.range([height - padding.bottom, padding.top]);
const xAxis = d3.axisBottom()
.scale(xScale)
.ticks(9)
.tickFormat(formatTime);
const yAxis = d3.axisLeft()
.scale(yScale)
.ticks(10);
const line = d3.line()
.x(d => xScale(d.date))
.y(d => yScale(d.amount));
graph.append("path")
.datum(data)
.attr("fill", "none")
.attr("stroke", "hotpink")
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("stroke-width", 1.5)
.attr("d", line);
graph.append("g")
.attr("class", "x axis")
.attr("transform", `translate(0, ${height - padding.bottom})`)
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", ".15em")
.attr("transform", "rotate(-45)");
graph.append("g")
.attr("class", "y axis")
.attr("transform", `translate(${padding.left}, 0)`)
.call(yAxis);
graph.select(".y.axis")
.append("text")
.text("Unicorn sightings")
.style("text-anchor", "end")
.attr("dx", -padding.top)
.attr("dy", "1em")
.attr("transform", "rotate(-90)")
.attr("fill", "black");
return graph.node();
}