Under dashboardBody
I have a tabs
function where I need to specify an argument to put under content
. I am trying to put two fluidRows
so that I have 2 rows each with 2 plots, however the other row is not showing. I have tried using div(fluidRows(), fluidRows())
but the plots end up being arranged in one column instead of two.
How do I make the content
portion of tabs
to accept multiple fluidRows
so that I can arrange the plots in rows and columns as desired?
Included is a code snippet of what I had done so far.
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")),
box(width = 8, 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)
Perhaps you should try fillRow
and 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")),
semantic.dashboard::box(width=6, plotOutput("unif"))) ,
column(12, semantic.dashboard::box(width = 5, plotOutput("chisq")),
semantic.dashboard::box(width = 5, 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.