如何解决在 R 的semantic.dashboard 包中使用tabBox 时,如何包含多个fluidRow 函数
在 dashboardBody
下,我有一个 tabs
函数,我需要指定一个参数放在 content
下。我试图放置两个 fluidRows
以便我有 2 行,每行有 2 个图,但是另一行没有显示。我曾尝试使用 div(fluidRows(),fluidRows())
,但这些图最终排列在一列而不是两列中。
如何使 content
的 tabs
部分接受多个 fluidRows
以便我可以根据需要按行和列排列图?
library(shiny)
library(shiny.semantic)
library(semantic.dashboard)
ui <- dashboardPage(
dashboardHeader(color = "black",title = "Dashboard Demo",inverted = TRUE),dashboardSidebar(
size = "",color = "teal",sidebarMenu(
menuItem(tabName = "main","Main",icon = icon("car")),menuItem(tabName = "extra","Extra",icon = icon("table"))
)
),dashboardBody(
tabBox(width = 16,tabs = list(list(menu = "Section 1",content = fluidRow(Box(width = 8,plotOutput("norm")),Box(width = 8,plotOutput("unif"))),fluidRow(Box(width = 8,plotOutput("chisq")),plotOutput("unif2")))),list(menu = "Section 2",content = plotOutput("norm2"))
)
)
),theme = "cerulean"
)
server <- function(input,output) {
output$norm <- renderPlot({hist(rnorm(500))})
output$unif <- renderPlot({hist(runif(500))})
output$chisq <- renderPlot({hist(rchisq(500,2))})
output$norm2 <- renderPlot({hist(rnorm(500))})
output$unif2 <- renderPlot({hist(runif(500))})
}
shinyApp(ui = ui,server = server)
解决方法
也许你应该试试 fillRow
和 column()
。
ui <- dashboardPage(
dashboardHeader(color = "black",title = "Dashboard Demo",inverted = TRUE),dashboardSidebar(
size = "",color = "teal",sidebarMenu(
menuItem(tabName = "main","Main",icon = icon("car")),menuItem(tabName = "extra","Extra",icon = icon("table"))
)
),dashboardBody(
semantic.dashboard::tab_box(width = 12,tabs = list(list(menu = "Section 1",content = fillRow(column(12,semantic.dashboard::box(width=6,plotOutput("norm")),plotOutput("unif"))),column(12,semantic.dashboard::box(width = 5,plotOutput("chisq")),plotOutput("unif2"))) ) ),list(menu = "Section 2",content = plotOutput("norm2"))
)
)
),theme = "cerulean"
)
server <- function(input,output) {
output$norm <- renderPlot({hist(rnorm(500))})
output$unif <- renderPlot({hist(runif(500))})
output$chisq <- renderPlot({hist(rchisq(500,2))})
output$norm2 <- renderPlot({hist(rnorm(500))})
output$unif2 <- renderPlot({hist(runif(500))})
}
shinyApp(ui = ui,server = server)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。