chart = {
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
const constellationLinesPath = d3.geoPath(projection, context);
const graticulePath = d3.geoPath(projection, context);
const starPath = d3
.geoPath(projection, context)
.pointRadius((d) => magnitudeScale(d.properties.mag));
function render() {
context.clearRect(0, 0, width, height);
context.beginPath(),
path(sphere),
(context.fillStyle = "#000"),
context.fill();
context.beginPath(),
graticulePath(graticule),
(context.strokeStyle = "#000"),
context.stroke();
stars.features.forEach((star) => {
context.beginPath(),
starPath(star),
(context.fillStyle = "#999"),
context.fill();
});
context.beginPath(),
constellationLinesPath(constellationLines),
(context.strokeStyle = "#ffffff"),
context.stroke();
context.beginPath(), path(sphere), context.stroke();
}
return d3
.select(context.canvas)
.call(
drag(projection)
.on("drag.render", () => render())
.on("end.render", () => render())
)
.call(() => render())
.node();
}