update_continuous_gradient: Update a gradient scale in Shiny

Description Usage Arguments Examples

Description

Update a gradient scale in Shiny

Usage

1
2

Arguments

proxy

A d3_map_proxy object.

var

New var to use on the map.

low, high

Colours for low and high ends of the gradient.

range

A length two vector to force range of data.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Not run: 

if (interactive()) {

library(r2d3maps)
library(shiny)

# data about Paris
data("paris")


# app
ui <- fluidPage(
  fluidRow(
    column(
      width = 8, offset = 2,
      tags$h2("Proxy for continuous breaks scale"),
      d3Output(outputId = "mymap"),
      selectInput(
        inputId = "var", label = "Variable:",
        choices = grep(pattern = "AGE", x = names(paris), value = TRUE)
      )
    )
  )
)

server <- function(input, output, session) {

  output$mymap <- renderD3({
    d3_map(shape = paris) %>%
      add_continuous_gradient(var = "AGE_00", low = "#FEE0D2", high = "#CB181D") %>%
      add_legend(d3_format = ".2s")
  })

  observeEvent(input$var, {
    d3_map_proxy(shinyId = "mymap", data = paris) %>%
      update_continuous_gradient(var = input$var)
  }, ignoreInit = TRUE)

}

shinyApp(ui, server)

}


## End(Not run)

dreamRs/r2d3maps documentation built on May 25, 2019, 8:17 a.m.