reactivePlot: fix infinite recursion when height/width is function

This commit is contained in:
Winston Chang
2013-03-04 11:20:14 -06:00
parent 4e71b9576d
commit cbcf9ce645

View File

@@ -49,17 +49,22 @@ renderPlot <- function(expr, width='auto', height='auto', ...,
args <- list(...)
if (is.function(width))
width <- reactive({ width() })
widthWrapper <- reactive({ width() })
else
widthWrapper <- NULL
if (is.function(height))
height <- reactive({ height() })
heightWrapper <- reactive({ height() })
else
heightWrapper <- NULL
return(function(shinyapp, name, ...) {
png.file <- tempfile(fileext='.png')
if (is.function(width))
width <- width()
if (is.function(height))
height <- height()
if (!is.null(widthWrapper))
width <- widthWrapper()
if (!is.null(heightWrapper))
height <- heightWrapper()
# Note that these are reactive calls. A change to the width and height
# will inherently cause a reactive plot to redraw (unless width and