|
10 | 10 | #' bundles are used, the most recent bundle will override the other bundles. |
11 | 11 | #' See the examples section for an example. |
12 | 12 | #' |
| 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 | +#' |
13 | 23 | #' @param p a plotly object. |
14 | 24 | #' @param type name of the (partial) bundle. The default, `'auto'`, attempts to |
15 | 25 | #' find the smallest single bundle that can render `p`. If no single partial bundle |
16 | 26 | #' 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`). |
19 | 29 | #' @param minified whether or not to use a minified js file (non-minified file can be useful for debugging plotly.js) |
20 | 30 | #' @author Carson Sievert |
21 | 31 | #' @export |
22 | 32 | #' @examplesIf interactive() || !identical(.Platform$OS.type, "windows") |
23 | 33 | #' |
24 | 34 | #' # ---------------------------------------------------------------------- |
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. |
27 | 36 | #' # ---------------------------------------------------------------------- |
28 | 37 | #' |
29 | 38 | #' \dontrun{ |
|
38 | 47 | #' } |
39 | 48 | #' f1 <- tempfile(fileext = ".html") |
40 | 49 | #' f2 <- tempfile(fileext = ".html") |
| 50 | +#' # Save with the full bundle while offline. |
41 | 51 | #' save_widget(p, f1) |
| 52 | +#' # The first use of this partial bundle needs access to the CDN. |
42 | 53 | #' save_widget(partial_bundle(p), f2) |
43 | 54 | #' |
44 | 55 | #' # ---------------------------------------------------------------------- |
|
0 commit comments