由网友(空城旧梦丶旧少年)分享简介:我希望能够选择将由useShinydashboard()命令修改的valueBox,而不是以下示例中的全部library(shiny)library(shinydashboard)library(shinyWidgets)ui <- fluidPage(tags$h2("Classic shiny"),setBa...
我希望能够选择将由useShinydashboard()
命令修改的valueBox
,而不是以下示例中的全部
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Classic shiny"),
setBackgroundColor(color = "ghostwhite"),
useShinydashboard(),
fluidRow(
valueBox(
tagList("60", tags$sup(style="font-size: 20px", "%")),
"Approval Rating", icon = icon("line-chart"), color = "green"
),
valueBox(
htmlOutput("progress"), "Progress", icon = icon("users"), color = "purple"
)))
server <- function(input, output, session) {
output$orderNum <- renderText({
prettyNum(input$orders, big.mark=",")
})
output$progress <- renderUI({
tagList(input$progress, tags$sup(style="font-size: 20px", "%"))
})
}
shinyApp(ui, server)
#编辑
添加如何useShinydashboard()
如果没有useShinydashboard()
,则如下所示
useShinydashboard()
。
第一个valueBox
由生成
valueBox(value=div(paste(1.51,"(1 óbito a cada 66 casos)"),style="font-size:25px;"),
subtitle = tags$div(HTML('<b style = "padding-left:10px;font-size:16px">LETALIDADE</b>')),
width=12,
#icon = icon("skull", lib = "font-awesome"),
color = "black")
问题在于useShinydashboard()
命令在全局范围内更改。下图是没有useShinydashboard()
的情况(这就是我想要的)
但useShinydashboard()
命令如下
推荐答案
或许您可以在ui
上使用此函数。
myvalueBox <- function (value, subtitle, icon = NULL, color = "white", 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", h3(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)
}
然后将程序中的valueBox()
替换为myvalueBox
。
相关推荐
最新文章