David
David

Reputation: 10152

Currency signs in valueBox shinydashboard/shiny

I created a shiny-app that displays values in a valueBox. The values are supposed to be displayed with the respective currency ($ or € or £), however, only the $-sign is displayed.

An MWE looks like this:

library(shinydashboard)
library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "MWE"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      valueBox(value = paste0(sprintf("%.2f", 123.14), "$"), 
               subtitle = "This works good:", 
               color = "green"),
      valueBox(value = paste0(sprintf("%.2f", 123.14), "€"), 
               subtitle = "This does not work:", 
               color = "red")
    )
  )
)
server <- function(input, output) {
}

shinyApp(ui, server)

Any ideas?

Upvotes: 3

Views: 3226

Answers (1)

Victorp
Victorp

Reputation: 13856

Hi you could use the HTML code for € (&#8364; or even &euro;) like below. And you can also use FontAwesome icons :

library(shinydashboard)
library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "MWE"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      valueBox(value = paste0(sprintf("%.2f", 123.14), "$"), icon = icon("dollar"),
               subtitle = "This works good:", 
               color = "green"),
      valueBox(value = HTML(paste0(sprintf("%.2f", 123.14), "&#8364;")), icon = icon("euro"),
               subtitle = "This does not work:", 
               color = "red")
    )
  )
)
server <- function(input, output) {
}

shinyApp(ui, server)

Upvotes: 4

Related Questions