【问题标题】:The downloadablePlot shiny module is not displayed in a shiny app可下载的闪亮模块未显示在闪亮的应用程序中
【发布时间】:2021-04-13 00:53:10
【问题描述】:

我有下面的shiny 应用程序,我想知道如何使用downloadablePlot Shiny 模块下载绘图。当我启动应用程序时,我得到Error in visibleplot: could not find function "visibleplot"。应该是通过shiny包加载的,没有显示按钮。

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)

【问题讨论】:

    标签: r shiny downloadableplot


    【解决方案1】:

    downloadablePlotUI 上的文档说明如下:

    此模块不兼容内置(基础)图形(图形包提供的任何功能,如绘图),因为它们不能保存到对象中,并且在创建时由系统直接输出。

    您正在使用无法显示的 plot(iris)。

    使用ggplot 将显示绘图。我仍然没有得到下载按钮。

    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 )
      
    }
    

    【讨论】:

      猜你喜欢
      • 2017-12-09
      • 1970-01-01
      • 2017-09-30
      • 1970-01-01
      • 2013-07-08
      • 2014-10-28
      • 2016-05-23
      • 2017-12-11
      • 2021-03-20
      相关资源
      最近更新 更多