You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing a string instead of an accessor into get_scatterplot_layer doesn't seem to produce a legend, even when visible = TRUE is enabled.
I can bypass this by creating a dummy column that is the same for every row in the object, and then using scale_color_* but this feels like a bit of a clunky workaround.
An example of the map I would expect to see a fill legend for:
library(rdeck)
library(dplyr)
library(sf)
library(absmapsdata)
shp <- sa32016 %>%
filter(gcc_name_2016 == "Greater Melbourne") |>
group_by(sa3_code_2016) |>
mutate(
centroid = st_centroid(geometry)
)
rdeck(
map_style = mapbox_dark(),
# set the bounds of the map to include all of the manhattan data
initial_bounds = st_bbox(shp),
# add a 2 pixel buffer to each point, making it easier to hover
picking_radius = 2
) |>
add_polygon_layer(
data = shp,
get_polygon = geometry,
filled = TRUE,
opacity = 0.1,
stroked = TRUE,
get_line_color = "#663399ff",
line_width_units = "pixels",
) |>
add_scatterplot_layer(
data = shp,
get_position = centroid,
get_radius = 200,
get_fill_color = "#ffffff",
visible = TRUE,
radius_min_pixels = 5
)
The workaround is to change get_fill_color to:
get_fill_color = cale_color_category(
col = state_name_2016,
palette = c("#ffffff")
)
I understand the normal use case for a string in get_fill_color is probably a useless single-valued legend. My use case is controlling several very similar layers with shiny that have each dataset on it's own layer (for individual toggling) and so the ability to create a "manual" legend would be very useful.
The text was updated successfully, but these errors were encountered:
Passing a string instead of an
accessor
intoget_scatterplot_layer
doesn't seem to produce a legend, even whenvisible = TRUE
is enabled.I can bypass this by creating a dummy column that is the same for every row in the object, and then using
scale_color_*
but this feels like a bit of a clunky workaround.An example of the map I would expect to see a fill legend for:
The workaround is to change
get_fill_color
to:I understand the normal use case for a string in
get_fill_color
is probably a useless single-valued legend. My use case is controlling several very similar layers with shiny that have each dataset on it's own layer (for individual toggling) and so the ability to create a "manual" legend would be very useful.The text was updated successfully, but these errors were encountered: