如何在shinyDashboard布局中更改tabPanel宽度?

问题描述

我目前正在使用软件包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的大小。我不知道如何更改它。

View of the Shiny App

你能帮我吗?谢谢!

解决方法

请尝试这个。

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

您可以尝试这种方法

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

sidebar<-dashboardSidebar()

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

ui<-dashboardPage(header,output) {
  output$plot<-renderPlot({plot(1)},height = 500)
}

shinyApp(ui,server)