【问题标题】:Change width of valueBox in RShiny在 R Shiny 中更改 valueBox 的宽度
【发布时间】:2020-10-30 21:32:56
【问题描述】:

我正在创建这样的值框:

valueBox(value = tags$p(winterMean, style = "font-size: 70%;"), 
                   subtitle = tags$p("Mean Winter Performance \u20ac / MWh", style = "font-size: 90%;"), 
                   color = "black")

产生以下valueBox()

黑色在ui.R 文件中定义如下:

tags$head(
  tags$style(".small-box.bg-black { background-color: #007d3c !important; color: #FFFFFF !important; }")
)

如何将valueBox的宽度改为红线?

【问题讨论】:

    标签: r shiny width shinydashboard


    【解决方案1】:

    valueBox()valueBoxOutput 函数有一个 width 参数(使用从 1 到 12 的引导网格系统,请参阅“布局”部分 here):

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(title = "Value boxes"),
      dashboardSidebar(),
      dashboardBody(
        fluidRow(
          # A static valueBox
          valueBox(10 * 2, "New Orders", icon = icon("credit-card"), width = 2),
          
          # Dynamic valueBoxes
          valueBoxOutput("progressBox", width = 2),
          
          valueBoxOutput("approvalBox", width = 2)
        ),
        fluidRow(
          # Clicking this will increment the progress amount
          box(width = 4, actionButton("count", "Increment progress"))
        )
      )
    )
    
    server <- function(input, output) {
      output$progressBox <- renderValueBox({
        valueBox(
          paste0(25 + input$count, "%"), "Progress", icon = icon("list"),
          color = "purple"
        )
      })
      
      output$approvalBox <- renderValueBox({
        valueBox(
          "80%", "Approval", icon = icon("thumbs-up", lib = "glyphicon"),
          color = "yellow"
        )
      })
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 2016-05-27
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多