chart = {
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
swoosh.context(context);
function render(land) {
context.clearRect(0, 0, width, height);
context.beginPath();
path(sphere);
context.fillStyle = "#fff";
context.fill();
context.beginPath();
path(land);
context.fillStyle = "#ccc";
context.fill();
context.beginPath();
path(sphere);
context.strokeStyle = '#ccc';
context.stroke();
links.forEach((link) => {
context.beginPath();
path(link.feature);
context.globalAlpha = fadeOnEdge(link) * 0.25;
context.shadowColor = '#333';
context.shadowBlur = 5;
context.lineWidth = 0.5;
context.lineWidth = 2;
context.strokeStyle = '#ccc';
context.stroke();
});
context.shadowBlur = 0;
links.forEach((link) => {
context.globalAlpha = fadeOnEdge(link);
context.beginPath();
swoosh(flyingArc(link));
context.strokeStyle = 'tomato';
context.lineWidth = 2;
context.stroke();
context.beginPath();
const [sourceX, sourceY] = projection(link.source);
context.arc(sourceX, sourceY, cityMarkerRadius, 0, 2 * Math.PI);
context.fillStyle = '#666';
context.fill();
context.beginPath();
const [targetX, targetY] = projection(link.target);
context.arc(targetX, targetY, cityMarkerRadius, 0, 2 * Math.PI);
context.fillStyle = '#666';
context.fill();
});
context.lineWidth = 1;
context.globalAlpha = 1;
}
return d3.select(context.canvas)
.call(drag(projection)
.on("drag.render", () => render(land110))
.on("end.render", () => render(land50)))
.call(() => render(land50))
.node();
}