【问题标题】:shiny slider with button for increment and decrement带有用于递增和递减按钮的闪亮滑块
【发布时间】:2020-10-29 02:17:45
【问题描述】:

闪亮的滑块是否有可能具有用于递增和递减的按钮,而不是拖动滑块?

【问题讨论】:

  • 如果您使用observeEvent 作为您的input$button,其中包括一个updateSliderInput,通过执行selected = input$slider+1 之类的操作来增加所选值,我认为这应该是可能的。

标签: r ggplot2 shiny ggplotly


【解决方案1】:

也许我的包裹shinyChakraSlider 是合适的。 chakraSliderInput 结合了滑块和数字输入:

这是生成您在此 GIF 上看到的应用程序的代码:

library(shiny)
library(shinyChakraSlider)

ui <- fluidPage(
  br(),
  chakraSliderInput("slider", value = 5, min = 0, max = 10, step = 0.5,
                    width = "50%", size = "lg",
                    numberInputOptions = numberInputOptions(
                      width = "25%",
                      fontSize = "15px", 
                      fontColor = "navyblue",
                      borderColor = "yellow",
                      borderWidth = "medium",
                      focusBorderColor = "navyblue",
                      stepperColor = c("palegreen", "palevioletred")
                    ),
                    trackColor = c("red", "blue"),
                    thumbOptions = thumbOptions(
                      width = "40px",
                      height = "30px",
                      color = "pink",
                      borderColor = "magenta",
                      borderWidth = "2px",
                      icon = "arrows",
                      iconSize = "2em"
                    )
  ),
  br(),
  verbatimTextOutput("value")
)

server <- function(input, output){
  output[["value"]] <- renderPrint({
    input[["slider"]]
  })
}

shinyApp(ui, server)

要安装这个包:

devtools::install_github("stla/shinyChakraInput")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-01
    • 2011-09-04
    相关资源
    最近更新 更多