我正在尝试将图像加载到我的shinydashboard中,当图像呈现时,图像中心会出现一个蓝色问号。我在我的工作目录中创建了一个www文件夹,并将png放在该文件夹中。
到目前为止,我对此选项卡的布局是:
tabItem(tabName = "Alignment",
fluidRow(
tags$img(src = 'Alignment.png', height = 800, width = 1200)
)
),标签名称显示在我的shinydashboard中,它试图加载图像,如果我更改它,它会调整图像大小,但它没有加载任何内容。
对于为什么会这样,有什么建议吗?
发布于 2018-05-09 00:51:26
你需要把图片放在服务器端来渲染它。
试试这个:
library (shiny)
library (shinydashboard)
library (png)
###/UI SIDE/###
header <- dashboardHeader()
sidebar <- dashboardSidebar(
sidebarMenu(id = "test",
menuItem("Alignment", tabname = "AlignmentTab")
)
)
body <- dashboardBody(
tabItem(tabName = "AlignmentTab",
fluidRow(
box(
title = "Alignment", status = "primary", solidHeader = TRUE, width = 12,
imageOutput("Alignment", height = "auto")
)
)
)
)
ui <- dashboardPage(header, sidebar, body)
###/SERVER SIDE/###
server <- function(input, output, session) {
output$picture <- renderImage({
return(list(src = "/srv/samba/share/site layouts//Alignment.PNG",contentType = "image/png",alt = "Alignment"))
}, deleteFile = FALSE) #where the src is wherever you have the picture
}
#Combines Dasboard and Data together----
shinyApp(ui, server)发布于 2019-09-12 17:41:55
我尝试了上面的答案。啊,真灵。我只需要稍微调整一下,因为我相信在imageOutput()命令中,参数应该是imageOutput("picture", height = "auto")而不是imageOutput("Alignment", height = "auto")。
https://stackoverflow.com/questions/50182910
复制相似问题