更改ValueBox的字号 [英] Changing the font size of valueBoxes

查看:0
本文介绍了更改ValueBox的字号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要更改valueBoxES的值和副标题的字体大小。

以下是我的尝试,但如果有任何关于如何以类似于默认外观的方式更改它的建议,我们将不胜感激。以下是我的可报告示例。

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)

推荐答案

Hi您可以使用p标记直接在valueBox中更改字体大小,而无需重写valueBox函数(如果需要,只需将valuesubtitle参数放在tags$p中),尝试:

library("shiny")
library("shinydashboard")

# header
header <- dashboardHeader(title = "Changing the font size of valueBoxes", titleWidth = 450)

# sidebar
sidebar <- dashboardSidebar(disable = TRUE)

# body
body <- dashboardBody(
  valueBox(
    value = "90k",
    subtitle = "some long descritptive text",
    icon = icon("car")
  ),
  valueBox(
    value = tags$p("90k", style = "font-size: 150%;"),
    subtitle = tags$p("some long descritptive text", style = "font-size: 150%;"),
    icon = icon("car fa-lg")
  ),
  valueBox(
    value = tags$p("90k", style = "font-size: 200%;"),
    subtitle = tags$p("some long descritptive text", style = "font-size: 200%;"),
    icon = icon("car fa-2x")
  ),
  valueBoxOutput(outputId = "mybigbox")
)

# server
server <- function(input, output) {
  output$mybigbox <- renderValueBox({
    valueBox(
      value = tags$p("90k", style = "font-size: 300%;"),
      subtitle = tags$p("some long descritptive text", style = "font-size: 300%;"),
      icon = icon("car fa-3x")
    )
  })
}
shinyApp(ui = dashboardPage(header, sidebar, body), server = server)

这篇关于更改ValueBox的字号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆