Kes*_*etE 3 r shiny shinydashboard
我想在同一行显示4个infoBoxes(或valueBoxes,我真的不在乎),它似乎不起作用......
这是一个工作的简化版本的代码,基于Rstudio wesite上的shinydashbaord教程(我使用的是infoBoxOutputs,但我想这里的格式无关紧要):
ui <- dashboardPage(
dashboardHeader(title = "Info boxes"),
dashboardSidebar(),
dashboardBody(
# infoBoxes with fill=FALSE
fluidRow(
infoBox("1st", 10 * 2, icon = icon("credit-card")),
infoBox("2nd", 10 * 2, icon = icon("credit-card")),
infoBox("3rd", 10 * 2, icon = icon("credit-card")),
)
)
)
Run Code Online (Sandbox Code Playgroud)
它在同一行显示3个infoBox.但是,一旦我再添加一个infoBox,它就会移动到一个新行:
ui <- dashboardPage(
dashboardHeader(title = "Info boxes"),
dashboardSidebar(),
dashboardBody(
# infoBoxes with fill=FALSE
fluidRow(
infoBox("1st", 10 * 2, icon = icon("credit-card")),
infoBox("2nd", 10 * 2, icon = icon("credit-card")),
infoBox("3rd", 10 * 2, icon = icon("credit-card")),
infoBox("4th", 10 * 2, icon = icon("credit-card")),
)
)
)
Run Code Online (Sandbox Code Playgroud)
我也尝试使用列 - 然后这些框显示在同一行上,但是被扭曲了.
有任何想法吗?
在fluidRowfrom中shiny,我们知道它的最大列宽为12.
看看infoxBox功能:
infoBox(title, value = NULL, subtitle = NULL,
icon = shiny::icon("bar-chart"), color = "aqua", width = 4,
href = NULL, fill = FALSE)
}
Run Code Online (Sandbox Code Playgroud)
我们看到宽度的设置是width = 4.
要在一行中安装所需的4个信息框,只需设置即可width = 3.
所有意图和目的的明确示例:
library(shiny)
library(shinydashboard)
server <- function(input, output) {
}
ui <- fluidPage(
fluidRow(
infoBox("test", value=1, width=3),
infoBox("test", value=2, width=3),
infoBox("test", value=3, width=3),
infoBox("test", value=4, width=3)
)
)
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)
产量: