【发布时间】:2021-04-09 03:38:34
【问题描述】:
我有下面的shinydashboard,其中我几乎消除了标题并在正文顶部添加了一个图像。在它下面有两行框,问题是图像和fluidRow() 之间浪费了太多空白空间,正如您在 scrshot 中看到的那样。
## app.R ##
library(shiny)
library(shinydashboard)
library(shinyjs)
library(tableHTML)
ui <- dashboardPage(
dashboardHeader(titleWidth = 0,
tags$li(class = "dropdown",
tags$style(".main-header {max-height: 0px}"),
tags$style(".main-header .logo {height: 0px;}"),
tags$style(".sidebar-toggle {height: 0px; padding-top: 0px !important;}"),
tags$style(".navbar {min-height:0px !important}")
) ),
dashboardSidebar(
checkboxGroupInput("box", "Select box",
c("Red", "Green", "Blue", "Yellow"),selected = "Red")
),
dashboardBody(
fluidRow(
imageOutput("image"), # IMAGE TOO BIG AND BOX CANNOT COMPLETELY CONTAIN IT
),
fluidRow(
column(4,uiOutput("box1")),
column(4,uiOutput("box2")),
column(4,uiOutput("box3"))
),
fluidRow(
column(4,uiOutput("box4"))
),
tags$script("document.getElementsByClassName('sidebar-toggle')[0].style.visibility = 'hidden';")
)
)
server <- function(input, output) {
output$box1<-renderUI({
if("Red" %in% input$box)
box(
"Red",height = 300,width = 5
)
})
output$box2<-renderUI({
if("Green" %in% input$box)
box(
"Green",height = 300,width = 5
)
})
output$box3<-renderUI({
if("Blue" %in% input$box)
box(
"Blue",height = 300,width = 5
)
})
output$box4<-renderUI({
if("Yellow" %in% input$box)
box(
"Yellow",height = 300,width = 5
)
})
output$image <- renderImage({
filename <- normalizePath(file.path(paste0('www/', "connect-shopify-to-google-analytics", '.jpg')))
list(
src = filename,
height = 150,
width=1700
)
}, deleteFile = FALSE)
}
shinyApp(ui, server)
【问题讨论】:
标签: r shiny shinydashboard