简体   繁体   English

货币符号在valueBox shinydashboard /有光泽

[英]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. 这些值应该与相应的货币($或€或£)一起显示,但是,只显示$ -sign。

An MWE looks like this: MWE看起来像这样:

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? 有任何想法吗?

Hi you could use the HTML code for € ( &#8364; or even &euro; ) like below. 嗨,您可以使用HTML代码( &#8364;甚至&euro; ),如下所示。 And you can also use FontAwesome icons : 您还可以使用FontAwesome图标

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM