无论浏览器页面宽度如何,修复WellPanel的宽度

时间:2017-06-09 09:16:01

标签: shiny shiny-server

我根据以下代码创建了一个闪亮的仪表板:

library(shinydashboard)
library(shiny)

sidebar <- dashboardSidebar(

  sidebarMenuOutput("menu"),
  conditionalPanel("input.tabs == 'ABC'",
    fluidRow(
      column(11, offset = 1, h5((' Note')))
    )
  ),
  conditionalPanel("input.tabs == 'ABC1'",
    fluidRow(
      column(11, offset = 1, style = "height:20px; color:rgb(30,144,255);", h1((' Update')))
    )
  ))

body <- dashboardBody(
  tabItems(
    tabItem(tabName = "ABC1",br())

  ),
  tabItems(
    tabItem(tabName = "ABC",br(),

fixedRow(column(10, offset = 1, wellPanel()))


)

  )
)


ui = dashboardPage(
  dashboardHeader(title = "ABC"),
  sidebar,
  body
)

server = function(input, output){
  output$menu <- renderMenu({
    sidebarMenu(id="tabs",
      menuItem("ABC", tabName="ABC", icon=icon("line-chart"), selected=TRUE),
      menuItem("ABC1", tabName="ABC1", icon=icon("line-chart"))
    )
  })
}

shinyApp(ui = ui, server = server)

通过以上设置,如果我调整浏览器大小,WellPanel的宽度会发生变化。因此,当我在更大的屏幕(例如2560 x 1080)中看到我的应用程序时,这看起来很丑陋。我希望WellPanel的整个尺寸将保持不变。如果浏览器大小小于WellPanel,则会出现一些水平/垂直滚动条。如果更大,Wellpanel将保持在浏览器的中上部分。

知道在上面的代码中需要更改哪些设置才能实现此目的。

谢谢,

1 个答案:

答案 0 :(得分:0)

我认为这有效:

library(shinydashboard)
library(shiny)

sidebar <- dashboardSidebar(
  
  sidebarMenuOutput("menu"),
  conditionalPanel("input.tabs == 'ABC'",
                   fluidRow(
                     column(11, offset = 1, h5((' Note')))
                   )
  ),
  conditionalPanel("input.tabs == 'ABC1'",
                   fluidRow(
                     column(11, offset = 1, style = "height:20px; color:rgb(30,144,255);", h1((' Update')))
                   )
  ))

body <- dashboardBody(
  tags$head(tags$style(type = "text/css"
                       , '#plotUI {min-width: 570px; max-width: 570px;overflow:auto;}'
  )
)
  ,tabItems(
    tabItem(tabName = "ABC1",br())
    
  ),
  tabItems(
    tabItem(tabName = "ABC",br(),
            
            fluidRow(column(10, offset = 1
                            ,div(class="thiswell"
                            , wellPanel(
                                        style= "min-width: 600px;max-width: 600px;overflow:auto",
                                        ,uiOutput("plotUI")
                              
                            )
                            )
                            ) )
            
            
    )
    
  )
)

ui = dashboardPage(
  dashboardHeader(title = "ABC"),
  sidebar,
  body
)

server = function(input, output){
  output$menu <- renderMenu({
    sidebarMenu(id="tabs",
                menuItem("ABC", tabName="ABC", icon=icon("line-chart"), selected=TRUE),
                menuItem("ABC1", tabName="ABC1", icon=icon("line-chart"))
    )
  })
  
  output$plotUI<- renderUI({
    plotOutput("thePlot")
  })
  
  output$thePlot<- renderPlot({
    plot(1:10)
  })
  
}

shinyApp(ui = ui, server = server)