View source: R/shiny-outputs.R
| register_output | R Documentation |
Enable advanced output gadgets such as expanding the output in another browser window, or downloading the rendered data.
register_output_options(
outputId,
...,
.opt = list(),
extras = list(),
session = shiny::getDefaultReactiveDomain()
)
get_output_options(outputId, session = shiny::getDefaultReactiveDomain())
register_output(
render_function,
outputId,
export_type = c("none", "custom", "pdf", "csv", "3dviewer", "htmlwidget"),
export_settings = list(),
quoted = FALSE,
output_opts = list(),
session = shiny::getDefaultReactiveDomain()
)
get_output(outputId, session = shiny::getDefaultReactiveDomain())
outputId |
output ID in the scope of current shiny session |
..., output_opts, .opt |
output options |
extras |
extra information to store |
session |
shiny session instance |
render_function |
shiny render function |
export_type |
type of export file formats supported, options are
|
export_settings |
a list of settings, depending on export type; see 'Details'. |
quoted |
whether |
Default shiny output does not provide handlers for downloading the figures or data, and is often limited to the 'HTML' layouts. 'RAVE' dashboard provides such mechanisms automatically with few extra configurations.
Registered output or output options.
if(interactive()) {
library(shiny)
library(ravedash)
rave_id <- paste(sample(c(letters, LETTERS, 0:9), 20, replace = TRUE),
collapse = "")
ui <- function(req) {
query_string <- req$QUERY_STRING
if(length(query_string) != 1) {
query_string <- "/"
}
query_result <- httr::parse_url(query_string)
if(!identical(toupper(query_result$query$standalone), "TRUE")) {
# normal page
basicPage(
output_gadget_container(
plotOutput("plot", brush = shiny::brushOpts("plot__brush")),
)
)
} else {
# standalone viewer
uiOutput("viewer")
}
}
server <- function(input, output, session) {
bindEvent(
safe_observe({
query_string <- session$clientData$url_search
query_result <- httr::parse_url(query_string)
if(!identical(toupper(query_result$query$module), "standalone_viewer")) {
# normal page
register_rave_session(session = session, .rave_id = rave_id)
register_output(
renderPlot({
plot(1:100, pch = 16)
}),
outputId = "plot", export_type = "pdf",
output_opts = list(brush = shiny::brushOpts("plot__brush"))
)
output$plot <- renderPlot({
input$btn
plot(rnorm(100), pch = 16)
})
} else {
# standalone viewer
standalone_viewer(outputId = "plot", rave_id = rave_id)
}
}),
session$clientData$url_search
)
}
shinyApp(ui, server, options = list(port = 8989))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.