I am trying to create a value box module that uses a custom valuebox design as a function and want the parameters to be dynamics. The code is throwing an error that I can figure out. here is my codes
# Custom valueBox function
valueBoxSpark <- function(value, title, sparkobj = NULL, subtitle, info = NULL,
icon = NULL, color = "aqua", width = 4, href = NULL){
shinydashboard:::validateColor(color)
if (!is.null(icon))
shinydashboard:::tagAssert(icon, type = "i")
info_icon <- tags$small(
tags$i(
class = "fa fa-info-circle fa-lg",
title = info,
`data-toggle` = "tooltip",
style = "color: rgba(255, 255, 255, 0.75);"
),
# bs3 pull-right
# bs4 float-right
class = "pull-right float-right"
)
boxContent <- div(
class = paste0("small-box bg-", color),
div(
class = "inner",
tags$small(title),
if (!is.null(sparkobj)) info_icon,
h3(value),
if (!is.null(sparkobj)) sparkobj,
p(subtitle)
),
# bs3 icon-large
# bs4 icon
if (!is.null(icon)) div(class = "icon-large icon", icon, style = "z-index; 0")
)
if (!is.null(href))
boxContent <- a(href = href, boxContent)
div(
class = if (!is.null(width)) paste0("col-sm-", width),
boxContent
)
}
##############################
# mod_valuebox.R
#
#
#
##############################
mod_valuebox_ui <- function(id){
ns <- NS(id)
tagList(
valueBoxOutput(ns("vb"), width=4)
)
}
#' valuebox Server Functions
#'
#'
mod_valuebox_server <- function(id,value,title,info,icon,colour){
moduleServer(id, function(input, output, session){
ns <- session$ns
output$vb <- renderValueBox({
valueBoxSpark(value = value,
title = title,
info = info,
icon =icon,
color = colour,
width = 4)
})
})
}
### UI and server call
server.R
mod_valuebox_server("valuebox_ui_tot",
value = 0,
title = "Sold",
info = "Graphe",
icon = icon("water"),
colour = "aqua",
)
ui.R
bs4TabItem(
tabName = "tab1",
mod_valuebox_ui("valuebox_ui_tot")
)