Description Usage Arguments Examples
Update a gradient scale in Shiny
1 2 |
proxy |
A |
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. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.