2

In noUiSliderInput() the numbers are shown as decimal by default like: 5.00 To change to integer like: 5

we can use the argument format: format = list(wNumbFormat(decimals = 0, thousand = ",", prefix = "$"))

This only works partially like here:

library( shiny )
library( shinyWidgets )

ui <- fluidPage(

  div(style = 'position: absolute;left: 150px; top:270px; width:950px;margin:auto',
  noUiSliderInput(
    inputId = "noui2", label = "Slider vertical:",
    min = 0, max = 45, step = 1,
    value = c(15, 20), margin = 10,
    orientation = "vertical",
    width = "100px", height = "300px",
    format = list(wNumbFormat(decimals = 0, thousand = ",", prefix = "$"))
  ),
  verbatimTextOutput(outputId = "res2")
  )
)
server <- function(input, output, session) {
  output$res2 <- renderPrint(input$noui2)
}
shinyApp(ui, server)

enter image description here

What is the reason for this behavior?

TarJae
  • 72,363
  • 6
  • 19
  • 66
  • 1
    What happens when you set `step = NULL` like [here](https://stackoverflow.com/questions/42675102/r-shiny-slider-input-round)? – Quinten Feb 17 '23 at 18:46
  • 1
    All numbers turn now in decimals with more then 10 comma positions. Strange! – TarJae Feb 17 '23 at 19:00

1 Answers1

2

I'm not sure why you are wrapping wNumbFormat in a list, but notice that while you set the prefix to "$", it does not show up in your graphic/video, suggesting that your options are not being used.

Remove the list and it works:

ui <- fluidPage(

  div(style = 'position: absolute;left: 150px; top:270px; width:950px;margin:auto',
  noUiSliderInput(
    inputId = "noui2", label = "Slider vertical:",
    min = 0, max = 45, step = 1,
    value = c(15, 20), margin = 10,
    orientation = "vertical",
    width = "100px", height = "300px",
    format = wNumbFormat(decimals = 0, thousand = ",", prefix = "$")
  ),
  verbatimTextOutput(outputId = "res2")
  )
)

enter image description here

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 1
    Perfect @r2evans. I could have think about it, but not even imagined that the `list` could be the problem. I took the code from the documentation and I swear in the morning there was a list in it, but now I can't find the site. Anyway thanks a lot. – TarJae Feb 17 '23 at 19:48