Skip to content

Commit

Permalink
declare all HTML deps via R functions -- yaml approach doesn't provid…
Browse files Browse the repository at this point in the history
…e enough control over ordering of dependencies

allows me to place polyfills b4 plotly.js bundle which fixes #1010
  • Loading branch information
cpsievert committed May 16, 2017
1 parent 7a71d7a commit 183006c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
19 changes: 17 additions & 2 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,11 @@ as_widget <- function(x, ...) {
defaultHeight = 400
),
preRenderHook = plotly_build,
dependencies = c(crosstalk::crosstalkLibs(), list(typedArrayPolyfill()))
dependencies = c(
list(typedArrayPolyfill()),
crosstalk::crosstalkLibs(),
list(plotlyMainBundle())
)
)
# set an ID to avoid the rmarkdown warning ('.Random.seed' is not an integer vector but of type 'NULL', so ignored)
# note this will throw a warning in shiny, but it is at least less obtrusive
Expand All @@ -377,12 +381,23 @@ as_widget <- function(x, ...) {

typedArrayPolyfill <- function() {
htmltools::htmlDependency(
"typedarray", 0.1,
"typedarray", "0.1",
src = depPath("typedarray"),
script = "typedarray.min.js"
)
}

# TODO: suggest a plotlyBundles package that has trace-level bundles
# and bundle size at print time.
plotlyMainBundle <- function() {
htmltools::htmlDependency(
"plotlyjs", "1.27.0",
src = depPath("plotlyjs"),
script = "plotly-latest.min.js",
stylesheet = "plotly-htmlwidgets.css"
)
}

#' Remove TypedArray polyfill
#'
#' By default, plotly.js' TypedArray polyfill is included as a dependency, so
Expand Down
6 changes: 0 additions & 6 deletions inst/htmlwidgets/plotly.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
dependencies:
- name: plotlyjs
version: 1.27.0
src: "htmlwidgets/lib/plotlyjs"
script: plotly-latest.min.js
stylesheet: plotly-htmlwidgets.css

0 comments on commit 183006c

Please sign in to comment.