闪亮的连续超过三个值框

时间:2017-09-12 06:11:24

标签: r shiny shinydashboard flexdashboard

我正在开发一个带有7或8个valueBox的测试ShinyApp。一切都工作得很好,除了,闪亮的是每行添加三个valueBox。现在我在顶部有三行显示这7个valueBox。我尝试更改宽度参数,它不起作用。这是我的代码。

我的目标是每行有5个valueBox而不是默认值3。任何建议都非常感谢。

## Only run this example in interactive R sessions

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(

      valueBoxOutput("vbox1"),
      valueBoxOutput("vbox2"),
      valueBoxOutput("vbox3"),
      valueBoxOutput("vbox4"),
      valueBoxOutput("vbox5"),
      valueBoxOutput("vbox6"),
      valueBoxOutput("vbox7"),
      valueBoxOutput("vbox8")

    )
  )
)

server <- function(input, output) {

  output$vbox1 <- renderValueBox({ valueBox( "One","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox2 <- renderValueBox({ valueBox( "Two","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox3 <- renderValueBox({ valueBox( "Skip","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox4 <- renderValueBox({ valueBox( "a Two","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox5 <- renderValueBox({ valueBox( "Then","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox6 <- renderValueBox({ valueBox( "some","Yes", width = 2, icon = icon("stethoscope"))})
  output$vbox7 <- renderValueBox({ valueBox( "a hundred too","Yes", width = 2, icon = icon("stethoscope"))})

}

shinyApp(ui, server)

Shiny Output with Three ValueBox per row

1 个答案:

答案 0 :(得分:4)

我们可以在width

中设置valueBoxOutput
ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(

      valueBoxOutput("vbox1", width = 2),
      valueBoxOutput("vbox2", width = 2),
      valueBoxOutput("vbox3", width = 2),
      valueBoxOutput("vbox4", width = 2),
      valueBoxOutput("vbox5", width = 2)),
      fluidRow(
      valueBoxOutput("vbox6", width = 2),
      valueBoxOutput("vbox7", width = 2),
      valueBoxOutput("vbox8", width = 2)

    )
  )
  )

-output

enter image description here