Description Usage Arguments Examples
Dynamically add bubbles using Shiny.
1 | 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. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ## Not run:
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)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.