richfitz / remake

Make-like declarative workflows in R
Other
340 stars 32 forks source link

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

Open rBatt opened 8 years ago

rBatt commented 8 years ago

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?

richfitz commented 8 years ago

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

rBatt commented 8 years ago

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.

rich-iannone commented 8 years ago

@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.

richfitz commented 8 years ago

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.

jordansread commented 8 years ago

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.

richfitz commented 8 years ago

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.

rich-iannone commented 8 years ago

@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!