Skip to content

Commit 8e919e9

Browse files
committed
bgcol and bgcol_alpha workign in view mode
1 parent 5559a3b commit 8e919e9

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# tmap 4.2.0.9000 (dev version)
22

3+
- tm_text: bgcol and bgcol_alpha implemented in view mode
4+
35
# tmap 4.2
46

57
- [!] improved legend (labeling #1174 and continuous-style intervals #1175)

R/tmapLeafletComp.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) {
156156

157157
nbins = length(val)
158158

159-
160-
161159
incl.na = cmp$na.show
162160

163161
if (incl.na) {
@@ -170,7 +168,7 @@ tmapLeaflet_legend = function(cmp, lf, o, orientation) {
170168
val = val[sel]
171169

172170
if (!breaks_show) {
173-
cli::cli_warn("{.field tm_scale_intervals} {.code label.style = {.str continuous}} implementation in view mode work in progress")
171+
if (cmp$scale == "intervals") cli::cli_warn("{.field tm_scale_intervals} {.code label.style = {.str continuous}} implementation in view mode work in progress")
174172
if (!head(sel, 1)) {
175173
val = c(cmp$limits[1], val)
176174
} else {

R/tmapLeafletDataPlot_text.R

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ tmapLeafletDataPlot.tm_data_text = function(a, shpTM, dt, pdt, popup.format, hdt
4949
col_set = unique(gp$col)
5050

5151
bgcol_set = unique(gp$bgcol)
52+
bgcol_alpha = unique(gp$bgcol_alpha)
5253

53-
if (any(bgcol_set != "#00000000")) {
54-
message("Variable bgcol and bgcol_alpha not supported by view mode")
55-
}
54+
# if (any(bgcol_set != "#00000000")) {
55+
# message("Variable bgcol and bgcol_alpha not supported by view mode")
56+
# }
5657

5758

5859
if (length(face_set) != 1) message("Variable fontfaces not supported by view mode")
5960

60-
vary = (length(cex_set) != 1) || (length(alpha_set) != 1) || (length(face_set) != 1) || (length(col_set) != 1)
61+
vary = (length(cex_set) != 1) || (length(alpha_set) != 1) || (length(face_set) != 1) || (length(col_set) != 1) || (length(bgcol_set) != 1) || (length(bgcol_alpha) != 1)
6162

6263
sizeChar <- paste(round(gp$cex * 12), "px", sep="")
6364

@@ -88,7 +89,10 @@ tmapLeafletDataPlot.tm_data_text = function(a, shpTM, dt, pdt, popup.format, hdt
8889
direction = direction,
8990
opacity=gp$col_alpha[1],
9091
textsize=sizeChar[1],
91-
style=list(color=gp$col[1])),
92+
style=list("color"=gp$col[1],
93+
"background-color" = paste0("rgba(", paste(col2rgb(gp$bgcol[1]), collapse = ", "), ",", gp$bgcol_alpha[1], ")"),
94+
# "border" = "2px solid rgba(0, 0, 0, 0.5)",
95+
"padding" = paste0(round(2 * gp$cex[1]), "px"))),
9296
options = markerOptions(pane = pane),
9397
clusterOptions = clusterOpts,
9498
clusterId = cidt)
@@ -104,7 +108,10 @@ tmapLeafletDataPlot.tm_data_text = function(a, shpTM, dt, pdt, popup.format, hdt
104108
direction = direction,
105109
opacity=gp$col_alpha[i],
106110
textsize=sizeChar[i],
107-
style=list(color=gp$col[i])),
111+
style=list("color"=gp$col[i],
112+
"background-color" = paste0("rgba(", paste(col2rgb(gp$bgcol[i]), collapse = ", "), ",", gp$bgcol_alpha[i], ")"),
113+
# "border" = "2px solid rgba(0, 0, 0, 0.5)",
114+
"padding" = paste0(round(2 * gp$cex[i]), "px"))),
108115
options = markerOptions(pane = pane),
109116
clusterOptions = clusterOpts,
110117
clusterId = cidt)

0 commit comments

Comments
 (0)