Skip to content

Commit

Permalink
Tweak hover to allow for TRUE or FALSE special behavior. (as do…
Browse files Browse the repository at this point in the history
…cumented)
  • Loading branch information
olivroy committed Jun 25, 2024
1 parent fe4d00e commit 97c86b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
11 changes: 0 additions & 11 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@

* In view mode, `hover` is now independent from `id` (#851).

```r
tmap_mode("view")
# v3
tm_shape(World) +
tm_polygons(id = "footprint")

# v4
tm_shape(World) +
tm_polygons(id = "footprint", hover = "footprint")
```

# tmap 3.3-4
- (!) last version of tmap 3.x. Next CRAN version will be tmap 4.x (release planned at the end of 2023)
- fixed bug (some stars appeared upside down in plot mode)
Expand Down
12 changes: 9 additions & 3 deletions R/step1_helper_facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,17 @@ step1_rearrange_facets = function(tmo, o) {
rlang::arg_match(popup.vars, values = smeta$vars, multiple = TRUE)
}
if (length(popup.vars)) add_used_vars(popup.vars)

if (!is.na(hover) && hover != "" && !hover %in% smeta$vars) rlang::arg_match0(hover, smeta$vars, "hover label", error_call = NULL)
if (!is.na(hover) && hover != "") add_used_vars(hover)
# if hover = FALSE, disable hovering
if (isFALSE(hover)) hover <- ""
# If hover is not specified, default to id
if (identical(hover, NA)) hover <- id
# If hover = TRUE, set to id
if (isTRUE(hover)) hover <- id
if (id != "" && !id %in% smeta$vars) rlang::arg_match0(id, smeta$vars, arg_nm = "id", error_call = NULL)
if (id != "") add_used_vars(id)
if (!is.na(hover) && hover != "" && !hover %in% smeta$vars) rlang::arg_match0(hover, smeta$vars, "hover", error_call = NULL)
if (!is.na(hover) && hover != "") add_used_vars(hover)

})
})

Expand Down

0 comments on commit 97c86b7

Please sign in to comment.