更改valueBoxes的字体大小

时间:2016-07-18 16:26:27

标签: r shiny shinydashboard

我想更改valueBox es的值和字幕的字体大小。

以下是我的尝试,但会对如何以类似于默认外观的方式更改它的任何建议表示感谢。以下是我的可再培训的例子。

require(shinydashboard)

valueBox2 <- function (value,header_val=4, subtitle, icon = NULL, color = "aqua", width = 4, 
                       href = NULL) {
  shinydashboard:::validateColor(color)
  if (!is.null(icon)) 
    shinydashboard:::tagAssert(icon, type = "i")
  boxContent <- div(class = paste0("small-box bg-", color), 
                    div(class = "inner", eval(parse(text=paste0('h',header_val,'(',shQuote(value),')'))), p(subtitle)), if (!is.null(icon)) 
                      div(class = "icon-large", icon))
  if (!is.null(href)) 
    boxContent <- a(href = href, boxContent)
  div(class = if (!is.null(width)) 
    paste0("col-sm-", width), boxContent)
}

ui = dashboardPage(title='hello',
  dashboardHeader(title='hello2'),
  dashboardSidebar(
    sliderInput('hval',label='header value',min=1,max=6,value=3)
  ),
  dashboardBody(
    valueBoxOutput('tmp')
  )
)

server = function(input, output) {
  output$tmp <- renderValueBox({
    valueBox2(value='90k',header_val = input$hval, subtitle='some long descritptive text',icon=icon("car"))
    })
}

shinyApp(ui=ui,server=server)

1 个答案:

答案 0 :(得分:9)

您好,您可以使用valueBox标记直接在p更改字体大小,而无需重写valueBox功能(如果您愿意,只需包裹value和{{1在subtitle)中的args,尝试:

tags$p