Skip to content

Commit c20823d

Browse files
committed
orca was assuming the plotly.js html dependency was a full path
1 parent c488c5e commit c20823d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

R/orca.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
7373

7474
# find the relevant plotly.js bundle
7575
plotlyjs <- plotlyjsBundle(b)
76-
plotlyjs_file <- file.path(plotlyjs$src$file, plotlyjs$script)
76+
plotlyjs_path <- file.path(plotlyjs$src$file, plotlyjs$script)
77+
# package field means src file path should be relative to pkg dir
78+
if (!is.null(plotlyjs$package)) {
79+
plotlyjs_path <- system.file(plotlyjs_path, package = plotlyjs$package)
80+
}
7781

7882
tmp <- tempfile(fileext = ".json")
7983
cat(to_JSON(b$x[c("data", "layout")]), file = tmp)
@@ -82,7 +86,7 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
8286
"graph", tmp,
8387
"-o", file,
8488
"--format", format,
85-
"--plotlyjs", plotlyjs_file,
89+
"--plotlyjs", plotlyjs_path,
8690
if (debug) "--debug",
8791
if (verbose) "--verbose",
8892
if (safe) "--safe-mode",
@@ -143,12 +147,16 @@ orca_serve <- function(port = 5151, mathjax = FALSE, safe = FALSE, request_limit
143147

144148
# use main bundle since any plot can be thrown at the server
145149
plotlyjs <- plotlyMainBundle()
146-
plotlyjs_file <- file.path(plotlyjs$src$file, plotlyjs$script)
150+
plotlyjs_path <- file.path(plotlyjs$src$file, plotlyjs$script)
151+
# package field means src file path should be relative to pkg dir
152+
if (!is.null(plotlyjs$package)) {
153+
plotlyjs_path <- system.file(plotlyjs_path, package = plotlyjs$package)
154+
}
147155

148156
args <- c(
149157
"serve",
150158
"-p", port,
151-
"--plotly", plotlyjs_file,
159+
"--plotly", plotlyjs_path,
152160
if (safe) "--safe-mode",
153161
if (orca_version() >= "1.1.1") "--graph-only",
154162
if (keep_alive) "--keep-alive",

0 commit comments

Comments
 (0)