闪亮的更新图输出brushOpts

时间:2019-01-31 17:20:31

标签: r shiny

可以通过ui中的 input (如radioButtons)在 plotOutput 中控制 brushOpts 。我在这里写一个简单的代码。这个想法是当radioButtons为"sweeping"时,我想将 brushOpts 中的 resetOnNew 设置为TRUE 并且如果radioButtons为"brushing",我想将 resetOnNew 设置为FALSE

library(shiny)
ui <- fluidPage(
radioButtons("select", "Select type:",  
              choices = c("sweeping", "brushing"), 
              selected = "sweeping"),
plotOutput(outputId="plots",
           brush = brushOpts(id = "plot_brush",
                             resetOnNew = TRUE))
)   

server <- function(input, output, session) {

   output$plots <-  renderPlot({
     input$plot_brush
     if(input$select == "sweeping")  {
        plot(1:10)       
     } else {
     # input select is "brushing", I want to update 
     # resetOnNew in brushOpts to FALSE, like:

     # brushOpts(id = "plot_brush",
     #           resetOnNew = FALSE)

     plot(10:1)
   }  
 })
} 
shinyApp(ui, server)

0 个答案:

没有答案