From eb28fc368198a8978e4bcc9fd1f8f343662ed319 Mon Sep 17 00:00:00 2001 From: "arsenij.ustjanzew" <arsenij.ustjanzew@mpi-bn.mpg.de> Date: Mon, 2 Mar 2020 14:54:11 +0100 Subject: [PATCH] implemented workaround for plotly dependencies issue --- inst/templates/vis_object.Rmd | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/inst/templates/vis_object.Rmd b/inst/templates/vis_object.Rmd index 425765a..a43ef1c 100644 --- a/inst/templates/vis_object.Rmd +++ b/inst/templates/vis_object.Rmd @@ -7,7 +7,20 @@ if (!requireNamespace("<% package %>", quietly = TRUE)) { stop('The package <% package %> is needed to embed objects of class <% class %>.', call. = FALSE) } -readRDS(file.path(datadir, '<% component_id %>.rds')) +vis_<% component_id %> <- readRDS(file.path(datadir, '<% component_id %>.rds')) + +# workaround for plotly dependencies issue (https://github.com/ropensci/plotly/issues/1044) +# +fix_dependency <- function(dependency){ + if(dependency$name == "jquery") dependency$src$file <- file.path(system.file(package ="crosstalk"), "lib/jquery") + if(dependency$name == "crosstalk") dependency$src$file <- file.path(system.file(package ="crosstalk"), "www") + return(dependency) +} +if ("<% package %>" == "plotly"){ + vis_<% component_id %>$dependencies <- lapply(vis_<% component_id %>$dependencies, fix_dependency) +} + +vis_<% component_id %> ``` -- GitLab