【问题标题】:How to change tabPanel width in a shinyDashboard layout?如何更改闪亮仪表板布局中的 tabPanel 宽度?
【发布时间】:2020-12-03 03:12:28
【问题描述】:

我目前正在设计一个带有 shinydashboard 包的 Shiny App。

我正在使用tabsetPanel 布局,我无法更改每个tabPanel 的宽度,以便绘图适合整个窗口宽度。 width = 参数中的值似乎对其没有影响。

我已经尝试了问题中给出的所有解决方案:Shiny: How to adjust the width of the tabsetPanel?,但这些都不适合我。

这是我的代码:

library(shiny)
library(shinydashboard)


header<-dashboardHeader(title="Shiny App")

sidebar<-dashboardSidebar()

body<-dashboardBody(
  fluidRow(
  mainPanel(
    tabsetPanel(
      tabPanel("Panel1",
          box(plotOutput("plot"),height=420,width = 1400)
      )
    )
  )
  )
)

ui<-dashboardPage(header,sidebar,body)

server<-function(input,output) {
  output$plot<-renderPlot({plot(1)})
}

shinyApp(ui,server)

无论width 的值是多少,我都有tabPanel 的大小。我不知道如何更改它。

你能帮帮我吗?谢谢!

【问题讨论】:

    标签: css r plot shiny shinydashboard


    【解决方案1】:

    请试试这个。

    library(shiny)
    library(shinydashboard)
    
    header<-dashboardHeader(title="Shiny App")
    
    sidebar<-dashboardSidebar()
    
    body<-dashboardBody(
    
          tabsetPanel(
            fluidRow(
              tabBox(id = "tabset1", height = "650px", width=12, title = "My Box Size",  ## change box size here
                     tabPanel("Panel1",
                              fluidRow(
                                column(12, plotOutput("plot",height=420, width=600)) ## change plot width here
                              )
                     )
          )))
    
    )
    
    
    ui<-dashboardPage(header,sidebar,body)
    
    server<-function(input,output) {
      plot1 <- qplot(rnorm(500),fill=I("red"),binwidth=0.2,title="plotgraph1")
      output$plot<-renderPlot({plot1})
    }
    
    shinyApp(ui,server)
    

    【讨论】:

    • 感谢您的回答,我尝试在我的程序上实现它,但它仍然无法正常工作。它可以在您的计算机上运行吗?
    【解决方案2】:

    你可以试试这个方法

    header<-dashboardHeader(title="Shiny App")
    
    sidebar<-dashboardSidebar()
    
    body<-dashboardBody(
      fluidRow(
        mainPanel(
          tabsetPanel(
             
            tabPanel("Panel1",
                     box(plotOutput("plot", width = 950, height = 100)))
          )
        )
      )
    )
    
    ui<-dashboardPage(header,sidebar,body)
    
    server<-function(input,output) {
      output$plot<-renderPlot({plot(1)},height = 500)
    }
    
    shinyApp(ui,server)
    

    【讨论】:

    • 感谢您的回答!我尝试了这个和注释行,但不幸的是这些都不适合我。它可以在您的计算机上运行吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 2021-12-13
    • 1970-01-01
    • 2015-10-21
    • 1970-01-01
    • 2017-12-14
    • 2015-04-22
    相关资源
    最近更新 更多