How to save interactive charts from dygraph

那年仲夏 提交于 2019-11-30 04:07:33

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.

From the dygraphs for R website:

You can use dygraphs within R Markdown documents just like any other R plotting function. However, rather than a PNG file being included in your document, the JavaScript required to render your dygraph is included.

It means that (from within Rstudio), using knitr and Rmarkdown packages, you can knit a standalone html document that includes dygraphs. You can email the html file if you like.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!