禁用特定范围滑块
Disable specific range slider
我有一个最小值为 0,最大值为 1 的 sliderInput。有没有办法可以禁用范围 0 - 0.2 和 0.8 - 1,这样用户只能从范围 select滑块上的 0.2 - 0.8?
注意:我不想更改最大和最小值,我想让用户知道还有更多,但目前select不能。
我通过这个 post 找到了有价值的信息,但我希望得到与使用 shinyjs::disable("")
时相同的输出。意味着无法获得的灰色区域。
谢谢!!
有一种可能:
sliderInput2 <- function(inputId, label, min, max, value, step=NULL, from_min, from_max){
x <- sliderInput(inputId, label, min, max, value, step)
x$children[[2]]$attribs <- c(x$children[[2]]$attribs,
"data-from-min" = from_min,
"data-from-max" = from_max)
x
}
css <- "
.irs-grid-text {
color: black;
}
.js-grid-text-0, .js-grid-text-1, .js-grid-text-9, .js-grid-text-10 {
color: #99a4ac;
}"
ui <- fluidPage(
tags$head(
tags$style(HTML(css))
),
sliderInput2("slider", "Slide:",
min = 0, max = 1, value = 0.5, step = 0.1, from_min = 0.2, from_max = 0.8
)
)
server <- function(input, output) {}
shinyApp(ui, server)
我有一个最小值为 0,最大值为 1 的 sliderInput。有没有办法可以禁用范围 0 - 0.2 和 0.8 - 1,这样用户只能从范围 select滑块上的 0.2 - 0.8?
注意:我不想更改最大和最小值,我想让用户知道还有更多,但目前select不能。
我通过这个 shinyjs::disable("")
时相同的输出。意味着无法获得的灰色区域。
谢谢!!
有一种可能:
sliderInput2 <- function(inputId, label, min, max, value, step=NULL, from_min, from_max){
x <- sliderInput(inputId, label, min, max, value, step)
x$children[[2]]$attribs <- c(x$children[[2]]$attribs,
"data-from-min" = from_min,
"data-from-max" = from_max)
x
}
css <- "
.irs-grid-text {
color: black;
}
.js-grid-text-0, .js-grid-text-1, .js-grid-text-9, .js-grid-text-10 {
color: #99a4ac;
}"
ui <- fluidPage(
tags$head(
tags$style(HTML(css))
),
sliderInput2("slider", "Slide:",
min = 0, max = 1, value = 0.5, step = 0.1, from_min = 0.2, from_max = 0.8
)
)
server <- function(input, output) {}
shinyApp(ui, server)