Description Usage Arguments Examples
Update a continuous scale in Shiny
1 2 | update_continuous_breaks(proxy, var, palette = NULL, direction = 1,
n_breaks = 5, style = "pretty")
|
proxy |
A |
var |
New var to use on the map. |
palette |
Color palette, you can use Viridis or Brewer color palette. |
direction |
Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed. |
n_breaks |
Number of breaks to cut data (depending on |
style |
Style for computing breaks, see |
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_breaks(var = "AGE_00", palette = "Blues") %>%
add_legend(d3_format = ".2s")
})
observeEvent(input$var, {
d3_map_proxy(shinyId = "mymap", data = paris) %>%
update_continuous_breaks(var = input$var, palette = "Blues")
}, 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.