Description Usage Arguments Examples
Update a legend in Shiny
1 2 | update_legend(proxy, title = "", prefix = "", suffix = "",
d3_format = NULL)
|
proxy |
A |
title |
Title for the legend. |
prefix |
A prefix of legend labels. |
suffix |
A suffix of legend labels. |
d3_format |
A string passed to |
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 48 49 50 | ## 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) %>%
update_legend(title = tolower(gsub(
pattern = "_", replacement = " ", x = input$var
)), d3_format = ".1s")
}, 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.