Skip to content

Commit 0904d85

Browse files
committed
Document offline export with Plotly bundles
Explain when partial bundles require a CDN download and when the session cache can satisfy an offline export. Show how to save with the installed full bundle. Fixes #2498
1 parent 4ff1c33 commit 0904d85

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

‎R/partial_bundles.R‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@
1010
#' bundles are used, the most recent bundle will override the other bundles.
1111
#' See the examples section for an example.
1212
#'
13+
#' With `local = TRUE`, the first use of a partial bundle in an R session
14+
#' downloads it from `https://cdn.plot.ly`. Later builds can reuse the cached
15+
#' file in the session's temporary directory without a connection. A
16+
#' self-contained HTML export embeds the local file.
17+
#'
18+
#' With `local = FALSE`, the widget references the CDN. Fetching the bundle
19+
#' for viewing or embedding it in a self-contained export requires an internet
20+
#' connection. To export offline using the full plotly.js bundle included in
21+
#' the package, save the original widget with `htmlwidgets::saveWidget()`.
22+
#'
1323
#' @param p a plotly object.
1424
#' @param type name of the (partial) bundle. The default, `'auto'`, attempts to
1525
#' find the smallest single bundle that can render `p`. If no single partial bundle
1626
#' can render `p`, then the full bundle is used.
17-
#' @param local whether or not to download the partial bundle so that it can be
18-
#' viewed later without an internet connection.
27+
#' @param local whether to download the partial bundle (`TRUE`, the default)
28+
#' or reference it by its CDN URL (`FALSE`).
1929
#' @param minified whether or not to use a minified js file (non-minified file can be useful for debugging plotly.js)
2030
#' @author Carson Sievert
2131
#' @export
2232
#' @examplesIf interactive() || !identical(.Platform$OS.type, "windows")
2333
#'
2434
#' # ----------------------------------------------------------------------
25-
#' # This function is always safe to use when rendering a single
26-
#' # plotly graph. In this case, we get a 3x file reduction.
35+
#' # Compare the full and partial bundle sizes for a single plotly graph.
2736
#' # ----------------------------------------------------------------------
2837
#'
2938
#' \dontrun{
@@ -38,7 +47,9 @@
3847
#' }
3948
#' f1 <- tempfile(fileext = ".html")
4049
#' f2 <- tempfile(fileext = ".html")
50+
#' # Save with the full bundle while offline.
4151
#' save_widget(p, f1)
52+
#' # The first use of this partial bundle needs access to the CDN.
4253
#' save_widget(partial_bundle(p), f2)
4354
#'
4455
#' # ----------------------------------------------------------------------

‎man/partial_bundle.Rd‎

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)