{
const context = DOM.context2d(width, width - 40);
context.canvas.style.display = "block";
context.canvas.style.maxWidth = "100%";
context.canvas.style.margin = "auto";
context.translate(width / 2, width / 2);
line.context(context);
data.forEach(d => {
context.save();
const x = 360 * d.i / data.length * Math.PI / 180;
context.rotate(x - Math.PI/2);
context.translate(366, 0);
if (x >= Math.PI) {
context.textAlign = "right";
context.rotate(Math.PI);
context.translate(-3, 0);
} else {
context.textAlign = "left";
context.translate(3, 0);
}
context.fillText(d.name, 0, 3);
context.restore();
context.save();
context.globalCompositeOperation = "multiply";
context.strokeStyle = "lightsteelblue";
const x1 = 360 * d.i / data.length * Math.PI / 180;
const y1 = 366;
d.links.forEach(l => {
const x2 = 360 * l.i / data.length * Math.PI / 180;
const y2 = 366;
context.beginPath();
line([
{x:x1, y:y1},
{x:0, y:0},
{x:x2, y:y1},
]);
context.stroke();
});
context.restore();
});
return context.canvas;
}