I'd like to remove the comma from the date in the sparkling tooltip, but I need to keep it in the value. I don't fully understand the jQuery Sparkline formatting.
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)
As defined here, you can set numberDigitGroupSep
to empty string:
data <- raw_data %>%
# Create the sparkline
summarise(
"value" = sparkline::spk_chr(
c(value),
numberDigitGroupSep = "",
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'
)
)