Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

save_d3_html

Save a D3 visualization as HTML


Description

Save a D3 visualization to an HTML file (e.g. for sharing with others).

Usage

save_d3_html(
  d3,
  file,
  selfcontained = TRUE,
  libdir = NULL,
  background = "white",
  title = "D3 Visualization",
  knitrOptions = list()
)

Arguments

d3

D3 visualization to save

file

File to save HTML into

selfcontained

Whether to save the HTML as a single self-contained file (with external resources base64 encoded) or a file with external resources placed in an adjacent directory.

libdir

Directory to copy HTML dependencies into (defaults to filename_files).

background

Text string giving the html background color of the widget. Defaults to white.

title

Text to use as the title of the generated page.

knitrOptions

A list of knitr chunk options.

Details

Using selfcontained set to TRUE requires pandoc to be installed.

See Also

Examples

library(r2d3)

viz <- r2d3(
  data = c(0.3, 0.6, 0.8, 0.95, 0.40, 0.20),
  script = system.file("examples/barchart.js", package = "r2d3")
)

save_d3_html(
  viz,
  file = tempfile(fileext = ".html"),
  selfcontained = FALSE
)

r2d3

Interface to 'D3' Visualizations

v0.2.5
BSD_3_clause + file LICENSE
Authors
Nick Strayer [aut, cre], Javier Luraschi [aut], JJ Allaire [aut], Mike Bostock [ctb, cph] (d3.js library, http://d3js.org), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.