renderCachedPlot: pass ... args

This commit is contained in:
Winston Chang
2018-04-16 11:43:14 -05:00
parent 08c6c7781f
commit 5641153272
2 changed files with 33 additions and 6 deletions

View File

@@ -133,6 +133,7 @@
renderCachedPlot <- function(expr, cacheKeyExpr, cacheResetEventExpr = NULL,
baseWidth = 400, aspectRatioRate = 1.2, growthRate = 1.2, res = 72,
scope = "app",
...,
env = parent.frame(), quoted = FALSE, outputArgs = list()
) {
@@ -143,6 +144,8 @@ renderCachedPlot <- function(expr, cacheKeyExpr, cacheResetEventExpr = NULL,
# triggered by the cache key (or width/height) changing.
isolatedFunc <- function() isolate(func())
args <- list(...)
cacheKey <- reactive(substitute(cacheKeyExpr), env = parent.frame(), quoted = TRUE)
.cacheDir <- NULL
@@ -271,8 +274,19 @@ renderCachedPlot <- function(expr, cacheKeyExpr, cacheResetEventExpr = NULL,
} else {
cat("drawReactive(): drawPlot()\n")
# This includes the displaylist.
drawPlot(outputName, session, isolatedFunc, width, height, pixelratio, res,
resultfile = resultFilePath)
do.call("drawPlot", c(
list(
name = outputName,
session = session,
func = isolatedFunc,
width = width,
height = height,
pixelratio = pixelratio,
res = res,
resultfile = resultFilePath
),
args
))
}
},
catch = function(reason) {
@@ -343,9 +357,19 @@ renderCachedPlot <- function(expr, cacheKeyExpr, cacheResetEventExpr = NULL,
} else {
cat("renderFunc(): resizeSavedPlot()\n")
img <- resizeSavedPlot(name, shinysession, result,
width, height, pixelratio, res,
resultfile = resultFilePath)
img <- do.call("resizeSavedPlot", c(
list(
name,
shinysession,
result,
width,
height,
pixelratio,
res,
resultfile = resultFilePath
),
args
))
}
}

View File

@@ -6,7 +6,7 @@
\usage{
renderCachedPlot(expr, cacheKeyExpr, cacheResetEventExpr = NULL,
baseWidth = 400, aspectRatioRate = 1.2, growthRate = 1.2, res = 72,
scope = "app", env = parent.frame(), quoted = FALSE,
scope = "app", ..., env = parent.frame(), quoted = FALSE,
outputArgs = list())
}
\arguments{
@@ -38,6 +38,9 @@ smaller and larger.}
\code{"session"}, or the path to a directory to store cached plots. See the
Cache Scoping section for more information.}
\item{...}{Arguments to be passed through to \code{\link[grDevices]{png}}.
These can be used to set the width, height, background color, etc.}
\item{env}{The environment in which to evaluate \code{expr}.}
\item{quoted}{Is \code{expr} a quoted expression (with \code{quote()})? This