10000 Localizing user-supplied expression in renderPlotly() by cpsievert · Pull Request #1640 · plotly/plotly.R · GitHub
[go: up one dir, main page]

Skip to content

Localizing user-supplied expression in renderPlotly() #1640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ renderPlotly <- function(expr, env = parent.frame(), quoted = FALSE) {
quoted <- TRUE
expr <- substitute(expr)
}
# Install the (user-supplied) expression as a function
# Wrap the (user-supplied) expression in local()
# This way, if the user-supplied expression contains a return()
# statement, we can capture that return value and pass it along
# to prepareWidget()
expr <- call("local", expr, env)
# prepareWidget() makes it possible to pass different non-plotly
# objects to renderPlotly() (e.g., ggplot2, promises). It also is used
# to inform event_data about what events have been registered
shiny::installExprFunction(expr, "func", env, quoted, assign.env = env)
expr <- quote(plotly:::prepareWidget(func()))
expr <- as.call(list(call(":::", quote("plotly"), quote("prepareWidget")), expr))
renderFunc <- shinyRenderWidget(expr, plotlyOutput, env, quoted)
# remove 'internal' plotly attributes that are known to cause false
# positive test results in shinytest (snapshotPreprocessOutput was added
Expand Down
0