InfoBox Shinydashboard上的自定义图标

时间:2019-10-15 16:19:40

标签: r shiny shinydashboard flexdashboard

是否可以使用infoBoxshinydashboard上的自定义图标。我正在尝试使用hrbrmstr gist上的示例,但是找不到更新infoBox函数的地方。

library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(width = 2, actionButton("count", "Count")),
      infoBoxOutput("ibox"),
      valueBoxOutput("vbox")
    )
  )
)

server <- function(input, output) {
  output$ibox <- renderInfoBox({
    infoBox(
      "Title",
      input$count,
      #icon = icon("credit-card")
icon=icon(list(src=x, width="80px"), lib="local")
    )
  })
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      input$count,
      icon = icon("credit-card")
    )
  })
}

shinyApp(ui, server)

1 个答案:

答案 0 :(得分:0)

我使用了leonawicz中的apputils软件包。我用infoBox取代了apputils::infoBox函数。

library(shiny)
library(apputils)
#exApp("icons")
ui <- dashboardPage(
  dashboardHeader(title = "Dynamic boxes"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      box(width = 2, actionButton("count", "Count")),
      infoBoxOutput("ibox"),
      valueBoxOutput("vbox")
    )
  )
)

server <- function(input, output) {

  output$ibox <- renderInfoBox({
    ic <- apputils::icon(list(src = "https://cdn1.iconfinder.com/data/icons/money-47/512/Money_Currency_Finance-41-512.png", width = "80px"), lib = "local")
    apputils::infoBox(
      "Title",
      input$count,
      icon = ic
      #icon = icon("credit-card")
      #icon=icon(list(src=x, width="80px"), lib="local")
    )
  })
  output$vbox <- renderValueBox({
    valueBox(
      "Title",
      input$count,
      icon = icon("credit-card")
    )
  })
}

shinyApp(ui, server)