簡體   English   中英

可下載的 Plot shiny 模塊未顯示在 shiny 應用程序中

[英]The downloadablePlot shiny module is not displayed in a shiny app

我有下面的shiny應用程序,我想知道如何使用可下載的 Plot Shiny 模塊downloadablePlot plot。 當我啟動應用程序時Error in visibleplot: could not find function "visibleplot" 它應該通過shiny package 加載,並且按鈕不顯示。

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)

downloadablePlotUI上的文檔說明如下:

該模塊與內置(基礎)圖形(圖形package提供的任何功能,例如繪圖)不兼容,因為它們無法保存到object中,並且在系統創建時直接為Z78E6221F6393D1356681DB398F14CE6。

您正在使用無法顯示的 plot(iris)。

使用ggplot將顯示 plot。 我仍然沒有得到下載按鈕。

server <- function(input, output, session) {
  output$plot<-renderPlot(plotInput())
  plotInput <- function() {
    ggplot(cars, aes(x=speed, y=dist))+geom_point()
  }
  plot <- ggplot(cars, aes(x=speed, y=dist))+geom_point()
  callModule(downloadablePlot,
             "object_id1", 
             logger = ss_userAction.Log,
             filenameroot = "mydownload1",
             aspectratio = 1.33,
             downloadfxns = list(png = plotInput),
             visibleplot = plotInput )
  
}

暫無
暫無

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

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