当您更改' speed control
' ' timeRange
' sliderInput
重置为最小值。我希望它能够在当前的#39;滑块的值。主滑块是timeRange
滑块。此外,我想在播放动画时禁用speed
和step_size
滑块,并仅在动画暂停时使其可用。
有什么建议吗?
这是我的代码:
library(shiny)
ui <- fluidPage(
titlePanel("tester"),
sidebarLayout(
sidebarPanel(id="sidebar",
uiOutput("slider"),
uiOutput("speed_value"),
uiOutput("step_size")
),
mainPanel(
h4(textOutput("selectedtime"))
)
)
)
server <- function(input, output) {
minimum.slider <- "2016-08-12 UTC"
maximum.slider <- "2016-08-30 05:29:00 UTC"
output$slider <- renderUI({
## MAIN slider input into the output. The step depends on user defined 'speed' and 'interval depends on user defined 'step size'
sliderInput("timeRange", label = "Date/Time:", width = '600px',
min = minimum.slider,
max = maximum.slider,
value = minimum.slider,
step = (60*input$step_size),
timezone = "UTC",
animate = animationOptions(interval = 3200 - (input$speed*300),
playButton = tags$img(height = 40,width = 45,
src = "https://png.icons8.com/color/1600/circled-play",
tags$p(tags$b("PLAY"))),
pauseButton = tags$img(height = 40, width = 45,
src = "https://cdn2.iconfinder.com/data/icons/perfect-flat-icons-2/512/Pause_button_play_stop_blue.png",
tags$p(tags$b("PAUSE"))))
)
})
##animation speed control
output$speed_value <- renderUI({
sliderInput("speed",
label = div(style='width:300px;',
div(style='float:left;', 'slower'),
div(style='float:right;', 'faster')),
min = 1,
max = 10,
value = 6,
width = '300px')
})
##time step definition by user
output$step_size <- renderUI({
sliderInput("step_size","Time Steps (minutes):",
min = 10, max = 60, value = 1, width = '300px')
})
##OUTPUT
observe({
output$selectedtime <- renderText({
paste(format(input$timeRange))
})
})
}
shinyApp(ui,server)