remake icon indicating copy to clipboard operation
remake copied to clipboard

Feature: save `diagram` as png (etc)?

Open rBatt opened this issue 10 years ago • 7 comments

Is there a way to save the output of diagram()? Current, it creates a .html file which opens in my browser.

Additionally, how do I redirect the output and name of the .html file it creates?

rBatt avatar Dec 15 '15 01:12 rBatt

@rich-iannone; do you have a best-practices way of doing this?

richfitz avatar Dec 15 '15 01:12 richfitz

Right now I'm using SVG crowbar. I figured out how to get the .html file; I can use saveWidget.

Ultimately I liked to put the diagram into the README of the GitHub repo.

rBatt avatar Dec 15 '15 02:12 rBatt

@richfitz unfortunately I know of no good way export content from the Viewer to a graphic format using a function call. There are no lightweight JS libraries (that I know of) that do this sort of thing either.

rich-iannone avatar Dec 15 '15 08:12 rich-iannone

Thanks Rich!

Mostly for my own information later, this thread has some useful hints: https://github.com/ramnathv/htmlwidgets/issues/95

The phantomjs approach looks promising but heavy.

richfitz avatar Dec 15 '15 15:12 richfitz

this is a really great package btw, and diagram() is such a great feature. just giving a :+1: here.

I think you can get the svg out (as @rBatt mentioned), but GH readmes don't really like doing svgs, as you have to point to a rawgit host of the image instead of the relative path.

jordansread avatar Feb 04 '16 16:02 jordansread

There's a brand new package https://github.com/rich-iannone/DiagrammeRsvg from @rich-iannone (just hit CRAN) that could probably get the svg out without a great hassle. If a sensible workflow can be established I'd be happy to add that to the package. Perhaps it could be combined with rsvg to go svg -> png.

richfitz avatar Feb 04 '16 16:02 richfitz

@richfitz yes! Please do that (it's the reason I put that on CRAN). And the rsvg package will convert to various formats. Check some recently updated issues for the DiagrammeR package; there are examples there!

rich-iannone avatar Feb 04 '16 16:02 rich-iannone