How to save interactive charts from dygraph

后端 未结 2 1012
无人及你
无人及你 2020-12-29 00:16

I produce interactive graphs using dygraph. I can view them in the \"Viewer\" window in R studio and in a browser.

What is the most convenient way to sa

2条回答
  •  情话喂你
    2020-12-29 01:19

    htmlwidgets have a saveWidget function which lets you save the full visualization out as a standalone (or composite) HTML file.

    As Miha said, you can knit them as well.

    If you don't need the interactivity (which is unlikely in the case of dygraphs) you can also use SVG Crowbar 2 to save out the SVG from the displayed visualization in a browser.

    With regard to the "knitting", here's a sample R Markdown document with a dygraph in it:

    ---
    title: "dygraphs knit example"
    author: "Bob Rudis (@hrbrmstr)"
    date: "March 17, 2015"
    output: html_document
    ---
    
    ```{r}
    library(dygraphs)
    dygraph(nhtemp, main = "New Haven Temperatures") %>% 
      dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))
    ```
    

    Knit that in RStudio and it'll generate a self-contained HTML with the visualization.

提交回复
热议问题