Final fixes to download
This commit is contained in:
31
app.R
31
app.R
@@ -621,6 +621,17 @@ server <- function(input, output, session) {
|
||||
})
|
||||
|
||||
|
||||
isAbsolutePath = function( path ){
|
||||
if( path == "~" )
|
||||
return(TRUE);
|
||||
if( grepl("^~/", path) )
|
||||
return(TRUE);
|
||||
if( grepl("^.:(/|\\\\)", path) )
|
||||
return(TRUE);
|
||||
if( grepl("^(/|\\\\)", path) )
|
||||
return(TRUE);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
exportOrca <- function (p, file = "plot.png", format = tools::file_ext(file),
|
||||
scale = NULL, width = NULL, height = NULL,
|
||||
@@ -635,17 +646,31 @@ server <- function(input, output, session) {
|
||||
b <- plotly_build(p)
|
||||
|
||||
plotlyjs <- b$dependencies[sapply(b$dependencies, function(d) { d$name == "plotly-main" })][[1]]
|
||||
plotlyjs_file <- file.path(plotlyjs$src$file, plotlyjs$script)
|
||||
|
||||
if (!isAbsolutePath(plotlyjs$src$file)) {
|
||||
plotlyjs_file <- NULL
|
||||
for(n in 1:length(.Library.site)) {
|
||||
if (!is.null(plotlyjs_file)) {
|
||||
next
|
||||
}
|
||||
f <- paste0(.Library.site[[n]], "/plotly/", plotlyjs$src$file, "/", plotlyjs$script)
|
||||
if (file.exists(f)) {
|
||||
plotlyjs_file <- f
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plotlyjs_file <- file.path(plotlyjs$src$file, plotlyjs$script)
|
||||
}
|
||||
|
||||
args <- c(
|
||||
"graph", shQuote(jsonlite::toJSON(
|
||||
"graph", paste0("'", jsonlite::toJSON(
|
||||
b$x[c("data", "layout")],
|
||||
digits = 50,
|
||||
auto_unbox = TRUE,
|
||||
force = TRUE,
|
||||
null = "null",
|
||||
na = "null"
|
||||
)),
|
||||
), "'"),
|
||||
"-o", file,
|
||||
"--format", format,
|
||||
"--plotlyjs", plotlyjs_file
|
||||
|
||||
Reference in New Issue
Block a user