Skip to content

Commit

Permalink
fixed #667
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Sep 21, 2023
1 parent c78278f commit 14a61e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions R/tmapLeafletLegend.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,27 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) {
domain = val,
na.color=colNA,
alpha = FALSE)

brks = pretty(cmp$limits, 7)

trns = function(x) {
f = (x-cmp$limits[1]) / diff(cmp$limits)
y = cmp$tr$fun(cmp$limits)
x2 = y[1] + diff(y) * f
cmp$tr$rev(x2)
}

lf |> leaflegend::addLegendNumeric(position=legpos,
orientation = orientation,
group = group,
height = {if (orientation == "horizontal") 20 else 200},
width = {if (orientation == "vertical") 20 else 200},
pal=pal,
values=val,
numberFormat = function(x) {
prettyNum(trns(x), format = "f", big.mark = ",", digits =
3, scientific = FALSE)
},
#na.label = textNA,
title=title,
fillOpacity=cmp$gp3$alpha,
Expand Down
5 changes: 4 additions & 1 deletion R/tmapScaleContinuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ tmapScaleContinuous = function(x1, scale, legend, o, aes, layer, layer_args, sor
labels = c(labels, label.na)
attr(labels, "align") = labels.align
}
#attr(vvalues, "style") = style



legend = within(legend, {
Expand All @@ -257,7 +257,10 @@ tmapScaleContinuous = function(x1, scale, legend, o, aes, layer, layer_args, sor
vneutral = value.neutral
na.show = get("na.show", envir = parent.env(environment()))
scale = "continuous"
tr = tr
limits = limits
})
# NOTE: tr and limits are included in the output to facilitate the transformation of the leaflet continuous legend ticks (https://github.com/rstudio/leaflet/issues/665)

if (submit_legend) {
if (bypass_ord) {
Expand Down

0 comments on commit 14a61e4

Please sign in to comment.