SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox
https://symbolixau.github.io/mapdeck/articles/mapdeck.html
363 stars 40 forks source link

scatterplot manual legend #301

Closed dcooley closed 4 years ago

dcooley commented 4 years ago

The colours don't show up in the legend

set_token( secret::get_secret("mapbox") )

df <- capitals
df$my_colour <- ifelse( substr(df$country, 1, 1) == "A", "#00FF00FF", "#FF0000FF")

l1 <- legend_element(
    variables = c("Begins with A", "Doesn't begin with A")
    , colours = c("#00FF00FF", "#FF0000FF")
    , colour_type = "fill"
    , variable_type = "category"
)
js <- mapdeck_legend(l1)

mapdeck() %>%
    add_scatterplot(
        data = capitals
        , fill_colour = "country"
        , legend = js
    )