christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 270 forks source link

Save network diagrams as vector graphics / pdf #270

Closed jradinger closed 4 years ago

jradinger commented 4 years ago

For publications (e.g. in a scientific context) it would be nice to have a simple way to save/export a diagram produced with networkD3 (e.g. sankeyNetwork() ) as pdf or any other vector graphics.

This vector graphics should if possible be not rasterized to allow custom post-production modification as users (like me) want to modify certain parts of the graph (lines, fonts, colors, shapes) manually in a vector-graphics software.

Note: There are ways via library(js2graphic) or library(webshot) to save and transform a htmlwidget to a static graphic output (including pdf), but these methods work via rasterizing the graphic.

cjyetman commented 4 years ago

The SVG result is created by JavaScript in a browser window, so the easiest solution is to open it in a browser and use something like SVG Crowbar.

Doing this in R is probably far out of scope for this package, so I'm going to close this issue, but thanks for the idea and your interest.