如何使用Shinydashboard()? [英] How to use useShinydashboard()?

查看:0
本文介绍了如何使用Shinydashboard()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够选择将由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

这篇关于如何使用Shinydashboard()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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