簡體   English   中英

downloadablePlot Shiny 模塊在啟動時分解了我的 shiny 應用程序

[英]The downloadablePlot Shiny Module breaks down my shiny app upon launching

我有下面的shiny應用程序,我想知道如何使用downloadablePlot Shiny 模塊下載 plot。 當我啟動該應用程序時,整個應用程序都崩潰了。

library(shiny)
library(periscope)
ui <- fluidPage(
  plotOutput("plot"),
  downloadablePlotUI("object_id1", 
                     downloadtypes = c("png", "csv"), 
                     download_hovertext = "Download the plot and data here!",
                     height = "500px", 
                     btn_halign = "left")
)

server <- function(input, output) {
  output$plot<-renderPlot(plot(iris))
  plotInput = function() {
    plot(iris)
  }
  callModule(downloadablePlot,
             "object_id1", 
             logger = ss_userAction.Log,
             filenameroot = "mydownload1",
             aspectratio = 1.33,
             downloadfxns = list(png = plotInput()),
             visibleplot = plotInput())
  
}

shinyApp(ui = ui, server = server)

將 plotInput 作為參數傳遞時,嘗試刪除plotInput之后的括號

library(shiny)
library(periscope)
ui <- fluidPage(
  plotOutput("plot"),
  downloadablePlotUI("object_id1",
                     downloadtypes = c("png", "csv"),
                     download_hovertext = "Download the plot and data here!",
                     height = "500px",
                     btn_halign = "left")
)

server <- function(input, output) {
  output$plot<-renderPlot(plot(iris))
  plotInput = function() {
    plot(iris)
  }
  callModule(downloadablePlot,
             "object_id1",
             logger = ss_userAction.Log,
             filenameroot = "mydownload1",
             aspectratio = 1.33,
             downloadfxns = list(png = plotInput),
             visibleplot = plotInput)

}

shinyApp(ui = ui, server = server)

在 shiny 中,當傳遞函數/反應時,你通常需要避免在它們后面附加() ,因為這樣做會評估它們。 在上面的示例中,您返回的是plotInput的 output 而不是 function 本身

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM