cytoscape / cyjShiny

An R/shiny widget for cytoscape.js
Other
92 stars 28 forks source link

save/export network image #19

Closed cavei closed 5 years ago

cavei commented 5 years ago

Hi, I would like to save/export the network created by the app. Is it possible to export in PNG format for example?

Thanks a lot!

Paolo

layerswing commented 5 years ago

I used: var png64 = cy.png(); which generates a base64 png that can be a src for an img or you can add it to a canvas.

var canvas = document.getElementById('myCanvas');  
var ctx = canvas.getContext('2d');
var myImage = new Image();  
myImage.onload = function () {  
   ctx.drawImage(myImage, 0, 0);  
};
myImage.src = myPNG;
paul-shannon commented 5 years ago

@cavei @b2b - Shall I add an adaptation oof b2b's code into the package such that there is a new R api for getting the network into a file in PNG format?

layerswing commented 5 years ago

If somebody wants a snapshot from a (dynamically changing) network it is a good idea to have a save it in png file option.

paul-shannon commented 5 years ago

@cannin @b2b version 0.99.40 - just commited - has the new function

savePngToFile(session, filename)

whose use is demonstrated in

inst/examples/tinyApp/tinyApp.R

Let me know if this is what you were looking for.

cavei commented 5 years ago

@paul-shannon Yes, it works for me! Thanks a lot to all.