Final fixes to download

This commit is contained in:
2019-04-16 17:06:57 +00:00
parent fe6a17841d
commit 7e7355cb89

31
app.R
View File

@@ -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), exportOrca <- function (p, file = "plot.png", format = tools::file_ext(file),
scale = NULL, width = NULL, height = NULL, scale = NULL, width = NULL, height = NULL,
@@ -635,17 +646,31 @@ server <- function(input, output, session) {
b <- plotly_build(p) b <- plotly_build(p)
plotlyjs <- b$dependencies[sapply(b$dependencies, function(d) { d$name == "plotly-main" })][[1]] 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( args <- c(
"graph", shQuote(jsonlite::toJSON( "graph", paste0("'", jsonlite::toJSON(
b$x[c("data", "layout")], b$x[c("data", "layout")],
digits = 50, digits = 50,
auto_unbox = TRUE, auto_unbox = TRUE,
force = TRUE, force = TRUE,
null = "null", null = "null",
na = "null" na = "null"
)), ), "'"),
"-o", file, "-o", file,
"--format", format, "--format", format,
"--plotlyjs", plotlyjs_file "--plotlyjs", plotlyjs_file