在 R Shiny 中更改 valueBox 的宽度
Change width of valueBox in RShiny
我正在创建这样的值框:
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
的宽度更改为红线?
valueBox()
和 valueBoxOutput
函数有一个 width
参数(从 1 到 12 使用 bootstrap 网格系统,参见“布局”部分 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)
我正在创建这样的值框:
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
的宽度更改为红线?
valueBox()
和 valueBoxOutput
函数有一个 width
参数(从 1 到 12 使用 bootstrap 网格系统,参见“布局”部分 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)