Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dd474e2

Browse filesBrowse files
committed
Wrap user-supplied expression in evalq(), closes #1528
1 parent d11bb5a commit dd474e2
Copy full SHA for dd474e2

File tree

Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed

‎R/shiny.R

Copy file name to clipboardExpand all lines: R/shiny.R
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ plotlyOutput <- function(outputId, width = "100%", height = "400px",
3838
#' @export
3939
renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) {
4040
if (!quoted) { expr <- substitute(expr) } # force quoted
41-
# this makes it possible to pass a ggplot2 object to renderPlotly()
42-
# https://github.com/ramnathv/htmlwidgets/issues/166#issuecomment-153000306
41+
# Wrap the (user-supplied) expression with a call to evalq()
42+
# This way, if the user-supplied expression contains a return()
43+
# statement, we can capture that return value and pass it along
44+
# to prepareWidget()
45+
expr <- call("evalq", expr, env)
46+
# prepareWidget() makes it possible to pass different non-plotly
47+
# objects to renderPlotly() (e.g., ggplot2, promises). It also is used
48+
# to inform event_data about what events have been registered
4349
expr <- as.call(list(call(":::", quote("plotly"), quote("prepareWidget")), expr))
4450
renderFunc <- shinyRenderWidget(expr, plotlyOutput, env, quoted = TRUE)
4551
# remove 'internal' plotly attributes that are known to cause false

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.