update_labels: Dynamically update labels

Description Usage Arguments Examples

View source: R/proxies.R

Description

Dynamically update labels using Shiny

Usage

1
2
3
4
5
6
7
8
update_labels(
  proxy,
  label.color = "#000",
  line.width = 1,
  font.size = 10,
  font.family = "Verdana",
  ...
)

Arguments

proxy

a proxy as returned by datamapsProxy.

label.color

color of label.

line.width

with of line.

font.size

size of font label.

font.family

family of font label.

...

any other option.

Examples

 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
## Not run: 
library(shiny)

ui <- fluidPage(
  actionButton(
    "update",
    "update labels"
  ),
  datamapsOutput("map")
)

server <- function(input, output){
  states <- data.frame(st = c("AR", "NY", "CA", "IL", "CO", "MT", "TX"),
                       val = c(10, 5, 3, 8, 6, 7, 2))

  output$map <- renderDatamaps({
    states %>%
      datamaps(scope = "usa", default = "lightgray") %>%
      add_choropleth(st, val) %>% 
      add_labels()
  })

  observeEvent(input$update, {
    datamapsProxy("map") %>%
      update_labels(sample(c("blue", "red", "orange", "green", "white"), 1)) # update
  })
}

shinyApp(ui, server)

## End(Not run)

JohnCoene/datamaps documentation built on Aug. 30, 2020, 7:20 a.m.