We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
srv_transform_teal_data
devtools::load_all("teal") tm_decorated_plot <- function(label = "module", decorators = list()) { checkmate::assert_list(decorators, "teal_transform_module", null.ok = TRUE) module( label = label, ui_args = list(decorators = decorators), server_args = list(decorators = decorators), ui = function(id, decorators) { ns <- NS(id) div( selectInput(ns("dataname"), label = "select dataname", choices = NULL), selectInput(ns("x"), label = "select x", choices = NULL), selectInput(ns("y"), label = "select y", choices = NULL), ui_transform_teal_data(ns("decorate"), transformators = decorators), plotOutput(ns("plot")), verbatimTextOutput(ns("text")) ) }, server = function(id, data, decorators) { moduleServer(id, function(input, output, session) { observeEvent(data(), { updateSelectInput(inputId = "dataname", choices = names(data())) }) dataname <- reactive({ req(input$dataname) input$dataname }) observeEvent(dataname(), { req(input$dataname) updateSelectInput(inputId = "x", choices = colnames(data()[[dataname()]])) updateSelectInput(inputId = "y", choices = colnames(data()[[dataname()]])) }) x <- reactive({ req(input$dataname) input$x }) y <- reactive({ req(input$dataname) input$y }) data_with_plot <- reactive({ req(dataname(), x(), y()) within(data(), { plot <- ggplot2::ggplot(dataname, ggplot2::aes(x = x, y = y)) + ggplot2::geom_point() }, dataname = as.name(dataname()), x = as.name(x()), y = as.name(y()) ) }) # Data without decorator has this error data_with_plot_decorated <- srv_transform_teal_data( "decorate", data = data_with_plot, transformators = list(static_decorator) ) # Data without decorator does not have this error # data_with_plot_decorated <- data_with_plot plot_r <- reactive({ data_with_plot_decorated()[["plot"]] }) reproducible_code <- reactive({ within(data_with_plot_decorated(), expr = plot) |> teal.code::get_code() }) output$plot <- renderPlot(plot_r()) output$text <- renderText(reproducible_code()) }) } ) } static_decorator <- teal_transform_module( label = "Static decorator", server = function(id, data) { moduleServer(id, function(input, output, session) { reactive({ within(data(), { plot <- plot + ggtitle("This is a better title") + xlab("the real x axis") }) }) }) } ) app <- init( data = teal_data(iris = iris, mtcars = mtcars), modules = modules( tm_decorated_plot("static", decorators = list(static_decorator)) ) ) shinyApp(app$ui, app$server)
The text was updated successfully, but these errors were encountered:
Having NULL here is a consequence of this. I think replacing NULL return with silent.shiny.error makes sense.
silent.shiny.error
Sorry, something went wrong.
Raise a shiny silent error when data is NULL (#1487)
b4cde98
Closes #1485 --------- Signed-off-by: Vedha Viyash <[email protected]> Co-authored-by: Dawid Kałędkowski <[email protected]>
vedhav
Successfully merging a pull request may close this issue.
What happened?
Code of Conduct
Contribution Guidelines
Security Policy
The text was updated successfully, but these errors were encountered: