2017-09-12 1 views
2

Ich entwickle einen Test ShinyApp mit 7 oder 8 valueBox. Alles funktioniert gut außer, glänzend fügt drei valueBox pro Zeile hinzu. Im Moment habe ich oben drei Zeilen, die diese 7 valueBox anzeigen. Ich habe versucht, den width-Parameter zu ändern, und es funktioniert nicht. Das ist mein Code unten.glänzend passend mehr als drei Wert-Box in einer Reihe

Mein Ziel ist es, 5 ValueBox pro Zeile anstelle der Standard drei zu haben. Jede Beratung wird sehr geschätzt.

## 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

+0

Vielleicht 'Spalten verwenden()' gesetzt, siehe [Beispiel hier] (https://shiny.studio.com/articles/layout-guide .html) – zx8754

Antwort

1

Wir konnten die width in 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) 

    ) 
) 
) 

-Ausgang

enter image description here

+1

Hinzufügen von Breite = 2 in der UI gearbeitet. Vielen Dank –

Verwandte Themen