当 tabpanel 干净时在闪亮的应用程序中显示文本,并在显示输出时隐藏它

Show text in shiny app when tabpanel is clean and hide it when output is displayed

我有一些图,一旦单击提交按钮就会显示,但在此之前,选项卡保持干净。我希望在那里显示一些文本,以便用户可以在点击提交按钮之前看到一些东西,一旦单击按钮,我希望删除文本并且它必须显示图表。

这是我对闪亮应用示例的看法:

library(shiny)
library(shinyjs)

# Define UI for application that draws a histogram
ui <- fluidPage(
    useShinyjs(),
    
    # Application title
    titlePanel("Old Faithful Geyser Data"),
    
    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30),
            actionButton("submit", "Show plot")
        ),
        
        # Show a plot of the generated distribution
        mainPanel(
            tabsetPanel(
                tabPanel(
                    "Plot",
                    uiOutput("help_text"),
                    plotOutput("distPlot")
                )
            )
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
    
    output$help_text <- renderUI({
        HTML("<b>Click 'Show plot' to show the plot.</b>")
    })
    
    plot_data <- eventReactive(input$submit, {
        
        hide("help_text")
        
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)
        
        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
    
    output$distPlot <- renderPlot({
        plot_data()
    })
}

# Run the application 
shinyApp(ui = ui, server = server)