SigmaJS: Create a snapshot of "sigma-containter"

19 Views Asked by At

The problem with taking a screenshot is that the canvas is divided into several sections:

enter image description here

I am using Angular and I don't see a way to capture it, I have tried to create a single canvas combining the existing ones but the styles are not maintained in the new one.

I try:

downloadGrafo() {
        var sigmaContainer = document.getElementById('sigma-container');
        var combinedCanvas = document.createElement('canvas');
        combinedCanvas.width = sigmaContainer.offsetWidth;
        combinedCanvas.height = sigmaContainer.offsetHeight;
        var ctx = combinedCanvas.getContext('2d');

        sigmaContainer.querySelectorAll('canvas').forEach(function(canvas) {
            // Dibujar el contenido del canvas en el canvas combinado
            ctx.drawImage(canvas, 0, 0);
        });

        var imageDataURL = combinedCanvas.toDataURL();
        var downloadLink = document.createElement('a');
        downloadLink.href = imageDataURL;

        downloadLink.download = 'sigma_image.png';

        downloadLink.click();
    }
0

There are 0 best solutions below