canvasRender = (i, scales, v, d, c, next) => {
const g = next(i, scales, v, d, c);
const xRange = scales.x.range();
const yRange = scales.y.range();
const width = Math.max(xRange[1], xRange[0]);
const height = Math.max(yRange[1], yRange[0]);
const svgElement = document.createElementNS(
"http://www.w3.org/2000/svg",
"svg"
);
svgElement.setAttribute("xmlns", "http://www.w3.org/2000/svg");
svgElement.setAttribute("width", width);
svgElement.setAttribute("height", height);
svgElement.appendChild(g.cloneNode(true));
const svgData = new XMLSerializer().serializeToString(svgElement);
const svgBlob = new Blob([svgData], {
type: "image/svg+xml;charset=utf-8"
});
const url = URL.createObjectURL(svgBlob);
const imageElement = document.createElementNS(
"http://www.w3.org/2000/svg",
"image"
);
imageElement.setAttributeNS("http://www.w3.org/1999/xlink", "href", url);
imageElement.setAttribute("width", width);
imageElement.setAttribute("height", height);
while (g.firstChild) {
g.removeChild(g.firstChild);
}
g.appendChild(imageElement);
imageElement.classList.add("my-line-y");
return g;
}