link = {
return function link(data, options) {
const link = Plot.link(data, options);
link.project = () => {};
link.render = function (
index,
scales,
{ x1: X1, y1: Y1, x2: X2, y2: Y2 },
{ width, height, marginLeft, marginRight, marginTop, marginBottom },
{ projection }
) {
width -= marginLeft + marginRight;
height -= marginTop + marginBottom;
const context = DOM.context2d(width, height);
context.translate(-marginLeft, -marginTop);
const path = d3.geoPath().projection(projection).context(context);
context.strokeStyle = this.stroke;
context.lineWidth = this.strokeWidth;
context.globalCompositeOperation = this.mixBlendMode;
context.globalAlpha = this.opacity;
for (const i of index) {
context.beginPath();
path({
type: "LineString",
coordinates: [
[X1[i], Y1[i]],
[X2[i], Y2[i]]
]
});
context.stroke();
}
return d3
.create("svg:image")
.attr("width", width)
.attr("height", height)
.attr("x", marginLeft)
.attr("y", marginTop)
.attr("xlink:href", context.canvas.toDataURL())
.node();
};
return link;
};
}