library(shiny)
library(plotly)
server <- function(input, output, session) {
rv <- reactiveValues(i = 0)
output$myplot <- renderPlotly({
dt = data.frame(x = 1:10, y = rep(rv$i,10))
plot_ly(dt, x = ~x, y =~y, mode = "markers", type = 'scatter')
})
observeEvent(input$run,{
rv$i <- 0
})
observe({
isolate({rv$i = rv$i + 1})
if (rv$i < 10){invalidateLater(1000, session)}
})
}
ui <- fluidPage(
actionButton("run", "START"),
plotlyOutput("myplot")
)
shinyApp(ui = ui, server = server)