如何从迷你图工具提示中的日期中删除逗号?
How do I remove the comma from the date in the sparkline tooltip?
我想从闪亮的工具提示中删除日期中的逗号,但我需要将其保留在值中。
我不完全理解 jQuery Sparkline 格式。
Sparkling tooltip example
library(shiny)
library(dplyr)
ui <- fluidPage(
htmlwidgets::getDependency('sparkline'),
DT::dataTableOutput("table")
)
server <- function(input, output) {
raw_data <- data.frame(date = 2000:2021,
value = sample(100:500, 22))
data <- raw_data %>%
# Create the sparkline
summarise("value" = sparkline::spk_chr(c(value),
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'))
output$table <- DT::renderDataTable({
cb <- htmlwidgets::JS('function(){debugger;HTMLWidgets.staticRender();}')
DT::datatable(data = data,
escape = FALSE,
options = list(drawCallback = cb))
})
}
shinyApp(ui, server)
如定义here,您可以将numberDigitGroupSep
设置为空字符串:
data <- raw_data %>%
# Create the sparkline
summarise(
"value" = sparkline::spk_chr(
c(value),
numberDigitGroupSep = "",
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'
)
)
我想从闪亮的工具提示中删除日期中的逗号,但我需要将其保留在值中。 我不完全理解 jQuery Sparkline 格式。
Sparkling tooltip example
library(shiny)
library(dplyr)
ui <- fluidPage(
htmlwidgets::getDependency('sparkline'),
DT::dataTableOutput("table")
)
server <- function(input, output) {
raw_data <- data.frame(date = 2000:2021,
value = sample(100:500, 22))
data <- raw_data %>%
# Create the sparkline
summarise("value" = sparkline::spk_chr(c(value),
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'))
output$table <- DT::renderDataTable({
cb <- htmlwidgets::JS('function(){debugger;HTMLWidgets.staticRender();}')
DT::datatable(data = data,
escape = FALSE,
options = list(drawCallback = cb))
})
}
shinyApp(ui, server)
如定义here,您可以将numberDigitGroupSep
设置为空字符串:
data <- raw_data %>%
# Create the sparkline
summarise(
"value" = sparkline::spk_chr(
c(value),
numberDigitGroupSep = "",
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'
)
)