當切換dashboardSidebar菜單時,圖形和表格(通過R Shiny製作)不會相應地調整它們的寬度。R Shiny,dashboardSidebar在切換時中斷圖形和表格寬度
下面是一個標準圖形和表格的例子。初始化應用程序時,圖形和表格會正確填充屏幕,但切換菜單會打破這兩個元素的寬度。
這是如何解決的,因此它們的寬度始終都是100%?
library(shiny)
library(shinydashboard)
library(dygraphs)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(id = "menu_tabs",
menuItem("Test", tabName = "page_1", icon = icon("table"), selected = TRUE)
)
),
dashboardBody(
tabItems(
tabItem(tabName = "page_1",
fluidRow(
column(width = 12, offset = 0,
box(width = 12,
dygraphOutput("dy_plot", height = "310px")
)
)
),
fluidRow(
column(width = 12, offset = 0,
box(width = 12,
dataTableOutput('mytable')
)
)
)
)
)
)
)
server <- function(input, output) {
output$mytable = renderDataTable({
mtcars
},
options = list(
lengthMenu = c(30),
pageLength = 30,
searching = FALSE,
paging = FALSE,
ordering = FALSE,
scrollX = TRUE))
output$dy_plot <- renderDygraph({
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths)
})
}
shinyApp(ui, server)