Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions R/partial_bundles.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,29 @@
#' bundles are used, the most recent bundle will override the other bundles.
#' See the examples section for an example.
#'
#' With `local = TRUE`, the first use of a partial bundle in an R session
#' downloads it from `https://cdn.plot.ly`. Later builds can reuse the cached
#' file in the session's temporary directory without a connection. A
#' self-contained HTML export embeds the local file.
#'
#' With `local = FALSE`, the widget references the CDN. Fetching the bundle
#' for viewing or embedding it in a self-contained export requires an internet
#' connection. To export offline using the full plotly.js bundle included in
#' the package, save the original widget with `htmlwidgets::saveWidget()`.
#'
#' @param p a plotly object.
#' @param type name of the (partial) bundle. The default, `'auto'`, attempts to
#' find the smallest single bundle that can render `p`. If no single partial bundle
#' can render `p`, then the full bundle is used.
#' @param local whether or not to download the partial bundle so that it can be
#' viewed later without an internet connection.
#' @param local whether to download the partial bundle (`TRUE`, the default)
#' or reference it by its CDN URL (`FALSE`).
#' @param minified whether or not to use a minified js file (non-minified file can be useful for debugging plotly.js)
#' @author Carson Sievert
#' @export
#' @examplesIf interactive() || !identical(.Platform$OS.type, "windows")
#'
#' # ----------------------------------------------------------------------
#' # This function is always safe to use when rendering a single
#' # plotly graph. In this case, we get a 3x file reduction.
#' # Compare the full and partial bundle sizes for a single plotly graph.
#' # ----------------------------------------------------------------------
#'
#' \dontrun{
Expand All @@ -38,7 +47,9 @@
#' }
#' f1 <- tempfile(fileext = ".html")
#' f2 <- tempfile(fileext = ".html")
#' # Save with the full bundle while offline.
#' save_widget(p, f1)
#' # The first use of this partial bundle needs access to the CDN.
#' save_widget(partial_bundle(p), f2)
#'
#' # ----------------------------------------------------------------------
Expand Down
19 changes: 15 additions & 4 deletions man/partial_bundle.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.