|
1 | 1 | #' Use a partial bundle of plotly.js |
2 | 2 | #' |
| 3 | +#' Leveraging plotly.js' partial bundles can lead to smaller file sizes |
| 4 | +#' and faster rendering. The full list of available bundles, and the |
| 5 | +#' trace types that they support, are available [here](https://github.com/plotly/plotly.js/blob/master/dist/README.md) |
3 | 6 | #' |
4 | 7 | #' @param p a plotly object. |
5 | | -#' @param type name of the (partial) bundle. The default `'auto'` attempts to |
6 | | -#' @param version version number (e.g. 1.30.0). See [here](https://github.com/plotly/plotly.js/releases) |
7 | | -#' for a list of valid versions and changelogs. |
8 | | -#' @param local either "local", "cdn", or "rawgit". |
| 8 | +#' @param type name of the (partial) bundle. The default, `'auto'`, attempts to |
| 9 | +#' find the smallest single bundle that can render `p`. If no single partial bundle, |
| 10 | +#' can render `p`, then the full bundle is used. |
| 11 | +#' @param local whether or not to download the partial bundle so that it can be |
| 12 | +#' viewed later without an internet connection. |
9 | 13 | #' @param minified whether or not to use a minified js file (non-minified file can be useful for debugging plotly.js) |
10 | | -#' @export |
11 | 14 | #' @author Carson Sievert |
12 | | -#' @references <https://github.com/plotly/plotly.js/blob/master/dist/README.md> |
13 | | -#' @seealso `[plotly_bundle_info]()` |
14 | | -#' |
| 15 | +#' @export |
15 | 16 | #' @examples |
16 | 17 | #' |
17 | 18 | #' library(plotly) |
@@ -129,8 +130,7 @@ plotlyjsBundle <- function(p) { |
129 | 130 | p$dependencies[[plotlyjsBundleIDX(p)]] |
130 | 131 | } |
131 | 132 |
|
132 | | - |
133 | | -# TODO: create this object from the dist/README.md |
| 133 | +# TODO: create this object in inst/plotlyjs.R from the dist/README.md |
134 | 134 | bundleTraceMap <- list( |
135 | 135 | basic = c( |
136 | 136 | "scatter", |
@@ -184,26 +184,3 @@ bundleTraceMap <- list( |
184 | 184 | "candlestick" |
185 | 185 | ) |
186 | 186 | ) |
187 | | - |
188 | | - |
189 | | - |
190 | | -##' List trace types supported by a particular bundle |
191 | | -##' |
192 | | -##' @export |
193 | | -#partial_bundle_info <- function() { |
194 | | -# for (i in seq_along(bundle_traces)) { |
195 | | -# bundle_name <- names(bundle_traces)[[i]] |
196 | | -# msg <- sprintf( |
197 | | -# "The '%s' bundle size is %s MB and contains the '%s' traces", |
198 | | -# bundle_name, |
199 | | -# round(file.info(bundle_file(bundle_name))$size / 1000000, 3), |
200 | | -# paste(bundle_traces[[i]], collapse = "', '") |
201 | | -# ) |
202 | | -# message(msg) |
203 | | -# } |
204 | | -#} |
205 | | -# |
206 | | -#bundle_file <- function(bundle = "basic") { |
207 | | -# bundle <- match.arg(bundle, names(bundle_traces)) |
208 | | -# system.file("lib", paste0("plotly-", bundle, ".min.js"), package = "plotlyDepends") |
209 | | -#} |
0 commit comments