Closed tomroh closed 11 months ago
034cdbbe5adae872bb4756030494acea7d12c8fb
addSizeLegend
gains an argument stacked
that will produce stacked size charts. This works for all available shapes but only circle, rect, and triangle are recommended.
library(leaflet)
library(leaflegend)
data("quakes")
baseSize <- 5
numPal <- colorNumeric('viridis', 10^(quakes$mag))
leaflet(quakes) |>
addTiles() |>
addLegendSize(
values = ~10^(mag),
title = 'Magnitude',
baseSize = baseSize,
shape = 'circle',
color = 'black',
fillColor = 'red',
position = 'topright',
stacked = TRUE,
breaks = 5,
strokeWidth = 2) |>
addLegendSize(
values = ~10^(mag),
title = 'Magnitude',
baseSize = baseSize,
shape = 'triangle',
color = 'black',
fillColor = 'red',
position = 'topright',
stacked = TRUE,
breaks = 5,
strokeWidth = 2) |>
addLegendSize(
values = ~10^(mag),
title = 'Magnitude',
baseSize = baseSize,
shape = 'diamond',
color = 'black',
fillColor = 'red',
position = 'topright',
stacked = TRUE,
breaks = 5,
strokeWidth = 2) |>
addLegendSize(
values = ~10^(mag),
title = 'Magnitude',
baseSize = baseSize,
shape = 'stadium',
color = 'black',
fillColor = 'red',
position = 'topright',
stacked = TRUE,
breaks = 5,
strokeWidth = 2)
See https://github.com/r-tmap/tmap/issues/777.