我使用 R 在传单地图上绘制 GPS 数据,通过动画模式下 sliderInput 提供的递增时间线将行程可视化。
sliderInput("animation", "Mesures GPS :",
min = ifelse( !exists("i.data"), 0, min(i.data$sequence)),
max = ifelse( !exists("i.data"), 1, max(i.data$sequence)),
value = 0,
step=20,
animate = animationOptions(interval = 1000, loop = FALSE),
width="100%"))
Run Code Online (Sandbox Code Playgroud)
我可以看到 GPS 点在地图上跳跃,现在我正在寻找使用“下一步”按钮([<<]、[>>])来控制更精细的本地步骤的方法。我在 sliderInput 文档中没有看到任何这样的选项。
这也可以通过添加临时的闪亮操作按钮来完成,
有什么建议吗?
改编代码?sliderInput:
library(shiny)
shinyApp(
ui = fluidPage(
fluidRow(
div(style = "display: inline-block;vertical-align:center;",
actionButton("left", label = "<<")),
div(style = "display: inline-block;vertical-align:center;",
sliderInput("obs", "Number of observations:",
min = 0, max = 1000, value = 500
)),
div(style = "display: inline-block;vertical-align:center;",
actionButton("right", label = ">>")),
),
plotOutput("distPlot")
),
# Server logic
server = function(input, output, session) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
observeEvent(input$left, {
updateSliderInput(session, "obs", value = input$obs - 10)
})
observeEvent(input$right, {
updateSliderInput(session, "obs", value = input$obs + 10)
})
}
)
Run Code Online (Sandbox Code Playgroud)
更新 +/- 10。
| 归档时间: |
|
| 查看次数: |
420 次 |
| 最近记录: |