rstudio / ggvis

Interactive grammar of graphics for R
Other
713 stars 171 forks source link

export_png() should not require external program to save as png #382

Open shreyasgm opened 9 years ago

shreyasgm commented 9 years ago

export_png() requires vega to be installed. This should be a feature that is built into ggvis, especially because so many users (1, 2, 3) have faced difficulties in installing vg2png on Windows.

I myself only got this far and got the following error:

Writing to file plot.png

Error in vega_file(vis, file = file, type = "png") :

Conversion program vg2pngnot found.

Shouldn't saving the generated graph / chart as a png file be a component of the package?

wch commented 9 years ago

That would be a nice feature, but doing so is non-trivial. The renderer requires a Javascript engine, which is either a web browser or or node.js (that's what vg2png runs on). However, with the new V8 package, this may more feasible now than it was before.

shreyasgm commented 9 years ago

Thanks, Winston. As a temporary fix, would it be possible for you to answer any of the unanswered questions on this topic on SO?

I asked this one.

There were a few others as well: (1, 2, 3)

okeuguru commented 9 years ago

Worked on this for about an hour and could not find a solution for windows. Looks like Ubuntu users have a work-around. https://groups.google.com/forum/#!topic/ggvis/kj0LjkIX8z4

benjaminrobinson commented 8 years ago

Wondering if anything new has been done to try to close this issue in the last year? Might it be more feasible now? You can even download as an SVG in the RStudio environment (albeit manually)...why not as a PNG?

Wario84 commented 8 years ago

Hi guys,

From Linux, I managed to install vega from node.js. The headless mode is running, from the terminal I can run: vg2png ~/npm/lib/node_modules/vega/examples/bar.json bar4.png

However, in my RStudio I still have the same error, I was wondering if there is an additional step?

> mtcars %>% ggvis(~mpg, ~hp) %>% layer_smooths() %>% export_png() Writing to file plot.png Error in vega_file(vis, file = file, type = "png") : Conversion program vg2pngnot found.

This is my session info:

> sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=nl_NL.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=nl_NL.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rsvg_1.0          ggvis_0.4.3       DiagrammeRsvg_0.1 DiagrammeR_0.8.4 

loaded via a namespace (and not attached):
 [1] igraph_1.0.1     Rcpp_0.12.3      rstudioapi_0.6   magrittr_1.5    
 [5] munsell_0.4.2    colorspace_1.2-6 xtable_1.8-0     R6_2.1.2        
 [9] stringr_1.0.0    plyr_1.8.3       dplyr_0.4.3      tools_3.2.5     
[13] visNetwork_1.0.1 parallel_3.2.5   DBI_0.3.1        influenceR_0.1.0
[17] htmltools_0.3    lazyeval_0.1.10  assertthat_0.1   digest_0.6.9    
[21] shiny_0.13.2     htmlwidgets_0.7  curl_0.9.7       mime_0.4        
[25] V8_1.1           stringi_1.0-1    scales_0.4.0     jsonlite_0.9.19 
[29] httpuv_1.3.3    
> 

Any help will be appreciated.