Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple ranges on one sliderInput

Tags:

r

slider

shiny

I know how to create a sliderInput of a value and a sliderInput of a range.

# ui
shinyUI(fluidPage(
  fluidRow(
    column(4,

      # Copy the line below to make a slider bar 
      sliderInput("slider1", label = h3("Slider"), min = 0, 
        max = 100, value = 50)
    ),
    column(4,

      # Copy the line below to make a slider range 
      sliderInput("slider2", label = h3("Slider Range"), min = 0, 
        max = 100, value = c(40, 60))
    )
  ),

  hr(),

  fluidRow(
    column(4, verbatimTextOutput("value")),
    column(4, verbatimTextOutput("range"))
  )

)) 

However, I'd like a sliderInput with multiple ranges on the one slider. That is the ability to independently select three or more values on the one slider. My initial thought of setting value = c(40, 60, 80) didn't work: the 80 was ignored. I appreciate that this feature might not be implemented.

like image 335
Hugh Avatar asked Oct 28 '25 12:10

Hugh


1 Answers

At the moment shiny sliderInput is implementing in shiny the jQuery Ion.RangeSlider (http://ionden.com/a/plugins/ion.rangeSlider/en.html) as you can see from sliderInput function definition (https://github.com/rstudio/shiny/blob/master/R/input-slider.R).

By construction Ion.RangeSlider has maximum two handles (by default range selection).

It has been requested to implement arbitrary number of handles to whom is responsible of the development of this plugin (IonDen). unfortunately he rejected the request.

The only way out seem to build your own htmlwidget based on other jquery sliders.

like image 123
gico Avatar answered Oct 31 '25 03:10

gico



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!