Dynamically add bubbles using Shiny.
update_choropleth(proxy, locations, color, reset = FALSE, ...)
proxy | a proxy as returned by |
---|---|
locations | column containing location names as |
color | column containing color of each |
reset | reset previous changes to |
... | any other variable to use for tooltip. |
if (FALSE) { library(shiny) ui <- fluidPage( selectInput( "countrySelect", "Select Country", choices = c("USA", "FRA", "CHN", "RUS", "COG", "DZA", "BRA", "IND") ), sliderInput( "value", "Value", min = 1, max = 10, value = 5 ), actionButton("update", "Update"), datamapsOutput("map") ) server <- function(input, output){ data <- data.frame(name = c("USA", "FRA", "CHN", "RUS", "COG", "DZA", "BRA", "IND", "ALG", "AFG"), color = 1:10) updated_data <- reactive({ data.frame(name = input$countrySelect, value = input$value) }) output$map <- renderDatamaps({ data %>% datamaps() %>% add_choropleth(name, color) }) observeEvent(input$update, { datamapsProxy("map") %>% add_data(updated_data()) %>% # pass updated data update_choropleth(name, value, TRUE) # update }) } shinyApp(ui, server) }