Hi,
I am interested in using the animation frame within the event_data framework in shiny. Is this possible and if not are their any suggested workarounds. The intended use case is in this app, using the animation frame rather than shiny animation allows me to speed up map generation.
Thanks in advance!
Working example into which I would like to add extracting the frame data.
#install.packages(c("shiny", "plotly", "getTBinR"))
library(shiny)
library(plotly)
library(getTBinR)
tb_burden <- get_tb_burden()
ui <- fluidPage(
plotlyOutput("map_tb_burden"),
dataTableOutput("country")
)
server <- function(input, output, session) {
# Make map of metric
output$map_tb_burden <- renderPlotly({
key <- tb_burden$iso3
g <- list(
showframe = FALSE,
showcoastlines = FALSE,
projection = list(type = 'Mercator')
)
plot_ly(data = tb_burden, frame = ~year, type = 'choropleth', z = ~e_inc_100k, text = ~country, color = ~e_inc_100k, colors = "Reds", locations = ~iso3, key = key) %>%
layout(geo = g)
})
#Get country clicked on map
countryB <- reactive({
d <- event_data("plotly_click")
ff <- data.frame(d[3])
ff
})
output$country <- renderDataTable({
d <- event_data("plotly_click")
# if (is.null(d))
# return(NULL)
withProgress(message = 'Click on a country', {
validate(
need(d, 'Click on a country!')
)
testing <- tb_burden %>% filter(iso3 == countryB()$key)
testing
})
})
}
shinyApp(ui, server)