chart = {
const cx = width / 2;
const cy = height / 2;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.attr("text-anchor", "middle")
.attr("fill", "currentColor")
.style("margin", "0 -14px")
.style("display", "block");
svg.append("path")
.attr("d", path(graticule))
.attr("fill", "none")
.attr("stroke", "currentColor")
.attr("stroke-opacity", 0.2);
svg.append("path")
.attr("d", path(outline))
.attr("fill", "none")
.attr("stroke", "currentColor");
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
const hour = svg.append("g")
.selectAll("g")
.data(d3.range(24))
.join("g");
hour.append("path")
.attr("fill", "none")
.attr("stroke", "red")
.attr("stroke-width", 2)
.attr("d", hour => path({
type: "LineString",
coordinates: d3.utcDays(start, end).map(day => {
return solar.position(d3.utcHour.offset(day, hour));
})
}));
hour.append("text")
.datum(hour => d3.utcHour.offset(mid, hour))
.attr("dy", "-1em")
.attr("transform", date => `translate(${projection(solar.position(date))})`)
.text(formatHour);
return svg.node();
}